Diff
Modified: trunk/LayoutTests/ChangeLog (189385 => 189386)
--- trunk/LayoutTests/ChangeLog 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/ChangeLog 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,3 +1,43 @@
+2015-09-04 Chris Dumez <[email protected]>
+
+ dispatchEvent() should throw an InvalidStateError if the event's initialized flag is not set
+ https://bugs.webkit.org/show_bug.cgi?id=148800
+ <rdar://problem/22565782>
+ <rdar://problem/22565485>
+
+ Reviewed by Geoffrey Garen.
+
+ * dom/html/level2/events/dispatchEvent02-expected.txt:
+ * dom/html/level2/events/dispatchEvent03-expected.txt:
+ * dom/html/level2/events/dispatchEvent04-expected.txt:
+ * dom/html/level2/events/dispatchEvent05-expected.txt:
+ * dom/html/level2/events/dispatchEvent06-expected.txt:
+ * dom/html/level2/events/dispatchEvent07-expected.txt:
+ * dom/xhtml/level2/events/dispatchEvent02-expected.txt:
+ * dom/xhtml/level2/events/dispatchEvent03-expected.txt:
+ * dom/xhtml/level2/events/dispatchEvent04-expected.txt:
+ * dom/xhtml/level2/events/dispatchEvent05-expected.txt:
+ * dom/xhtml/level2/events/dispatchEvent06-expected.txt:
+ * dom/xhtml/level2/events/dispatchEvent07-expected.txt:
+ Rebaseline, those tests are outdated and their expected results no
+ longer matches the behavior of the latest DOM specification.
+
+ * fast/dom/DOMException/EventException-expected.txt: Removed.
+ * fast/dom/DOMException/EventException.html: Removed.
+ * fast/dom/DOMException/resources/EventException.js: Removed.
+ Drop this test we no longer throw an EventException in this case.
+
+ * fast/dom/Window/dispatchEvent-expected.txt:
+ Rebaseline.
+
+ * fast/events/dispatch-event-being-dispatched-expected.txt:
+ * fast/events/dispatch-event-being-dispatched.html:
+ Fix the test to expect the new exception types.
+
+ * http/tests/w3c/dom/events/Event-type-empty-expected.txt:
+ * http/tests/w3c/dom/events/EventTarget-dispatchEvent-expected.txt:
+ Rebaseline.
+
2015-09-04 Ryosuke Niwa <[email protected]>
Triage some of the failures of the CSS WG's multicolumn tests imported in r189364.
Modified: trunk/LayoutTests/dom/html/level2/events/dispatchEvent02-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/html/level2/events/dispatchEvent02-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/html/level2/events/dispatchEvent02-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
-Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent02
-Status: Success
+Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent02
+Status: failure
+Detail: throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/html/level2/events/dispatchEvent03-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/html/level2/events/dispatchEvent03-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/html/level2/events/dispatchEvent03-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
-Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent03
-Status: Success
+Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent03
+Status: failure
+Detail: throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/html/level2/events/dispatchEvent04-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/html/level2/events/dispatchEvent04-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/html/level2/events/dispatchEvent04-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
-Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent04
-Status: Success
+Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent04
+Status: failure
+Detail: throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/html/level2/events/dispatchEvent05-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/html/level2/events/dispatchEvent05-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/html/level2/events/dispatchEvent05-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
-Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent05
-Status: Success
+Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent05
+Status: failure
+Detail: throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/html/level2/events/dispatchEvent06-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/html/level2/events/dispatchEvent06-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/html/level2/events/dispatchEvent06-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
-Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent06
-Status: Success
+Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent06
+Status: failure
+Detail: throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/html/level2/events/dispatchEvent07-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/html/level2/events/dispatchEvent07-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/html/level2/events/dispatchEvent07-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
-Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent07
-Status: Success
+Test: http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent07
+Status: failure
+Detail: throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent02-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent02-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent02-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
Test http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent02
-Status Success
+Status failure
+Message throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent03-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent03-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent03-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
Test http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent03
-Status Success
+Status failure
+Message throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent04-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent04-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent04-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
Test http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent04
-Status Success
+Status failure
+Message throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent05-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent05-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent05-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
Test http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent05
-Status Success
+Status failure
+Message throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent06-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent06-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent06-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
Test http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent06
-Status Success
+Status failure
+Message throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Modified: trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent07-expected.txt (189385 => 189386)
--- trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent07-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/dom/xhtml/level2/events/dispatchEvent07-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,2 +1,3 @@
Test http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent07
-Status Success
+Status failure
+Message throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
Deleted: trunk/LayoutTests/fast/dom/DOMException/EventException-expected.txt (189385 => 189386)
--- trunk/LayoutTests/fast/dom/DOMException/EventException-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/fast/dom/DOMException/EventException-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,16 +0,0 @@
-Tests the properties of the EventException object.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS e.toString() is "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0"
-PASS Object.prototype.toString.call(e) is "[object EventException]"
-PASS Object.prototype.toString.call(e.__proto__) is "[object EventExceptionPrototype]"
-PASS e.constructor.toString() is "[object EventExceptionConstructor]"
-PASS e.constructor is window.EventException
-PASS e.UNSPECIFIED_EVENT_TYPE_ERR is e.constructor.UNSPECIFIED_EVENT_TYPE_ERR
-PASS e.UNSPECIFIED_EVENT_TYPE_ERR is 0
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
Deleted: trunk/LayoutTests/fast/dom/DOMException/EventException.html (189385 => 189386)
--- trunk/LayoutTests/fast/dom/DOMException/EventException.html 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/fast/dom/DOMException/EventException.html 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src=""
-</head>
-<body>
-<script src=""
-<script src=""
-</body>
-</html>
Deleted: trunk/LayoutTests/fast/dom/DOMException/resources/EventException.js (189385 => 189386)
--- trunk/LayoutTests/fast/dom/DOMException/resources/EventException.js 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/fast/dom/DOMException/resources/EventException.js 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,17 +0,0 @@
-description("Tests the properties of the EventException object.")
-
-var e;
-try {
- document.dispatchEvent(null);
- // raises a UNSPECIFIED_EVENT_TYPE_ERR
-} catch (err) {
- e = err;
-}
-
-shouldBeEqualToString("e.toString()", "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0");
-shouldBeEqualToString("Object.prototype.toString.call(e)", "[object EventException]");
-shouldBeEqualToString("Object.prototype.toString.call(e.__proto__)", "[object EventExceptionPrototype]");
-shouldBeEqualToString("e.constructor.toString()", "[object EventExceptionConstructor]");
-shouldBe("e.constructor", "window.EventException");
-shouldBe("e.UNSPECIFIED_EVENT_TYPE_ERR", "e.constructor.UNSPECIFIED_EVENT_TYPE_ERR");
-shouldBe("e.UNSPECIFIED_EVENT_TYPE_ERR", "0");
Modified: trunk/LayoutTests/fast/dom/Window/dispatchEvent-expected.txt (189385 => 189386)
--- trunk/LayoutTests/fast/dom/Window/dispatchEvent-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/fast/dom/Window/dispatchEvent-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS window.dispatchEvent(event) threw exception Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0.
-PASS window.dispatchEvent(event) threw exception Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0.
+PASS window.dispatchEvent(event) threw exception TypeError: Type error.
+PASS window.dispatchEvent(event) threw exception Error: InvalidStateError: DOM Exception 11.
PASS myEventDispatched is true
PASS target is window
PASS currentTarget is window
Modified: trunk/LayoutTests/fast/events/dispatch-event-being-dispatched-expected.txt (189385 => 189386)
--- trunk/LayoutTests/fast/events/dispatch-event-being-dispatched-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/fast/events/dispatch-event-being-dispatched-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,10 +1,13 @@
-Tests that dispatchEvent raises DISPATCH_REQUEST_ERR if the event being dispatched is already being dispatched.
+Tests that dispatchEvent raises INVALID_STATE_ERR if the event being dispatched is already being dispatched.
-PASS should have got DISPATCH_REQUEST_ERR EventException
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.dispatchEvent(event) threw exception Error: InvalidStateError: DOM Exception 11.
PASS redispatchCustom.wasInvoked is true
-PASS should have got DISPATCH_REQUEST_ERR EventException
+PASS window.dispatchEvent(event) threw exception Error: InvalidStateError: DOM Exception 11.
PASS checkCustom.wasInvoked is true
-PASS should have got DISPATCH_REQUEST_ERR EventException
+PASS document.dispatchEvent(event) threw exception Error: InvalidStateError: DOM Exception 11.
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/events/dispatch-event-being-dispatched.html (189385 => 189386)
--- trunk/LayoutTests/fast/events/dispatch-event-being-dispatched.html 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/fast/events/dispatch-event-being-dispatched.html 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,43 +1,24 @@
<!DOCTYPE html>
<html>
-<head>
-<script src=""
-</head>
<body>
-<p class="description">
-Tests that dispatchEvent raises DISPATCH_REQUEST_ERR if the event
-being dispatched is already being dispatched.
-</p>
-<pre id="console">
-</pre>
+<script src=""
+<div class="testDiv"></div>
<script>
-if (window.testRunner)
- testRunner.dumpAsText();
+description("Tests that dispatchEvent raises INVALID_STATE_ERR if the event being dispatched is already being dispatched.");
jsTestIsAsync = true;
-function shouldBeDispatchRequestErr(exception) {
- var ok = EventException.prototype.isPrototypeOf(exception) && exception.code == EventException.DISPATCH_REQUEST_ERR;
- (ok ? testPassed : testFailed)("should have got DISPATCH_REQUEST_ERR EventException");
-}
+// try redispatching an event in the process of being dispatched with dispatchEvent
-// try redispatching an event in the process of being dispatched with
-// dispatchEvent
-
function redispatchCustom(event) {
- try {
- window.dispatchEvent(event);
- testFailed('dispatchEvent of an event being dispatched should throw an exception');
- } catch (ex) {
- shouldBeDispatchRequestErr(ex);
- }
+ shouldThrow("window.dispatchEvent(event)", "'Error: InvalidStateError: DOM Exception 11'");
redispatchCustom.wasInvoked = true;
}
var customEvent = document.createEvent('CustomEvent');
customEvent.initCustomEvent('foo', true, true, null);
-var p = document.querySelector('.description');
+var p = document.querySelector('.testDiv');
p.addEventListener('foo', redispatchCustom);
p.dispatchEvent(customEvent);
shouldBeTrue('redispatchCustom.wasInvoked');
@@ -62,15 +43,9 @@
return;
}
- try {
- redispatchLoad.dispatching = true;
- document.dispatchEvent(event);
- testFailed('dispatchEvent of an event being dispatched should throw an exception');
- } catch (ex) {
- shouldBeDispatchRequestErr(ex);
- } finally {
- delete redispatchLoad.dispatching;
- }
+ redispatchLoad.dispatching = true;
+ shouldThrow("document.dispatchEvent(event)", "'Error: InvalidStateError: DOM Exception 11'");
+ delete redispatchLoad.dispatching;
finishJSTest();
}
Modified: trunk/LayoutTests/http/tests/w3c/dom/events/Event-type-empty-expected.txt (189385 => 189386)
--- trunk/LayoutTests/http/tests/w3c/dom/events/Event-type-empty-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/http/tests/w3c/dom/events/Event-type-empty-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,4 +1,4 @@
-FAIL initEvent UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0
-FAIL Constructor UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0
+PASS initEvent
+PASS Constructor
Modified: trunk/LayoutTests/http/tests/w3c/dom/events/EventTarget-dispatchEvent-expected.txt (189385 => 189386)
--- trunk/LayoutTests/http/tests/w3c/dom/events/EventTarget-dispatchEvent-expected.txt 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/LayoutTests/http/tests/w3c/dom/events/EventTarget-dispatchEvent-expected.txt 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,21 +1,19 @@
CONSOLE MESSAGE: line 60: Error
-FAIL Calling dispatchEvent(null). assert_throws: function "function () { document.dispatchEvent(null) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" ("UNSPECIFIED_EVENT_TYPE_ERR") expected object "TypeError" ("TypeError")
-FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (CustomEvent). assert_throws: function "function () { document.dispatchEvent(e) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
-FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (Event). assert_throws: function "function () { document.dispatchEvent(e) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
-FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (Events). assert_throws: function "function () { document.dispatchEvent(e) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
-FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (HTMLEvents). assert_throws: function "function () { document.dispatchEvent(e) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
-FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (KeyboardEvent). assert_throws: function "function () { document.dispatchEvent(e) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
+PASS Calling dispatchEvent(null).
+PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (CustomEvent).
+PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (Event).
+PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (Events).
+PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (HTMLEvents).
+PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (KeyboardEvent).
FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (KeyEvents). NotSupportedError: DOM Exception 9
-FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (MessageEvent). assert_throws: function "function () { document.dispatchEvent(e) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
-FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (MouseEvent). assert_throws: function "function () { document.dispatchEvent(e) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
-FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (MouseEvents). assert_throws: function "function () { document.dispatchEvent(e) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
+PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (MessageEvent).
+PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (MouseEvent).
+PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (MouseEvents).
FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (TouchEvent). NotSupportedError: DOM Exception 9
-FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (UIEvent). assert_throws: function "function () { document.dispatchEvent(e) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
-FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (UIEvents). assert_throws: function "function () { document.dispatchEvent(e) }" threw object "Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0" that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
-FAIL If the event's dispatch flag is set, an InvalidStateError must be thrown. assert_throws: function "function () {
- target.dispatchEvent(e)
- }" threw object "Error: DISPATCH_REQUEST_ERR: DOM Events Exception 1" that is not a DOMException InvalidStateError: property "code" is equal to 1, expected 11
+PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (UIEvent).
+PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (UIEvents).
+PASS If the event's dispatch flag is set, an InvalidStateError must be thrown.
PASS Exceptions from event listeners must not be propagated.
FAIL Event listeners added during dispatch should be called assert_array_equals: lengths differ, expected 2 got 0
PASS Event listeners should be called in order of addition
Modified: trunk/Source/WebCore/ChangeLog (189385 => 189386)
--- trunk/Source/WebCore/ChangeLog 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/Source/WebCore/ChangeLog 2015-09-04 21:13:06 UTC (rev 189386)
@@ -1,3 +1,33 @@
+2015-09-04 Chris Dumez <[email protected]>
+
+ dispatchEvent() should throw an InvalidStateError if the event's initialized flag is not set
+ https://bugs.webkit.org/show_bug.cgi?id=148800
+ <rdar://problem/22565782>
+ <rdar://problem/22565485>
+
+ Reviewed by Geoffrey Garen.
+
+ dispatchEvent() should throw an InvalidStateError if the event's
+ initialized flag is not set or its dispatch flag is set, and should
+ allow dispatching events with an empty type as long as it is
+ initialized:
+ https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent (step 1)
+
+ Previously, WebKit relied on the event type being empty to throw a
+ UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0. However, this
+ exception type is outdated and initializing Event.type to an empty
+ string is legal.
+
+ No new tests, already covered by existing tests that were rebaselined.
+
+ * dom/Event.cpp:
+ (WebCore::Event::Event):
+ (WebCore::Event::initEvent):
+ * dom/Event.h:
+ (WebCore::Event::isInitialized):
+ * dom/EventTarget.cpp:
+ (WebCore::EventTarget::dispatchEvent):
+
2015-09-04 Beth Dakin <[email protected]>
Speculative build fix.
Modified: trunk/Source/WebCore/dom/Event.cpp (189385 => 189386)
--- trunk/Source/WebCore/dom/Event.cpp 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/Source/WebCore/dom/Event.cpp 2015-09-04 21:13:06 UTC (rev 189386)
@@ -56,7 +56,8 @@
}
Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg)
- : m_type(eventType)
+ : m_isInitialized(true)
+ , m_type(eventType)
, m_canBubble(canBubbleArg)
, m_cancelable(cancelableArg)
, m_propagationStopped(false)
@@ -71,7 +72,8 @@
}
Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg, double timestamp)
- : m_type(eventType)
+ : m_isInitialized(true)
+ , m_type(eventType)
, m_canBubble(canBubbleArg)
, m_cancelable(cancelableArg)
, m_propagationStopped(false)
@@ -86,7 +88,8 @@
}
Event::Event(const AtomicString& eventType, const EventInit& initializer)
- : m_type(eventType)
+ : m_isInitialized(true)
+ , m_type(eventType)
, m_canBubble(initializer.bubbles)
, m_cancelable(initializer.cancelable)
, m_propagationStopped(false)
@@ -109,6 +112,7 @@
if (dispatched())
return;
+ m_isInitialized = true;
m_propagationStopped = false;
m_immediatePropagationStopped = false;
m_defaultPrevented = false;
Modified: trunk/Source/WebCore/dom/Event.h (189385 => 189386)
--- trunk/Source/WebCore/dom/Event.h 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/Source/WebCore/dom/Event.h 2015-09-04 21:13:06 UTC (rev 189386)
@@ -100,6 +100,7 @@
virtual ~Event();
void initEvent(const AtomicString& type, bool canBubble, bool cancelable);
+ bool isInitialized() const { return m_isInitialized; }
const AtomicString& type() const { return m_type; }
void setType(const AtomicString& type) { m_type = type; }
@@ -188,6 +189,7 @@
bool dispatched() const { return m_target; }
private:
+ bool m_isInitialized { false };
AtomicString m_type;
bool m_canBubble;
bool m_cancelable;
Modified: trunk/Source/WebCore/dom/EventTarget.cpp (189385 => 189386)
--- trunk/Source/WebCore/dom/EventTarget.cpp 2015-09-04 21:07:37 UTC (rev 189385)
+++ trunk/Source/WebCore/dom/EventTarget.cpp 2015-09-04 21:13:06 UTC (rev 189386)
@@ -138,13 +138,13 @@
bool EventTarget::dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec)
{
- if (!event || event->type().isEmpty()) {
- ec = EventException::UNSPECIFIED_EVENT_TYPE_ERR;
+ if (!event) {
+ ec = TypeError;
return false;
}
- if (event->isBeingDispatched()) {
- ec = EventException::DISPATCH_REQUEST_ERR;
+ if (!event->isInitialized() || event->isBeingDispatched()) {
+ ec = INVALID_STATE_ERR;
return false;
}