Fix onbeforeunload event handler processing#2353
Conversation
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.
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> |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
(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> |
There was a problem hiding this comment.
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> |
|
Proposed commit message: |
There are two particular fixes:
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.