Change Event's returnValue so it doesn't expose a new primitive
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Apr 2018 01:01:18 +0000 (01:01 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Apr 2018 01:01:18 +0000 (01:01 +0000)
commita1da4f9bdabc9b2a52cc54c8c073b3ec1afd4e83
tree3620b0ad1ab7846278881412982d413357e2a34f
parent252d03777e7839a1f14656d86074b86979772425
Change Event's returnValue so it doesn't expose a new primitive
https://bugs.webkit.org/show_bug.cgi?id=184415

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Import test coverage from https://github.com/w3c/web-platform-tests/pull/10258.

* web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt:
* web-platform-tests/dom/events/AddEventListenerOptions-passive.html:
* web-platform-tests/dom/events/Event-constructors.html:
* web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch-expected.txt:
* web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch.html:
* web-platform-tests/dom/events/Event-defaultPrevented-expected.txt:
* web-platform-tests/dom/events/Event-defaultPrevented.html:
* web-platform-tests/dom/events/Event-dispatch-click.html:
* web-platform-tests/dom/events/Event-dispatch-detached-click.html:
* web-platform-tests/dom/events/Event-dispatch-other-document.html:
* web-platform-tests/dom/events/Event-initEvent.html:
* web-platform-tests/dom/events/Event-returnValue-expected.txt: Added.
* web-platform-tests/dom/events/Event-returnValue.html: Added.
* web-platform-tests/dom/events/EventListener-handleEvent.html:
* web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue-expected.txt:
* web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue.html:
* web-platform-tests/dom/events/w3c-import.log:
* web-platform-tests/dom/interfaces-expected.txt:
* web-platform-tests/interfaces/dom.idl:

Source/WebCore:

Update Event.returnValue setter to match the latest DOM specification after:
- https://github.com/whatwg/dom/pull/626

In particular, the returnValue setter is now a no-op if the new flag value
is true. If the input flag value is false, it only sets the 'canceled' flag
if the event is cancelable and the event’s in passive listener flag is unset.

Test: imported/w3c/web-platform-tests/dom/events/Event-returnValue.html

* dom/Event.cpp:
(WebCore::Event::setLegacyReturnValue):
(WebCore::Event::setCanceledFlagIfPossible):
(WebCore::Event::preventDefault):
* dom/Event.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/interfaces.any.worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive.html
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-constructors.html
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch.html
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-defaultPrevented-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-defaultPrevented.html
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-click.html
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-detached-click.html
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document.html
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-initEvent.html
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-returnValue-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-returnValue.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/dom/events/EventListener-handleEvent.html
LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue.html
LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log
LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt
LayoutTests/imported/w3c/web-platform-tests/interfaces/dom.idl
Source/WebCore/ChangeLog
Source/WebCore/dom/Event.h