diff options
author | Patrick Ngai <clpngai@gmail.com> | 2019-02-24 23:58:51 +0800 |
---|---|---|
committer | Patrick Ngai <clpngai@gmail.com> | 2019-02-28 21:03:03 +0800 |
commit | fcadff7bad42c3562a761e2ec6300a33c0fa7666 (patch) | |
tree | 7ab4e57ca5f35a828814129f41b954557a1f4ef3 | |
parent | 427003210b3e16a82f958e35ff4212f26ffa35ab (diff) | |
download | servo-fcadff7bad42c3562a761e2ec6300a33c0fa7666.tar.gz servo-fcadff7bad42c3562a761e2ec6300a33c0fa7666.zip |
Implement historical returnValue attribute for Event interface
6 files changed, 13 insertions, 42 deletions
diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index fc18036bfc7..914cf279278 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -297,6 +297,18 @@ impl EventMethods for Event { self.cancelable.get() } + // https://dom.spec.whatwg.org/#dom-event-returnvalue + fn ReturnValue(&self) -> bool { + self.canceled.get() == EventDefault::Allowed + } + + // https://dom.spec.whatwg.org/#dom-event-returnvalue + fn SetReturnValue(&self, val: bool) { + if !val { + self.PreventDefault(); + } + } + // https://dom.spec.whatwg.org/#dom-event-timestamp fn TimeStamp(&self) -> u64 { self.timestamp diff --git a/components/script/dom/webidls/Event.webidl b/components/script/dom/webidls/Event.webidl index 9aea7e38e75..e579bab8d89 100644 --- a/components/script/dom/webidls/Event.webidl +++ b/components/script/dom/webidls/Event.webidl @@ -26,6 +26,7 @@ interface Event { readonly attribute boolean bubbles; [Pure] readonly attribute boolean cancelable; + attribute boolean returnValue; // historical void preventDefault(); [Pure] readonly attribute boolean defaultPrevented; diff --git a/tests/wpt/metadata/dom/events/Event-defaultPrevented.html.ini b/tests/wpt/metadata/dom/events/Event-defaultPrevented.html.ini deleted file mode 100644 index 2cab7efe8da..00000000000 --- a/tests/wpt/metadata/dom/events/Event-defaultPrevented.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[Event-defaultPrevented.html] - [returnValue should change defaultPrevented if cancelable is true.] - expected: FAIL - diff --git a/tests/wpt/metadata/dom/events/Event-returnValue.html.ini b/tests/wpt/metadata/dom/events/Event-returnValue.html.ini deleted file mode 100644 index e9c34f6438f..00000000000 --- a/tests/wpt/metadata/dom/events/Event-returnValue.html.ini +++ /dev/null @@ -1,19 +0,0 @@ -[Event-returnValue.html] - [When an event is created, returnValue should be initialized to true.] - expected: FAIL - - [preventDefault() should not change returnValue if cancelable is false.] - expected: FAIL - - [returnValue=false should have no effect if cancelable is false.] - expected: FAIL - - [preventDefault() should change returnValue if cancelable is true.] - expected: FAIL - - [initEvent should unset returnValue.] - expected: FAIL - - [returnValue=true should have no effect once the canceled flag was set.] - expected: FAIL - diff --git a/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent-returnvalue.html.ini b/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent-returnvalue.html.ini deleted file mode 100644 index 5fe7e8ffe60..00000000000 --- a/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent-returnvalue.html.ini +++ /dev/null @@ -1,7 +0,0 @@ -[EventTarget-dispatchEvent-returnvalue.html] - [Return value of EventTarget.dispatchEvent() affected by preventDefault().] - expected: FAIL - - [Return value of EventTarget.dispatchEvent() affected by returnValue.] - expected: FAIL - diff --git a/tests/wpt/metadata/dom/interfaces.html.ini b/tests/wpt/metadata/dom/interfaces.html.ini index b94d68781c3..b7c05270022 100644 --- a/tests/wpt/metadata/dom/interfaces.html.ini +++ b/tests/wpt/metadata/dom/interfaces.html.ini @@ -872,9 +872,6 @@ [Event interface: operation composedPath()] expected: FAIL - [Event interface: attribute returnValue] - expected: FAIL - [Event interface: attribute composed] expected: FAIL @@ -887,9 +884,6 @@ [Event interface: document.createEvent("Event") must inherit property "composedPath()" with the proper type] expected: FAIL - [Event interface: document.createEvent("Event") must inherit property "returnValue" with the proper type] - expected: FAIL - [Event interface: document.createEvent("Event") must inherit property "composed" with the proper type] expected: FAIL @@ -899,9 +893,6 @@ [Event interface: new Event("foo") must inherit property "composedPath()" with the proper type] expected: FAIL - [Event interface: new Event("foo") must inherit property "returnValue" with the proper type] - expected: FAIL - [Event interface: new Event("foo") must inherit property "composed" with the proper type] expected: FAIL @@ -914,9 +905,6 @@ [Event interface: new CustomEvent("foo") must inherit property "composedPath()" with the proper type] expected: FAIL - [Event interface: new CustomEvent("foo") must inherit property "returnValue" with the proper type] - expected: FAIL - [Event interface: new CustomEvent("foo") must inherit property "composed" with the proper type] expected: FAIL |