<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[207016] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/207016">207016</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-10-10 13:21:30 -0700 (Mon, 10 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update MessageEvent to stop using legacy [ConstructorTemplate=Event]
https://bugs.webkit.org/show_bug.cgi?id=163187

Reviewed by Darin Adler.

Source/WebCore:

Update MessageEvent to stop using legacy [ConstructorTemplate=Event] and
use a regular constructor as in the specification:
- https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces

No new tests, updated existing test.

* bindings/js/JSDOMBinding.h:
(WebCore::toRefPtrNativeArray):
* bindings/js/JSDOMConvert.h:
(WebCore::convertWrapperTypeSequence):
(WebCore::convertWrapperType): Deleted.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDefaultValue):
(GenerateDictionaryImplementationContent):
(GetNativeType):
* dom/MessageEvent.cpp:
(WebCore::MessageEvent::MessageEvent):
(WebCore::MessageEvent::create):
(WebCore::MessageEvent::trySerializeData):
(WebCore::MessageEvent::createForBindings): Deleted.
(WebCore::MessageEvent::initMessageEvent): Deleted.
* dom/MessageEvent.h:
* dom/MessageEvent.idl:

LayoutTests:

Rebaseline existing test now that:
- Exception messages are sometimes a bit different
- We properly use the default member value when input is an explicit undefined
- We throw in more cases of bad input

* fast/events/constructors/message-event-constructor-expected.txt:
* fast/events/constructors/message-event-constructor.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfasteventsconstructorsmessageeventconstructorexpectedtxt">trunk/LayoutTests/fast/events/constructors/message-event-constructor-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsconstructorsmessageeventconstructorhtml">trunk/LayoutTests/fast/events/constructors/message-event-constructor.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingh">trunk/Source/WebCore/bindings/js/JSDOMBinding.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMConverth">trunk/Source/WebCore/bindings/js/JSDOMConvert.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCoredomMessageEventcpp">trunk/Source/WebCore/dom/MessageEvent.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMessageEventh">trunk/Source/WebCore/dom/MessageEvent.h</a></li>
<li><a href="#trunkSourceWebCoredomMessageEventidl">trunk/Source/WebCore/dom/MessageEvent.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (207015 => 207016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/LayoutTests/ChangeLog        2016-10-10 20:21:30 UTC (rev 207016)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-10-10  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Update MessageEvent to stop using legacy [ConstructorTemplate=Event]
+        https://bugs.webkit.org/show_bug.cgi?id=163187
+
+        Reviewed by Darin Adler.
+
+        Rebaseline existing test now that:
+        - Exception messages are sometimes a bit different
+        - We properly use the default member value when input is an explicit undefined
+        - We throw in more cases of bad input
+
+        * fast/events/constructors/message-event-constructor-expected.txt:
+        * fast/events/constructors/message-event-constructor.html:
+
</ins><span class="cx"> 2016-10-10  Antoine Quint  &lt;graouts@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Modern Media Controls] Buttons
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsconstructorsmessageeventconstructorexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/constructors/message-event-constructor-expected.txt (207015 => 207016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/constructors/message-event-constructor-expected.txt        2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/LayoutTests/fast/events/constructors/message-event-constructor-expected.txt        2016-10-10 20:21:30 UTC (rev 207016)
</span><span class="lines">@@ -16,7 +16,7 @@
</span><span class="cx"> PASS new MessageEvent('eventType', { cancelable: true }).cancelable is true
</span><span class="cx"> PASS new MessageEvent('eventType', { data: test_object }).data is test_object
</span><span class="cx"> PASS new MessageEvent('eventType', { data: document }).data is document
</span><del>-PASS new MessageEvent('eventType', { data: undefined }).data is undefined
</del><ins>+PASS new MessageEvent('eventType', { data: undefined }).data is null
</ins><span class="cx"> PASS new MessageEvent('eventType', { data: null }).data is null
</span><span class="cx"> PASS new MessageEvent('eventType', { data: false }).data is false
</span><span class="cx"> PASS new MessageEvent('eventType', { data: true }).data is true
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> PASS new MessageEvent('eventType', { get data() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
</span><span class="cx"> PASS new MessageEvent('eventType', { origin: 'melancholy' }).origin is &quot;melancholy&quot;
</span><span class="cx"> PASS new MessageEvent('eventType', { origin: '' }).origin is &quot;&quot;
</span><del>-PASS new MessageEvent('eventType', { origin: undefined }).origin is &quot;undefined&quot;
</del><ins>+PASS new MessageEvent('eventType', { origin: undefined }).origin is &quot;&quot;
</ins><span class="cx"> PASS new MessageEvent('eventType', { origin: null }).origin is &quot;null&quot;
</span><span class="cx"> PASS new MessageEvent('eventType', { origin: false }).origin is &quot;false&quot;
</span><span class="cx"> PASS new MessageEvent('eventType', { origin: true }).origin is &quot;true&quot;
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> PASS new MessageEvent('eventType', { get origin() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
</span><span class="cx"> PASS new MessageEvent('eventType', { lastEventId: 'melancholy' }).lastEventId is &quot;melancholy&quot;
</span><span class="cx"> PASS new MessageEvent('eventType', { lastEventId: '' }).lastEventId is &quot;&quot;
</span><del>-PASS new MessageEvent('eventType', { lastEventId: undefined }).lastEventId is &quot;undefined&quot;
</del><ins>+PASS new MessageEvent('eventType', { lastEventId: undefined }).lastEventId is &quot;&quot;
</ins><span class="cx"> PASS new MessageEvent('eventType', { lastEventId: null }).lastEventId is &quot;null&quot;
</span><span class="cx"> PASS new MessageEvent('eventType', { lastEventId: false }).lastEventId is &quot;false&quot;
</span><span class="cx"> PASS new MessageEvent('eventType', { lastEventId: true }).lastEventId is &quot;true&quot;
</span><span class="lines">@@ -61,20 +61,20 @@
</span><span class="cx"> PASS new MessageEvent('eventType', { source: window }).source is window
</span><span class="cx"> PASS new MessageEvent('eventType', { source: this }).source is this
</span><span class="cx"> PASS new MessageEvent('eventType', { ports: [channel.port1], source: channel.port1 }).source is channel.port1
</span><del>-PASS new MessageEvent('eventType', { source: test_object }).source is null
</del><ins>+PASS new MessageEvent('eventType', { source: test_object }).source threw exception TypeError: Type error.
</ins><span class="cx"> PASS new MessageEvent('eventType', { source: document }).source is null
</span><span class="cx"> PASS new MessageEvent('eventType', { source: document.body }).source is null
</span><span class="cx"> PASS new MessageEvent('eventType', { source: undefined }).source is null
</span><span class="cx"> PASS new MessageEvent('eventType', { source: null }).source is null
</span><del>-PASS new MessageEvent('eventType', { source: false }).source is null
-PASS new MessageEvent('eventType', { source: true }).source is null
-PASS new MessageEvent('eventType', { source: '' }).source is null
-PASS new MessageEvent('eventType', { source: 'chocolate' }).source is null
-PASS new MessageEvent('eventType', { source: 12345 }).source is null
-PASS new MessageEvent('eventType', { source: 18446744073709551615 }).source is null
-PASS new MessageEvent('eventType', { source: NaN }).source is null
-PASS new MessageEvent('eventType', { source: {valueOf: function () { return window; } } }).source == window is false
-PASS new MessageEvent('eventType', { get source() { return 123; } }).source is null
</del><ins>+PASS new MessageEvent('eventType', { source: false }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: true }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: '' }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: 'chocolate' }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: 12345 }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: 18446744073709551615 }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: NaN }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: {valueOf: function () { return window; } } }) threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { get source() { return 123; } }).source threw exception TypeError: Type error.
</ins><span class="cx"> PASS new MessageEvent('eventType', { get source() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
</span><span class="cx"> PASS new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel2.port1] }).ports[0] is channel.port1
</span><span class="cx"> PASS new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel2.port1] }).ports[1] is channel.port2
</span><span class="lines">@@ -81,10 +81,10 @@
</span><span class="cx"> PASS new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel2.port1] }).ports[2] is channel2.port1
</span><span class="cx"> PASS new MessageEvent('eventType', { ports: [] }).ports is []
</span><span class="cx"> PASS new MessageEvent('eventType', { ports: undefined }).ports is []
</span><del>-PASS new MessageEvent('eventType', { ports: null }).ports is []
-PASS new MessageEvent('eventType', { ports: [1, 2, 3] }).ports[2] threw exception TypeError: Type error.
-PASS new MessageEvent('eventType', { ports: test_object }).ports threw exception TypeError: Value is not a sequence.
-PASS new MessageEvent('eventType', { ports: document }).ports threw exception TypeError: Value is not a sequence.
</del><ins>+PASS new MessageEvent('eventType', { ports: [1, 2, 3] }).ports[2] threw exception TypeError: Invalid Array element type.
+PASS new MessageEvent('eventType', { ports: test_object }).ports threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { ports: document }).ports threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { ports: null }).ports threw exception TypeError: Value is not a sequence.
</ins><span class="cx"> PASS new MessageEvent('eventType', { ports: false }).ports threw exception TypeError: Value is not a sequence.
</span><span class="cx"> PASS new MessageEvent('eventType', { ports: true }).ports threw exception TypeError: Value is not a sequence.
</span><span class="cx"> PASS new MessageEvent('eventType', { ports: '' }).ports threw exception TypeError: Value is not a sequence.
</span><span class="lines">@@ -93,8 +93,8 @@
</span><span class="cx"> PASS new MessageEvent('eventType', { ports: 18446744073709551615 }).ports threw exception TypeError: Value is not a sequence.
</span><span class="cx"> PASS new MessageEvent('eventType', { ports: NaN }).ports threw exception TypeError: Value is not a sequence.
</span><span class="cx"> PASS new MessageEvent('eventType', { get ports() { return 123; } }).ports threw exception TypeError: Value is not a sequence.
</span><del>-PASS new MessageEvent('eventType', { get ports() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
-PASS new MessageEvent('eventType', { ports: {valueOf: function () { return [channel.port1, channel.port2, channel.port2]; } } }).ports[0] threw exception TypeError: Value is not a sequence.
</del><ins>+PASS new MessageEvent('eventType', { get ports() { throw 'MessageEvent Error'; } }) threw exception TypeError: Value is not a sequence.
+PASS new MessageEvent('eventType', { ports: {valueOf: function () { return [channel.port1, channel.port2, channel.port2]; } } }).ports[0] threw exception TypeError: Type error.
</ins><span class="cx"> PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel2.port1] }).bubbles is true
</span><span class="cx"> PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel2.port1] }).cancelable is true
</span><span class="cx"> PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel2.port1] }).data is test_object
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsconstructorsmessageeventconstructorhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/constructors/message-event-constructor.html (207015 => 207016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/constructors/message-event-constructor.html        2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/LayoutTests/fast/events/constructors/message-event-constructor.html        2016-10-10 20:21:30 UTC (rev 207016)
</span><span class="lines">@@ -30,8 +30,8 @@
</span><span class="cx"> // data is passed.
</span><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { data: test_object }).data&quot;, &quot;test_object&quot;);
</span><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { data: document }).data&quot;, &quot;document&quot;);
</span><del>-shouldBe(&quot;new MessageEvent('eventType', { data: undefined }).data&quot;, &quot;undefined&quot;);
-shouldBe(&quot;new MessageEvent('eventType', { data: null }).data&quot;, &quot;null&quot;);
</del><ins>+shouldBeNull(&quot;new MessageEvent('eventType', { data: undefined }).data&quot;);
+shouldBeNull(&quot;new MessageEvent('eventType', { data: null }).data&quot;);
</ins><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { data: false }).data&quot;, &quot;false&quot;);
</span><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { data: true }).data&quot;, &quot;true&quot;);
</span><span class="cx"> shouldBeEqualToString(&quot;new MessageEvent('eventType', { data: '' }).data&quot;, &quot;&quot;);
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     shouldBeEqualToString(&quot;new MessageEvent('eventType', { &quot; + attr + &quot;: '' }).&quot; + attr, &quot;&quot;);
</span><span class="cx"> 
</span><span class="cx">     // Non-strings.
</span><del>-    shouldBeEqualToString(&quot;new MessageEvent('eventType', { &quot; + attr + &quot;: undefined }).&quot; + attr, &quot;undefined&quot;);
</del><ins>+    shouldBeEqualToString(&quot;new MessageEvent('eventType', { &quot; + attr + &quot;: undefined }).&quot; + attr, &quot;&quot;);
</ins><span class="cx">     shouldBeEqualToString(&quot;new MessageEvent('eventType', { &quot; + attr + &quot;: null }).&quot; + attr, &quot;null&quot;);
</span><span class="cx">     shouldBeEqualToString(&quot;new MessageEvent('eventType', { &quot; + attr + &quot;: false }).&quot; + attr, &quot;false&quot;);
</span><span class="cx">     shouldBeEqualToString(&quot;new MessageEvent('eventType', { &quot; + attr + &quot;: true }).&quot; + attr, &quot;true&quot;);
</span><span class="lines">@@ -76,21 +76,21 @@
</span><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { ports: [channel.port1], source: channel.port1 }).source&quot;, &quot;channel.port1&quot;);
</span><span class="cx"> 
</span><span class="cx"> // Unacceptable source objects (not a Window or a MessagePort).
</span><del>-shouldBe(&quot;new MessageEvent('eventType', { source: test_object }).source&quot;, &quot;null&quot;);
</del><ins>+shouldThrowErrorName(&quot;new MessageEvent('eventType', { source: test_object }).source&quot;, &quot;TypeError&quot;);
</ins><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { source: document }).source&quot;, &quot;null&quot;);
</span><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { source: document.body }).source&quot;, &quot;null&quot;);
</span><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { source: undefined }).source&quot;, &quot;null&quot;);
</span><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { source: null }).source&quot;, &quot;null&quot;);
</span><del>-shouldBe(&quot;new MessageEvent('eventType', { source: false }).source&quot;, &quot;null&quot;);
-shouldBe(&quot;new MessageEvent('eventType', { source: true }).source&quot;, &quot;null&quot;);
-shouldBe(&quot;new MessageEvent('eventType', { source: '' }).source&quot;, &quot;null&quot;);
-shouldBe(&quot;new MessageEvent('eventType', { source: 'chocolate' }).source&quot;, &quot;null&quot;);
-shouldBe(&quot;new MessageEvent('eventType', { source: 12345 }).source&quot;, &quot;null&quot;);
-shouldBe(&quot;new MessageEvent('eventType', { source: 18446744073709551615 }).source&quot;, &quot;null&quot;);
-shouldBe(&quot;new MessageEvent('eventType', { source: NaN }).source&quot;, &quot;null&quot;);
</del><ins>+shouldThrowErrorName(&quot;new MessageEvent('eventType', { source: false }).source&quot;, &quot;TypeError&quot;);
+shouldThrowErrorName(&quot;new MessageEvent('eventType', { source: true }).source&quot;, &quot;TypeError&quot;);
+shouldThrowErrorName(&quot;new MessageEvent('eventType', { source: '' }).source&quot;, &quot;TypeError&quot;);
+shouldThrowErrorName(&quot;new MessageEvent('eventType', { source: 'chocolate' }).source&quot;, &quot;TypeError&quot;);
+shouldThrowErrorName(&quot;new MessageEvent('eventType', { source: 12345 }).source&quot;, &quot;TypeError&quot;);
+shouldThrowErrorName(&quot;new MessageEvent('eventType', { source: 18446744073709551615 }).source&quot;, &quot;TypeError&quot;);
+shouldThrowErrorName(&quot;new MessageEvent('eventType', { source: NaN }).source&quot;, &quot;TypeError&quot;);
</ins><span class="cx"> // Note that valueOf() is not called, when the left hand side is evaluated.
</span><del>-shouldBeFalse(&quot;new MessageEvent('eventType', { source: {valueOf: function () { return window; } } }).source == window&quot;);
-shouldBe(&quot;new MessageEvent('eventType', { get source() { return 123; } }).source&quot;, &quot;null&quot;);
</del><ins>+shouldThrowErrorName(&quot;new MessageEvent('eventType', { source: {valueOf: function () { return window; } } })&quot;, &quot;TypeError&quot;);
+shouldThrowErrorName(&quot;new MessageEvent('eventType', { get source() { return 123; } }).source&quot;, &quot;TypeError&quot;);
</ins><span class="cx"> shouldThrow(&quot;new MessageEvent('eventType', { get source() { throw 'MessageEvent Error'; } })&quot;);
</span><span class="cx"> 
</span><span class="cx"> // ports is passed.
</span><span class="lines">@@ -101,12 +101,12 @@
</span><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel2.port1] }).ports[2]&quot;, &quot;channel2.port1&quot;);
</span><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { ports: [] }).ports&quot;, &quot;[]&quot;);
</span><span class="cx"> shouldBe(&quot;new MessageEvent('eventType', { ports: undefined }).ports&quot;, &quot;[]&quot;);
</span><del>-shouldBe(&quot;new MessageEvent('eventType', { ports: null }).ports&quot;, &quot;[]&quot;);
</del><span class="cx"> 
</span><span class="cx"> // Invalid message ports.
</span><span class="cx"> shouldThrow(&quot;new MessageEvent('eventType', { ports: [1, 2, 3] }).ports[2]&quot;);
</span><span class="cx"> shouldThrow(&quot;new MessageEvent('eventType', { ports: test_object }).ports&quot;);
</span><span class="cx"> shouldThrow(&quot;new MessageEvent('eventType', { ports: document }).ports&quot;);
</span><ins>+shouldThrow(&quot;new MessageEvent('eventType', { ports: null }).ports&quot;)
</ins><span class="cx"> shouldThrow(&quot;new MessageEvent('eventType', { ports: false }).ports&quot;);
</span><span class="cx"> shouldThrow(&quot;new MessageEvent('eventType', { ports: true }).ports&quot;);
</span><span class="cx"> shouldThrow(&quot;new MessageEvent('eventType', { ports: '' }).ports&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (207015 => 207016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/ChangeLog        2016-10-10 20:21:30 UTC (rev 207016)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-10-10  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Update MessageEvent to stop using legacy [ConstructorTemplate=Event]
+        https://bugs.webkit.org/show_bug.cgi?id=163187
+
+        Reviewed by Darin Adler.
+
+        Update MessageEvent to stop using legacy [ConstructorTemplate=Event] and
+        use a regular constructor as in the specification:
+        - https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces
+
+        No new tests, updated existing test.
+
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::toRefPtrNativeArray):
+        * bindings/js/JSDOMConvert.h:
+        (WebCore::convertWrapperTypeSequence):
+        (WebCore::convertWrapperType): Deleted.
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateDefaultValue):
+        (GenerateDictionaryImplementationContent):
+        (GetNativeType):
+        * dom/MessageEvent.cpp:
+        (WebCore::MessageEvent::MessageEvent):
+        (WebCore::MessageEvent::create):
+        (WebCore::MessageEvent::trySerializeData):
+        (WebCore::MessageEvent::createForBindings): Deleted.
+        (WebCore::MessageEvent::initMessageEvent): Deleted.
+        * dom/MessageEvent.h:
+        * dom/MessageEvent.idl:
+
</ins><span class="cx"> 2016-10-10  Antoine Quint  &lt;graouts@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Modern Media Controls] Buttons
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (207015 => 207016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2016-10-10 20:21:30 UTC (rev 207016)
</span><span class="lines">@@ -297,7 +297,7 @@
</span><span class="cx"> RefPtr&lt;JSC::Float64Array&gt; toFloat64Array(JSC::JSValue);
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename T, typename JSType&gt; Vector&lt;Ref&lt;T&gt;&gt; toRefNativeArray(JSC::ExecState&amp;, JSC::JSValue);
</span><del>-template&lt;typename T, typename JSType&gt; Vector&lt;RefPtr&lt;T&gt;&gt; toRefPtrNativeArray(JSC::ExecState&amp;, JSC::JSValue);
</del><ins>+template&lt;typename T, typename JSType, typename VectorType = Vector&lt;RefPtr&lt;T&gt;&gt;&gt; VectorType toRefPtrNativeArray(JSC::ExecState&amp;, JSC::JSValue);
</ins><span class="cx"> template&lt;typename T&gt; Vector&lt;T&gt; toNativeArray(JSC::ExecState&amp;, JSC::JSValue);
</span><span class="cx"> bool hasIteratorMethod(JSC::ExecState&amp;, JSC::JSValue);
</span><span class="cx"> 
</span><span class="lines">@@ -835,18 +835,18 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template&lt;typename T, typename JST&gt; Vector&lt;RefPtr&lt;T&gt;&gt; toRefPtrNativeArray(JSC::ExecState&amp; exec, JSC::JSValue value)
</del><ins>+template&lt;typename T, typename JST, typename VectorType&gt; VectorType toRefPtrNativeArray(JSC::ExecState&amp; state, JSC::JSValue value)
</ins><span class="cx"> {
</span><del>-    JSC::VM&amp; vm = exec.vm();
</del><ins>+    JSC::VM&amp; vm = state.vm();
</ins><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx"> 
</span><span class="cx">     if (!value.isObject()) {
</span><del>-        throwSequenceTypeError(exec, scope);
</del><ins>+        throwSequenceTypeError(state, scope);
</ins><span class="cx">         return { };
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Vector&lt;RefPtr&lt;T&gt;&gt; result;
-    forEachInIterable(&amp;exec, value, [&amp;result](JSC::VM&amp; vm, JSC::ExecState* state, JSC::JSValue jsValue) {
</del><ins>+    VectorType result;
+    forEachInIterable(&amp;state, value, [&amp;result](JSC::VM&amp; vm, JSC::ExecState* state, JSC::JSValue jsValue) {
</ins><span class="cx">         auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx"> 
</span><span class="cx">         if (jsValue.inherits(JST::info()))
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMConverth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMConvert.h (207015 => 207016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMConvert.h        2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvert.h        2016-10-10 20:21:30 UTC (rev 207016)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> 
</span><span class="cx"> enum class IsNullable { No, Yes };
</span><span class="cx"> template&lt;typename T, typename JST&gt; T* convertWrapperType(JSC::ExecState&amp;, JSC::JSValue, IsNullable);
</span><ins>+template&lt;typename T, typename JST, typename VectorType&gt; VectorType convertWrapperTypeSequence(JSC::ExecState&amp;, JSC::JSValue);
</ins><span class="cx"> 
</span><span class="cx"> // This is where the implementation of the things declared above begins:
</span><span class="cx"> 
</span><span class="lines">@@ -77,6 +78,11 @@
</span><span class="cx">     return object;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template&lt;typename T, typename JST, typename VectorType&gt; inline VectorType convertWrapperTypeSequence(JSC::ExecState&amp; state, JSC::JSValue value)
+{
+    return toRefPtrNativeArray&lt;T, JST, VectorType&gt;(state, value);
+}
+
</ins><span class="cx"> template&lt;typename T&gt; struct DefaultConverter {
</span><span class="cx">     using OptionalValue = Optional&lt;T&gt;;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (207015 => 207016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-10-10 20:21:30 UTC (rev 207016)
</span><span class="lines">@@ -986,6 +986,7 @@
</span><span class="cx">     if ($value eq &quot;null&quot;) {
</span><span class="cx">         $value = $member-&gt;type eq &quot;any&quot; ? &quot;jsNull()&quot; : &quot;nullptr&quot;;
</span><span class="cx">     }
</span><ins>+    $value = &quot;{ }&quot; if $value eq &quot;[]&quot;;
</ins><span class="cx">     $value = &quot;jsUndefined()&quot; if $value eq &quot;undefined&quot;;
</span><span class="cx"> 
</span><span class="cx">     return $value;
</span><span class="lines">@@ -1120,6 +1121,14 @@
</span><span class="cx">                 $result .= &quot;        Optional&lt;${nativeType}&gt; $key = convertDictionary&lt;${nativeType}&gt;(state, ${key}Value).value();\n&quot;;
</span><span class="cx">                 $result .= &quot;        RETURN_IF_EXCEPTION(throwScope, Nullopt);\n&quot;;
</span><span class="cx">                 $result .= &quot;        result.$key = $key.value();\n&quot;;
</span><ins>+            } elsif ($codeGenerator-&gt;IsSequenceOrFrozenArrayType($type)) {
+                my $innerType = $codeGenerator-&gt;GetSequenceOrFrozenArrayInnerType($type);
+                if ($codeGenerator-&gt;IsWrapperType($innerType)) {
+                    $result .= &quot;        result.$key = convertWrapperTypeSequence&lt;$innerType, JS$innerType, $nativeType&gt;(state, ${key}Value);\n&quot;;
+                } else {
+                    $result .= &quot;        result.$key = convert&lt;${nativeType}&gt;(state, ${key}Value);\n&quot;;
+                }
+                $result .= &quot;        RETURN_IF_EXCEPTION(throwScope, Nullopt);\n&quot;;
</ins><span class="cx">             } else {
</span><span class="cx">                 my $conversionRuleWithLeadingComma = GenerateConversionRuleWithLeadingComma($interface, $member);
</span><span class="cx">                 $result .= &quot;        result.$key = convert&lt;${nativeType}&gt;(state, ${key}Value${conversionRuleWithLeadingComma});\n&quot;;
</span><span class="lines">@@ -4778,14 +4787,15 @@
</span><span class="cx">     &quot;unsigned short&quot; =&gt; &quot;uint16_t&quot;,
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-sub GetVariadicType
</del><ins>+sub GetNativeVectorType
</ins><span class="cx"> {
</span><span class="cx">     my ($interface, $type) = @_;
</span><span class="cx"> 
</span><del>-    my $wrappedType = IsNativeType($type) ? GetNativeType($interface, $type) : $type;
-    my $wrapperType = IsNativeType($type) ? &quot;JSC::JSValue&quot; : &quot;JS$wrappedType&quot;;
</del><ins>+    die &quot;This should only be called for sequence or array types&quot; unless $codeGenerator-&gt;IsSequenceOrFrozenArrayType($type);
</ins><span class="cx"> 
</span><del>-    return ($wrapperType, $wrappedType);
</del><ins>+    my $innerType = $codeGenerator-&gt;GetSequenceOrFrozenArrayInnerType($type);
+    return &quot;MessagePortArray&quot; if $innerType eq &quot;MessagePort&quot;;
+    return &quot;Vector&lt;&quot; . GetNativeVectorInnerType($innerType) . &quot;&gt;&quot;;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> sub GetNativeType
</span><span class="lines">@@ -4802,7 +4812,7 @@
</span><span class="cx"> 
</span><span class="cx">     return &quot;RefPtr&lt;${type}&gt;&quot; if $codeGenerator-&gt;IsTypedArrayType($type) and $type ne &quot;ArrayBuffer&quot;;
</span><span class="cx"> 
</span><del>-    return &quot;Vector&lt;&quot; . GetNativeVectorInnerType($codeGenerator-&gt;GetSequenceOrFrozenArrayInnerType($type)) . &quot;&gt;&quot; if $codeGenerator-&gt;IsSequenceOrFrozenArrayType($type);
</del><ins>+    return GetNativeVectorType($interface, $type) if $codeGenerator-&gt;IsSequenceOrFrozenArrayType($type);
</ins><span class="cx"> 
</span><span class="cx">     return &quot;${type}*&quot;;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomMessageEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MessageEvent.cpp (207015 => 207016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MessageEvent.cpp        2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/dom/MessageEvent.cpp        2016-10-10 20:21:30 UTC (rev 207016)
</span><span class="lines">@@ -35,6 +35,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+using namespace JSC;
+
</ins><span class="cx"> static inline bool isValidSource(EventTarget* source)
</span><span class="cx"> {
</span><span class="cx">     return !source || source-&gt;toDOMWindow() || source-&gt;isMessagePort();
</span><span class="lines">@@ -45,10 +47,10 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline MessageEvent::MessageEvent(const AtomicString&amp; type, const MessageEventInit&amp; initializer)
-    : Event(type, initializer)
</del><ins>+inline MessageEvent::MessageEvent(ExecState&amp; state, const AtomicString&amp; type, const Init&amp; initializer, IsTrusted isTrusted)
+    : Event(type, initializer, isTrusted)
</ins><span class="cx">     , m_dataType(DataTypeScriptValue)
</span><del>-    , m_dataAsScriptValue(initializer.data)
</del><ins>+    , m_dataAsScriptValue(state.vm(), initializer.data)
</ins><span class="cx">     , m_origin(initializer.origin)
</span><span class="cx">     , m_lastEventId(initializer.lastEventId)
</span><span class="cx">     , m_source(isValidSource(initializer.source.get()) ? initializer.source : nullptr)
</span><span class="lines">@@ -131,9 +133,9 @@
</span><span class="cx">     return adoptRef(*new MessageEvent);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref&lt;MessageEvent&gt; MessageEvent::createForBindings(const AtomicString&amp; type, const MessageEventInit&amp; initializer)
</del><ins>+Ref&lt;MessageEvent&gt; MessageEvent::create(ExecState&amp; state, const AtomicString&amp; type, const Init&amp; initializer, IsTrusted isTrusted)
</ins><span class="cx"> {
</span><del>-    return adoptRef(*new MessageEvent(type, initializer));
</del><ins>+    return adoptRef(*new MessageEvent(state, type, initializer, isTrusted));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MessageEvent::~MessageEvent()
</span><span class="lines">@@ -172,7 +174,7 @@
</span><span class="cx">     m_ports = WTFMove(ports);
</span><span class="cx"> }
</span><span class="cx">     
</span><del>-RefPtr&lt;SerializedScriptValue&gt; MessageEvent::trySerializeData(JSC::ExecState* exec)
</del><ins>+RefPtr&lt;SerializedScriptValue&gt; MessageEvent::trySerializeData(ExecState* exec)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!m_dataAsScriptValue.hasNoValue());
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebCoredomMessageEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MessageEvent.h (207015 => 207016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MessageEvent.h        2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/dom/MessageEvent.h        2016-10-10 20:21:30 UTC (rev 207016)
</span><span class="lines">@@ -36,14 +36,6 @@
</span><span class="cx"> 
</span><span class="cx"> class Blob;
</span><span class="cx"> 
</span><del>-struct MessageEventInit : public EventInit {
-    Deprecated::ScriptValue data;
-    String origin;
-    String lastEventId;
-    RefPtr&lt;EventTarget&gt; source;
-    MessagePortArray ports;
-};
-
</del><span class="cx"> class MessageEvent final : public Event {
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;MessageEvent&gt; create(std::unique_ptr&lt;MessagePortArray&gt;, RefPtr&lt;SerializedScriptValue&gt;&amp;&amp;, const String&amp; origin = { }, const String&amp; lastEventId = { }, EventTarget* source = nullptr);
</span><span class="lines">@@ -52,7 +44,16 @@
</span><span class="cx">     static Ref&lt;MessageEvent&gt; create(Ref&lt;Blob&gt;&amp;&amp; data, const String&amp; origin);
</span><span class="cx">     static Ref&lt;MessageEvent&gt; create(Ref&lt;ArrayBuffer&gt;&amp;&amp; data, const String&amp; origin = { });
</span><span class="cx">     static Ref&lt;MessageEvent&gt; createForBindings();
</span><del>-    static Ref&lt;MessageEvent&gt; createForBindings(const AtomicString&amp; type, const MessageEventInit&amp;);
</del><ins>+
+    struct Init : EventInit {
+        JSC::JSValue data;
+        String origin;
+        String lastEventId;
+        RefPtr&lt;EventTarget&gt; source;
+        MessagePortArray ports;
+    };
+    static Ref&lt;MessageEvent&gt; create(JSC::ExecState&amp;, const AtomicString&amp; type, const Init&amp;, IsTrusted = IsTrusted::No);
+
</ins><span class="cx">     virtual ~MessageEvent();
</span><span class="cx"> 
</span><span class="cx">     void initMessageEvent(const AtomicString&amp; type, bool canBubble, bool cancelable, const Deprecated::ScriptValue&amp; data, const String&amp; origin, const String&amp; lastEventId, DOMWindow* source, std::unique_ptr&lt;MessagePortArray&gt;);
</span><span class="lines">@@ -86,7 +87,7 @@
</span><span class="cx">     
</span><span class="cx"> private:
</span><span class="cx">     MessageEvent();
</span><del>-    MessageEvent(const AtomicString&amp;, const MessageEventInit&amp;);
</del><ins>+    MessageEvent(JSC::ExecState&amp;, const AtomicString&amp;, const Init&amp;, IsTrusted);
</ins><span class="cx">     MessageEvent(RefPtr&lt;SerializedScriptValue&gt;&amp;&amp; data, const String&amp; origin, const String&amp; lastEventId, EventTarget* source, std::unique_ptr&lt;MessagePortArray&gt;);
</span><span class="cx">     MessageEvent(const AtomicString&amp; type, RefPtr&lt;SerializedScriptValue&gt;&amp;&amp; data, const String&amp; origin, const String&amp; lastEventId);
</span><span class="cx">     MessageEvent(const String&amp; data, const String&amp; origin);
</span></span></pre></div>
<a id="trunkSourceWebCoredomMessageEventidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MessageEvent.idl (207015 => 207016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MessageEvent.idl        2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/dom/MessageEvent.idl        2016-10-10 20:21:30 UTC (rev 207016)
</span><span class="lines">@@ -26,16 +26,16 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> [
</span><del>-    ConstructorTemplate=Event,
</del><ins>+    Constructor(DOMString type, optional MessageEventInit eventInitDict),
+    ConstructorCallWith=ScriptState,
</ins><span class="cx">     Exposed=(Window,Worker),
</span><span class="cx"> ] interface MessageEvent : Event {
</span><del>-    [InitializedByEventConstructor] readonly attribute USVString origin;
-    [InitializedByEventConstructor] readonly attribute DOMString lastEventId;
-    [InitializedByEventConstructor] readonly attribute EventTarget source; // May be a DOMWindow or a MessagePort.
</del><ins>+    readonly attribute USVString origin;
+    readonly attribute DOMString lastEventId;
+    readonly attribute EventTarget? source; // May be a DOMWindow or a MessagePort.
+    [CachedAttribute, CustomGetter] readonly attribute any data;
+    readonly attribute FrozenArray&lt;MessagePort&gt; ports;
</ins><span class="cx"> 
</span><del>-    [InitializedByEventConstructor, CachedAttribute, CustomGetter] readonly attribute any data;
-    [InitializedByEventConstructor] readonly attribute sequence&lt;MessagePort&gt; ports;
-
</del><span class="cx">     [Custom] void initMessageEvent(optional DOMString typeArg, optional boolean canBubbleArg, optional boolean cancelableArg,
</span><span class="cx">         optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional DOMWindow sourceArg,
</span><span class="cx">         optional Array messagePorts);
</span><span class="lines">@@ -44,3 +44,11 @@
</span><span class="cx">         optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional DOMWindow sourceArg,
</span><span class="cx">         optional Array transferables);
</span><span class="cx"> };
</span><ins>+
+dictionary MessageEventInit : EventInit {
+      any data = null;
+      USVString origin = &quot;&quot;;
+      DOMString lastEventId = &quot;&quot;;
+      EventTarget? source = null;
+      sequence&lt;MessagePort&gt; ports = [];
+};
</ins></span></pre>
</div>
</div>

</body>
</html>