Skip to content

Fix onbeforeunload event handler processing#2353

Merged
domenic merged 3 commits intomasterfrom
fix-beforeunload
Feb 14, 2017
Merged

Fix onbeforeunload event handler processing#2353
domenic merged 3 commits intomasterfrom
fix-beforeunload

Conversation

@domenic
Copy link
Copy Markdown
Member

@domenic domenic commented Feb 11, 2017

There are two particular fixes:

  • null should not cancel the event; this was flipped
  • CustomEvents with type "beforeunload" should not get this special
    behavior (especially since they could be non-cancelable)

This also modernizes the surrounding section, style-wise.

Fixes #2297.

/cc @bzbarsky, although I don't think your review is necessarily required if you're busy. Also @nox and @jdm regarding servo/servo#15142

Tests at web-platform-tests/wpt#4800. Spoiler alert: Firefox passes them all; Chrome doesn't seem to do the Web IDL conversion correctly; Edge craps out because I tried to access a function from one window in another.

There are two particular fixes:

- null should *not* cancel the event; this was flipped
- CustomEvents with type "beforeunload" should not get this special
  behavior (especially since they could be non-cancelable)

This also modernizes the surrounding section, style-wise.

Fixes #2297.
domenic added a commit to web-platform-tests/wpt that referenced this pull request Feb 11, 2017
source Outdated
data-x="event-error">error</code> and <var>E</var> is an <code>ErrorEvent</code> object</dt>

<dd><p>If <var>return value</var> is a Web IDL boolean true value, then set <var>E</var>'s
<span>canceled flag</span>.</p></dd>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make this "If [return value] is true"? (I'm also surprised that in the algorithm above we do not directly link https://heycam.github.io/webidl/#invoke-a-callback-function. That's what DOM does.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(My other super nitpick here is that I tend to put <dt>/<dd>s together without newlines, and only separate the groups with a newline. Not sure if now is the time to discuss though.)

data-x="idl-DOMString">DOMString</code>.</p>

<p>If the <var>return value</var> is null, then cancel the event.</p>
<p>If <var>return value</var> is not null, then:</p>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know when this regressed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to have been wrong ever since it was introduced in 7612afe . The comment at https://www.w3.org/Bugs/Public/show_bug.cgi?id=19713#c12 is wrong too.

source Outdated
<dd><p>If <var>return value</var> is a Web IDL boolean false value, then cancel the
event.</p></dd>
<dd><p>If <var>return value</var> is a Web IDL boolean false value, then set <var>E</var>'s
<span>canceled flag</span>.</p></dd>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just say "false" here.

@domenic
Copy link
Copy Markdown
Member Author

domenic commented Feb 13, 2017

Proposed commit message:

Fix onbeforeunload event handler processing

There are two particular fixes:

* null should *not* cancel the event. This has been flipped ever since
  it was introduced in 7612afe2f2d13939094811b4f42000edede24069. It
  appears the mistake occured between
  https://www.w3.org/Bugs/Public/show_bug.cgi?id=19713#c11 (includes
  "not") and https://www.w3.org/Bugs/Public/show_bug.cgi?id=19713#c12
  (which elides it).
* Only applies the special behavior to BeforeUnloadEvents, not to any
  Event with the name "beforeunload". This is especially important since
  such events could be non-cancelable, in which case the previous text
  could potentially cancel them anyway.

This also modernizes the surrounding section, style-wise.

Fixes #2297.

@domenic domenic merged commit fb7e621 into master Feb 14, 2017
@domenic domenic deleted the fix-beforeunload branch February 14, 2017 20:15
@domenic
Copy link
Copy Markdown
Member Author

domenic commented Feb 14, 2017

domenic added a commit to web-platform-tests/wpt that referenced this pull request Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

onbeforeunload return value handling is broken

2 participants