The return value of an OnBeforeUnloadEventHandler should always be coerced into a...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Sep 2018 02:03:51 +0000 (02:03 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Sep 2018 02:03:51 +0000 (02:03 +0000)
commite7de75fea24ee95536515931281674cda4a155df
treed810f6d8659d6643f8e875892cc3057abfd84164
parentc5a29f555e42254fdd81775d2f94dd95ddb754cc
The return value of an OnBeforeUnloadEventHandler should always be coerced into a DOMString
https://bugs.webkit.org/show_bug.cgi?id=190090

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline WPT test now that one more check is passing.

* web-platform-tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-expected.txt:

Source/WebCore:

The return value of an OnBeforeUnloadEventHandler should always be coerced into a DOMString:
- https://html.spec.whatwg.org/#onbeforeunloadeventhandler
- https://html.spec.whatwg.org/#the-event-handler-processing-algorithm (Step 5)

In particular, this means that returning false in an OnBeforeUnloadEventHandler should NOT
cancel the event when the event is a CustomEvent (and not a BeforeUnloadEvent). This is
because the return value cannot be false at:
- https://html.spec.whatwg.org/#the-event-handler-processing-algorithm (Step 5. Otherwise case).

No new tests, rebaselined existing test.

* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):

LayoutTests:

Update test that was returning a value in a beforeunload event listener instead of using an
event handler. The test needs to use an event handler (window.onbeforeunload) as an event
listener does not have a return value. I have verified that our behavior is consistent with
Chrome and Firefox on this test, both with an event listener and an event handler.

* fast/loader/form-submission-after-beforeunload-cancel.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236633 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/loader/form-submission-after-beforeunload-cancel.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSEventListener.cpp