Skip to content

Commit

Permalink
Merge r213517 - Align initEvent / initCustomEvent / initMessageEvent …
Browse files Browse the repository at this point in the history
…with the latest specification

https://bugs.webkit.org/show_bug.cgi?id=169176

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Re-sync web-platform tests from upstream after:
- web-platform-tests/wpt#5043
- web-platform-tests/wpt#5044

* web-platform-tests/dom/events/CustomEvent-expected.txt:
* web-platform-tests/dom/events/CustomEvent.html:
* web-platform-tests/dom/events/Event-initEvent-expected.txt:
* web-platform-tests/dom/events/Event-initEvent.html:
* web-platform-tests/dom/interfaces-expected.txt:
* web-platform-tests/dom/interfaces.html:
* web-platform-tests/html/dom/interfaces-expected.txt:
* web-platform-tests/html/dom/interfaces.html:
* web-platform-tests/html/dom/resources/interfaces.idl: Copied from LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces.html.
* web-platform-tests/html/dom/resources/untested-interfaces.idl: Added.
* web-platform-tests/html/webappapis/scripting/events/messageevent-constructor-expected.txt: Removed.
* web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.html: Removed.
* web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https.html:

Source/WebCore:

Align initEvent / initCustomEvent / initMessageEvent with the latest specification
after:
- whatwg/dom#417
- whatwg/html#2410

In particular, the following changes were made:
- initEvent: The length property now properly returns 1 instead of 3 as only the
  first parameter is mandatory. We were already behaving correcting the the length
  property value was wrong because we forgot to drop a hack from the bindings
  generator.
- initCustomEvent: Make all parameters except the first optional. Previously, all
  parameters were mandatory so this is safe.
- initMessageEvent: Drop the custom code and mark the first parameter as mandatory.
  A side effect of dropping the custom code is that null is no longer considered as
  valid input for the last parameter. The parameter is of type sequence<> and the
  new behavior is consistent with the specification and Firefox. If it turns out to
  break existing content, I'll make the parameter nullable in a follow-up.

No new tests, updated existing tests.

* bindings/js/JSMessageEventCustom.cpp:
* bindings/scripts/CodeGeneratorJS.pm:
(GeneratePropertiesHashTable):
* dom/CustomEvent.idl:
* dom/MessageEvent.idl:

LayoutTests:

Updated existing tests to reflect behavior change.

* fast/events/init-events-expected.txt:
* fast/events/script-tests/init-events.js:
* fast/eventsource/eventsource-attribute-listeners.html:

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.16@213825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgc@webkit.org committed Mar 13, 2017
1 parent 7b05927 commit 7f1d18d
Show file tree
Hide file tree
Showing 24 changed files with 3,415 additions and 3,364 deletions.
13 changes: 13 additions & 0 deletions LayoutTests/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2017-03-07 Chris Dumez <cdumez@apple.com>

Align initEvent / initCustomEvent / initMessageEvent with the latest specification
https://bugs.webkit.org/show_bug.cgi?id=169176

Reviewed by Alex Christensen.

Updated existing tests to reflect behavior change.

* fast/events/init-events-expected.txt:
* fast/events/script-tests/init-events.js:
* fast/eventsource/eventsource-attribute-listeners.html:

2017-03-06 Brent Fulgham <bfulgham@apple.com>

Validate DOM after potentially destructive actions during parser insert operations
Expand Down
29 changes: 15 additions & 14 deletions LayoutTests/fast/events/init-events-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,21 @@ PASS testInitEvent('Keyboard', '"a", false, true, window, "b", 1001, false, fals
PASS testInitEvent('Keyboard', '"a", false, true, window, "b", 1001, false, false, false, false, false').pageX is 0
PASS testInitEvent('Keyboard', '"a", false, true, window, "b", 1001, false, false, false, false, false').pageY is 0
PASS testInitEvent('Keyboard', '"a", false, true, window, "b", 1001, false, false, false, false, false').which is 0
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, null').type is 'a'
PASS testInitEvent('Message', 'null, false, false, "b", "c", "d", window, null').type is 'null'
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, null').bubbles is false
PASS testInitEvent('Message', '"a", true, false, "b", "c", "d", window, null').bubbles is true
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, null').cancelable is false
PASS testInitEvent('Message', '"a", false, true, "b", "c", "d", window, null').cancelable is true
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, null').data is 'b'
PASS testInitEvent('Message', '"a", false, false, null, "c", "d", window, null').data is null
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, null').origin is 'c'
PASS testInitEvent('Message', '"a", false, false, "b", null, "d", window, null').origin is 'null'
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, null').lastEventId is 'd'
PASS testInitEvent('Message', '"a", false, false, "b", "c", null, window, null').lastEventId is 'null'
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, null').source is window
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", null, null').source is null
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, []').type is 'a'
PASS testInitEvent('Message', 'null, false, false, "b", "c", "d", window, []').type is 'null'
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, []').bubbles is false
PASS testInitEvent('Message', '"a", true, false, "b", "c", "d", window, []').bubbles is true
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, []').cancelable is false
PASS testInitEvent('Message', '"a", false, true, "b", "c", "d", window, []').cancelable is true
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, []').data is 'b'
PASS testInitEvent('Message', '"a", false, false, null, "c", "d", window, []').data is null
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, []').origin is 'c'
PASS testInitEvent('Message', '"a", false, false, "b", null, "d", window, []').origin is 'null'
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, []').lastEventId is 'd'
PASS testInitEvent('Message', '"a", false, false, "b", "c", null, window, []').lastEventId is 'null'
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", window, []').source is window
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", null, []').source is null
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", null, []').ports is []
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", null, channelArray').ports[0] is channel.port1
PASS testInitEvent('Message', '"a", false, false, "b", "c", "d", null, channelArray').ports[1] is channel.port2
PASS testInitEvent('Mouse', '"a", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').type is 'a'
Expand Down
29 changes: 15 additions & 14 deletions LayoutTests/fast/events/script-tests/init-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,21 @@ shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, fa
shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').pageY", "0");
shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').which", "0");

shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').type", "'a'");
shouldBe("testInitEvent('Message', 'null, false, false, \"b\", \"c\", \"d\", window, null').type", "'null'");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').bubbles", "false");
shouldBe("testInitEvent('Message', '\"a\", true, false, \"b\", \"c\", \"d\", window, null').bubbles", "true");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').cancelable", "false");
shouldBe("testInitEvent('Message', '\"a\", false, true, \"b\", \"c\", \"d\", window, null').cancelable", "true");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').data", "'b'");
shouldBe("testInitEvent('Message', '\"a\", false, false, null, \"c\", \"d\", window, null').data", "null");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').origin", "'c'");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", null, \"d\", window, null').origin", "'null'");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').lastEventId", "'d'");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", null, window, null').lastEventId", "'null'");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').source", "window");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", null, null').source", "null");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, []').type", "'a'");
shouldBe("testInitEvent('Message', 'null, false, false, \"b\", \"c\", \"d\", window, []').type", "'null'");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, []').bubbles", "false");
shouldBe("testInitEvent('Message', '\"a\", true, false, \"b\", \"c\", \"d\", window, []').bubbles", "true");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, []').cancelable", "false");
shouldBe("testInitEvent('Message', '\"a\", false, true, \"b\", \"c\", \"d\", window, []').cancelable", "true");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, []').data", "'b'");
shouldBe("testInitEvent('Message', '\"a\", false, false, null, \"c\", \"d\", window, []').data", "null");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, []').origin", "'c'");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", null, \"d\", window, []').origin", "'null'");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, []').lastEventId", "'d'");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", null, window, []').lastEventId", "'null'");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, []').source", "window");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", null, []').source", "null");
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", null, []').ports", "[]");
var channel = new MessageChannel;
var channelArray = [channel.port1, channel.port2];
shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", null, channelArray').ports[0]", "channel.port1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
var flag = false;
es.onmessage = function (e) { flag = (e.data == "hello"); };
var evt = document.createEvent("MessageEvent");
evt.initMessageEvent("message", false, false, "hello", null, null, null, null);
evt.initMessageEvent("message", false, false, "hello", null, null, null, []);
es.dispatchEvent(evt);
if (flag) {
log("PASS: dispatching event on an EventSource triggers attribute listener");
Expand Down
26 changes: 26 additions & 0 deletions LayoutTests/imported/w3c/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
2017-03-07 Chris Dumez <cdumez@apple.com>

Align initEvent / initCustomEvent / initMessageEvent with the latest specification
https://bugs.webkit.org/show_bug.cgi?id=169176

Reviewed by Alex Christensen.

Re-sync web-platform tests from upstream after:
- https://github.com/w3c/web-platform-tests/pull/5043
- https://github.com/w3c/web-platform-tests/pull/5044

* web-platform-tests/dom/events/CustomEvent-expected.txt:
* web-platform-tests/dom/events/CustomEvent.html:
* web-platform-tests/dom/events/Event-initEvent-expected.txt:
* web-platform-tests/dom/events/Event-initEvent.html:
* web-platform-tests/dom/interfaces-expected.txt:
* web-platform-tests/dom/interfaces.html:
* web-platform-tests/html/dom/interfaces-expected.txt:
* web-platform-tests/html/dom/interfaces.html:
* web-platform-tests/html/dom/resources/interfaces.idl: Copied from LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces.html.
* web-platform-tests/html/dom/resources/untested-interfaces.idl: Added.
* web-platform-tests/html/webappapis/scripting/events/messageevent-constructor-expected.txt: Removed.
* web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.html: Removed.
* web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https.html:

2017-03-06 Alex Christensen <achristensen@webkit.org>

Fix URLs relative to file URLs with paths beginning with Windows drive letters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

PASS CustomEvent
PASS CustomEvent dispatching.
PASS First parameter to initCustomEvent should be mandatory.
PASS initCustomEvent's default parameter values.

Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,21 @@
var fooEvent = document.createEvent("CustomEvent");
fooEvent.initEvent(type, true, true);
target.dispatchEvent(fooEvent);
});
}, "CustomEvent dispatching.");

test(function() {
var e = document.createEvent("CustomEvent");
assert_throws(new TypeError(), function() {
e.initCustomEvent();
});
}, "First parameter to initCustomEvent should be mandatory.");

test(function() {
var e = document.createEvent("CustomEvent");
e.initCustomEvent("foo");
assert_equals(e.type, "foo", "type");
assert_false(e.bubbles, "bubbles");
assert_false(e.cancelable, "cancelable");
assert_equals(e.detail, null, "detail");
}, "initCustomEvent's default parameter values.");
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ PASS Calling initEvent must not have an effect during dispatching.
PASS Calling initEvent must unset the stop propagation flag.
PASS Calling initEvent must unset the stop immediate propagation flag.
PASS Calling initEvent during propagation.
PASS First parameter to initEvent should be mandatory.
PASS Tests initEvent's default parameter values.

Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,19 @@

this.done()
}, "Calling initEvent during propagation.")

test(function() {
var e = document.createEvent("Event")
assert_throws(new TypeError(), function() {
e.initEvent()
})
}, "First parameter to initEvent should be mandatory.")

test(function() {
var e = document.createEvent("Event")
e.initEvent("type")
assert_equals(e.type, "type", "type")
assert_false(e.bubbles, "bubbles")
assert_false(e.cancelable, "cancelable")
}, "Tests initEvent's default parameter values.")
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ PASS Event interface: document.createEvent("Event") must inherit property "defau
PASS Event interface: document.createEvent("Event") must have own property "isTrusted"
PASS Event interface: document.createEvent("Event") must inherit property "timeStamp" with the proper type (15)
PASS Event interface: document.createEvent("Event") must inherit property "initEvent" with the proper type (16)
FAIL Event interface: calling initEvent(DOMString,boolean,boolean) on document.createEvent("Event") with too few arguments must throw TypeError assert_throws: Called with 1 arguments function "function () {
fn.apply(obj, args);
}" did not throw
PASS Event interface: calling initEvent(DOMString,boolean,boolean) on document.createEvent("Event") with too few arguments must throw TypeError
PASS Event must be primary interface of new Event("foo")
PASS Stringification of new Event("foo")
PASS Event interface: new Event("foo") must inherit property "type" with the proper type (0)
Expand All @@ -68,9 +66,7 @@ PASS Event interface: new Event("foo") must inherit property "defaultPrevented"
PASS Event interface: new Event("foo") must have own property "isTrusted"
PASS Event interface: new Event("foo") must inherit property "timeStamp" with the proper type (15)
PASS Event interface: new Event("foo") must inherit property "initEvent" with the proper type (16)
FAIL Event interface: calling initEvent(DOMString,boolean,boolean) on new Event("foo") with too few arguments must throw TypeError assert_throws: Called with 1 arguments function "function () {
fn.apply(obj, args);
}" did not throw
PASS Event interface: calling initEvent(DOMString,boolean,boolean) on new Event("foo") with too few arguments must throw TypeError
PASS CustomEvent interface: existence and properties of interface object
PASS CustomEvent interface object length
PASS CustomEvent interface object name
Expand Down Expand Up @@ -100,9 +96,7 @@ PASS Event interface: new CustomEvent("foo") must inherit property "defaultPreve
PASS Event interface: new CustomEvent("foo") must have own property "isTrusted"
PASS Event interface: new CustomEvent("foo") must inherit property "timeStamp" with the proper type (15)
PASS Event interface: new CustomEvent("foo") must inherit property "initEvent" with the proper type (16)
FAIL Event interface: calling initEvent(DOMString,boolean,boolean) on new CustomEvent("foo") with too few arguments must throw TypeError assert_throws: Called with 1 arguments function "function () {
fn.apply(obj, args);
}" did not throw
PASS Event interface: calling initEvent(DOMString,boolean,boolean) on new CustomEvent("foo") with too few arguments must throw TypeError
PASS EventTarget interface: existence and properties of interface object
PASS EventTarget interface object length
PASS EventTarget interface object name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h1>DOM IDL tests</h1>
[Unforgeable] readonly attribute boolean isTrusted;
readonly attribute DOMTimeStamp timeStamp;

void initEvent(DOMString type, boolean bubbles, boolean cancelable);
void initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false);
};

dictionary EventInit {
Expand All @@ -48,7 +48,7 @@ <h1>DOM IDL tests</h1>
interface CustomEvent : Event {
readonly attribute any detail;

void initCustomEvent(DOMString type, boolean bubbles, boolean cancelable, any detail);
void initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null);
};

dictionary CustomEventInit : EventInit {
Expand Down
Loading

0 comments on commit 7f1d18d

Please sign in to comment.