Diff
Modified: trunk/LayoutTests/ChangeLog (204287 => 204288)
--- trunk/LayoutTests/ChangeLog 2016-08-09 18:06:30 UTC (rev 204287)
+++ trunk/LayoutTests/ChangeLog 2016-08-09 18:52:11 UTC (rev 204288)
@@ -1,3 +1,18 @@
+2016-08-09 Chris Dumez <cdu...@apple.com>
+
+ It should be possible to re-initialize a CustomEvent after it's been dispatched
+ https://bugs.webkit.org/show_bug.cgi?id=160664
+
+ Reviewed by Darin Adler.
+
+ * fast/events/initCustomEvent-after-dispatch-expected.txt: Copied from LayoutTests/fast/events/initEvent-after-dispatch-expected.txt.
+ * fast/events/initCustomEvent-after-dispatch.html: Copied from LayoutTests/fast/events/initEvent-after-dispatch.html.
+ Add layout test coverage.
+
+ * fast/events/initEvent-after-dispatch-expected.txt:
+ * fast/events/initEvent-after-dispatch.html:
+ Fix related layout test.
+
2016-08-08 Ryan Haddad <ryanhad...@apple.com>
Update test expectations for rdar://problem/27711048.
Copied: trunk/LayoutTests/fast/events/initCustomEvent-after-dispatch-expected.txt (from rev 204287, trunk/LayoutTests/fast/events/initEvent-after-dispatch-expected.txt) (0 => 204288)
--- trunk/LayoutTests/fast/events/initCustomEvent-after-dispatch-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/initCustomEvent-after-dispatch-expected.txt 2016-08-09 18:52:11 UTC (rev 204288)
@@ -0,0 +1,55 @@
+Tests calling initCustomEvent() on an custom event while it is being dispatched and after.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testEvent.__proto__ is CustomEvent.prototype
+PASS testEvent.initCustomEvent("foo", true, false, "detail") did not throw exception.
+PASS testEvent.type is "foo"
+PASS testEvent.bubbles is true
+PASS testEvent.cancelable is false
+PASS testEvent.target is null
+PASS testEvent.currentTarget is null
+PASS testEvent.eventPhase is Event.NONE
+PASS testEvent.detail is "detail"
+
+* In event handler
+PASS event.type is "foo"
+PASS event.bubbles is true
+PASS event.cancelable is false
+PASS event.target is document.body
+PASS event.currentTarget is document.body
+PASS event.eventPhase is Event.AT_TARGET
+PASS event.detail is "detail"
+
+PASS event.initCustomEvent("bar", false, true, "detail2") did not throw exception.
+PASS event.type is "foo"
+PASS event.bubbles is true
+PASS event.cancelable is false
+PASS event.target is document.body
+PASS event.currentTarget is document.body
+PASS event.eventPhase is Event.AT_TARGET
+PASS event.detail is "detail"
+PASS document.body.dispatchEvent(testEvent) did not throw exception.
+
+* After event has been dispatched
+PASS testEvent.type is "foo"
+PASS testEvent.bubbles is true
+PASS testEvent.cancelable is false
+PASS testEvent.target is document.body
+PASS testEvent.currentTarget is null
+PASS testEvent.eventPhase is Event.NONE
+PASS testEvent.detail is "detail"
+
+PASS testEvent.initCustomEvent("bar", false, true, "detail2") did not throw exception.
+PASS testEvent.type is "bar"
+PASS testEvent.bubbles is false
+PASS testEvent.cancelable is true
+PASS testEvent.target is null
+PASS testEvent.currentTarget is null
+PASS testEvent.eventPhase is Event.NONE
+PASS testEvent.detail is "detail2"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Copied: trunk/LayoutTests/fast/events/initCustomEvent-after-dispatch.html (from rev 204287, trunk/LayoutTests/fast/events/initEvent-after-dispatch.html) (0 => 204288)
--- trunk/LayoutTests/fast/events/initCustomEvent-after-dispatch.html (rev 0)
+++ trunk/LayoutTests/fast/events/initCustomEvent-after-dispatch.html 2016-08-09 18:52:11 UTC (rev 204288)
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests calling initCustomEvent() on an custom event while it is being dispatched and after.");
+
+function eventHandler(ev) {
+ event = ev;
+ debug("");
+ debug("* In event handler");
+ shouldBeEqualToString("event.type", "foo");
+ shouldBeTrue("event.bubbles");
+ shouldBeFalse("event.cancelable");
+ shouldBe("event.target", "document.body");
+ shouldBe("event.currentTarget", "document.body");
+ shouldBe("event.eventPhase", "Event.AT_TARGET");
+ shouldBeEqualToString("event.detail", "detail");
+
+ debug("");
+ // It should not be possible to re-initialize an event being dispatched.
+ shouldNotThrow('event.initCustomEvent("bar", false, true, "detail2")');
+ shouldBeEqualToString("event.type", "foo");
+ shouldBeTrue("event.bubbles");
+ shouldBeFalse("event.cancelable");
+ shouldBe("event.target", "document.body");
+ shouldBe("event.currentTarget", "document.body");
+ shouldBe("event.eventPhase", "Event.AT_TARGET");
+ shouldBeEqualToString("event.detail", "detail");
+}
+
+var testEvent = document.createEvent("customevent");
+shouldBe("testEvent.__proto__", "CustomEvent.prototype");
+shouldNotThrow('testEvent.initCustomEvent("foo", true, false, "detail")');
+shouldBeEqualToString("testEvent.type", "foo");
+shouldBeTrue("testEvent.bubbles");
+shouldBeFalse("testEvent.cancelable");
+shouldBeNull("testEvent.target");
+shouldBeNull("testEvent.currentTarget");
+shouldBe("testEvent.eventPhase", "Event.NONE");
+shouldBeEqualToString("testEvent.detail", "detail");
+
+document.body.addEventListener("foo", eventHandler);
+shouldNotThrow('document.body.dispatchEvent(testEvent)');
+
+debug("");
+debug("* After event has been dispatched");
+shouldBeEqualToString("testEvent.type", "foo");
+shouldBeTrue("testEvent.bubbles");
+shouldBeFalse("testEvent.cancelable");
+shouldBe("testEvent.target", "document.body");
+shouldBeNull("testEvent.currentTarget");
+shouldBe("testEvent.eventPhase", "Event.NONE");
+shouldBeEqualToString("testEvent.detail", "detail");
+
+// It should now be possible to re-initialize the event.
+debug("");
+shouldNotThrow('testEvent.initCustomEvent("bar", false, true, "detail2")');
+shouldBeEqualToString("testEvent.type", "bar");
+shouldBeFalse("testEvent.bubbles");
+shouldBeTrue("testEvent.cancelable");
+shouldBeNull("testEvent.target");
+shouldBeNull("testEvent.currentTarget");
+shouldBe("testEvent.eventPhase", "Event.NONE");
+shouldBeEqualToString("testEvent.detail", "detail2");
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/fast/events/initEvent-after-dispatch-expected.txt (204287 => 204288)
--- trunk/LayoutTests/fast/events/initEvent-after-dispatch-expected.txt 2016-08-09 18:06:30 UTC (rev 204287)
+++ trunk/LayoutTests/fast/events/initEvent-after-dispatch-expected.txt 2016-08-09 18:52:11 UTC (rev 204288)
@@ -19,7 +19,7 @@
PASS event.currentTarget is document.body
PASS event.eventPhase is Event.AT_TARGET
-PASS testEvent.initEvent("bar", false, true) did not throw exception.
+PASS event.initEvent("bar", false, true) did not throw exception.
PASS event.type is "foo"
PASS event.bubbles is true
PASS event.cancelable is false
@@ -37,12 +37,12 @@
PASS testEvent.eventPhase is Event.NONE
PASS testEvent.initEvent("bar", false, true) did not throw exception.
-PASS event.type is "bar"
-PASS event.bubbles is false
-PASS event.cancelable is true
-PASS event.target is null
-PASS event.currentTarget is null
-PASS event.eventPhase is Event.NONE
+PASS testEvent.type is "bar"
+PASS testEvent.bubbles is false
+PASS testEvent.cancelable is true
+PASS testEvent.target is null
+PASS testEvent.currentTarget is null
+PASS testEvent.eventPhase is Event.NONE
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/events/initEvent-after-dispatch.html (204287 => 204288)
--- trunk/LayoutTests/fast/events/initEvent-after-dispatch.html 2016-08-09 18:06:30 UTC (rev 204287)
+++ trunk/LayoutTests/fast/events/initEvent-after-dispatch.html 2016-08-09 18:52:11 UTC (rev 204288)
@@ -18,7 +18,7 @@
debug("");
// It should not be possible to re-initialize an event being dispatched.
- shouldNotThrow('testEvent.initEvent("bar", false, true)');
+ shouldNotThrow('event.initEvent("bar", false, true)');
shouldBeEqualToString("event.type", "foo");
shouldBeTrue("event.bubbles");
shouldBeFalse("event.cancelable");
@@ -51,12 +51,12 @@
// It should now be possible to re-initialize the event.
debug("");
shouldNotThrow('testEvent.initEvent("bar", false, true)');
-shouldBeEqualToString("event.type", "bar");
-shouldBeFalse("event.bubbles");
-shouldBeTrue("event.cancelable");
-shouldBeNull("event.target");
-shouldBeNull("event.currentTarget");
-shouldBe("event.eventPhase", "Event.NONE");
+shouldBeEqualToString("testEvent.type", "bar");
+shouldBeFalse("testEvent.bubbles");
+shouldBeTrue("testEvent.cancelable");
+shouldBeNull("testEvent.target");
+shouldBeNull("testEvent.currentTarget");
+shouldBe("testEvent.eventPhase", "Event.NONE");
</script>
<script src=""
</body>
Modified: trunk/Source/WebCore/ChangeLog (204287 => 204288)
--- trunk/Source/WebCore/ChangeLog 2016-08-09 18:06:30 UTC (rev 204287)
+++ trunk/Source/WebCore/ChangeLog 2016-08-09 18:52:11 UTC (rev 204288)
@@ -1,3 +1,18 @@
+2016-08-09 Chris Dumez <cdu...@apple.com>
+
+ It should be possible to re-initialize a CustomEvent after it's been dispatched
+ https://bugs.webkit.org/show_bug.cgi?id=160664
+
+ Reviewed by Darin Adler.
+
+ It should be possible to re-initialize a CustomEvent after it's been dispatched:
+ - https://dom.spec.whatwg.org/#dom-customevent-initcustomevent
+
+ Test: fast/events/initCustomEvent-after-dispatch.html
+
+ * dom/CustomEvent.cpp:
+ (WebCore::CustomEvent::initCustomEvent):
+
2016-08-09 Anders Carlsson <ander...@apple.com>
Get rid of PluginStrategy
Modified: trunk/Source/WebCore/dom/CustomEvent.cpp (204287 => 204288)
--- trunk/Source/WebCore/dom/CustomEvent.cpp 2016-08-09 18:06:30 UTC (rev 204287)
+++ trunk/Source/WebCore/dom/CustomEvent.cpp 2016-08-09 18:52:11 UTC (rev 204288)
@@ -47,7 +47,7 @@
void CustomEvent::initCustomEvent(JSC::ExecState& state, const AtomicString& type, bool canBubble, bool cancelable, JSC::JSValue detail)
{
- if (dispatched())
+ if (isBeingDispatched())
return;
initEvent(type, canBubble, cancelable);