[Webkit-unassigned] [Bug 169789] I found one more onbeforeunload event return value coercion edge case

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Mar 16 16:07:08 PDT 2017


https://bugs.webkit.org/show_bug.cgi?id=169789

--- Comment #3 from Chris Dumez <cdumez at apple.com> ---
(In reply to comment #2)
> (In reply to comment #1)
> > (In reply to comment #0)
> > > The newly-introduced test at
> > > http://w3c-test.org/html/browsers/browsing-the-web/unloading-documents/
> > > beforeunload-canceling.html named
> > > 
> > > > Returning false must not cancel the event, because it's coerced to the DOMString "false" which does not cancel CustomEvents: CustomEvent, cancelable
> > > 
> > > does not pass in Safari Tech Preview 25. Everything else does (except the
> > > test "Returning a string must not cancel the event: BeforeUnloadEvent with
> > > type "click", cancelable" which is fine since it's best if Safari doesn't
> > > implement createEvent("beforeunload"); see
> > > https://github.com/whatwg/dom/issues/362.)
> > 
> > I am not clear yet on what part of the spec says so.
> > 
> > I found:
> > https://html.spec.whatwg.org/#the-event-handler-processing-algorithm (step 5)
> > 
> > which says:
> > If return value is not null, then:
> >     1. Set E's canceled flag.
> >     ...
> > 
> > So if you return false, we cancel the event.
> 
> Oh, it is a CustomEvent, not a BeforeUnloadEvent. I get it now.

So:

"""
Otherwise
If return value is false, then set E's canceled flag.

If we've gotten to this "Otherwise" clause because E's type is beforeunload but E is not a BeforeUnloadEvent object, then return value will never be false, since in such cases return value will have been coerced into either null or a DOMString.
"""


More information about the webkit-unassigned mailing list