<!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>[178662] 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/178662">178662</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2015-01-19 12:03:00 -0800 (Mon, 19 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>ES6: Support Array.of construction
https://bugs.webkit.org/show_bug.cgi?id=140605
&lt;rdar://problem/19513655&gt;

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Add and implementation of Array.of, described in 22.1.2.3 of the ES6
specification (15 Jan 2015). The Array.of() method creates a new Array
instance with a variable number of arguments, regardless of number or type
of the arguments.

* runtime/ArrayConstructor.cpp:
(JSC::arrayConstructorOf): Create a new empty Array, then iterate
over the arguments, setting them to the appropriate index.

LayoutTests:

Add 'of' to the Array properties, and a
test for Array.of().

* js/Object-getOwnPropertyNames-expected.txt:
* js/array-of-expected.txt: Added.
* js/array-of.html: Added.
* js/script-tests/Object-getOwnPropertyNames.js:
* js/script-tests/array-of.js: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsObjectgetOwnPropertyNamesexpectedtxt">trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs">trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeArrayConstructorcpp">trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsarrayofexpectedtxt">trunk/LayoutTests/js/array-of-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrayofhtml">trunk/LayoutTests/js/array-of.html</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrayofjs">trunk/LayoutTests/js/script-tests/array-of.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (178661 => 178662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-01-19 20:02:01 UTC (rev 178661)
+++ trunk/LayoutTests/ChangeLog        2015-01-19 20:03:00 UTC (rev 178662)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-01-18  Dean Jackson  &lt;dino@apple.com&gt;
+
+        ES6: Support Array.of construction
+        https://bugs.webkit.org/show_bug.cgi?id=140605
+        &lt;rdar://problem/19513655&gt;
+
+        Reviewed by Geoffrey Garen.
+
+        Add 'of' to the Array properties, and a
+        test for Array.of().
+
+        * js/Object-getOwnPropertyNames-expected.txt:
+        * js/array-of-expected.txt: Added.
+        * js/array-of.html: Added.
+        * js/script-tests/Object-getOwnPropertyNames.js:
+        * js/script-tests/array-of.js: Added.
+
</ins><span class="cx"> 2015-01-16  Ada Chan  &lt;adachan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         HTMLMediaElement::isPlayingAudio() should return false if the element is explicitly muted by script.
</span></span></pre></div>
<a id="trunkLayoutTestsjsObjectgetOwnPropertyNamesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt (178661 => 178662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2015-01-19 20:02:01 UTC (rev 178661)
+++ trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2015-01-19 20:03:00 UTC (rev 178662)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> PASS getSortedOwnPropertyNames(Object.prototype) is ['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', '__proto__', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Function) is ['length', 'name', 'prototype']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Function.prototype) is ['apply', 'bind', 'call', 'constructor', 'length', 'name', 'toString']
</span><del>-PASS getSortedOwnPropertyNames(Array) is ['isArray', 'length', 'name', 'prototype']
</del><ins>+PASS getSortedOwnPropertyNames(Array) is ['isArray', 'length', 'name', 'of', 'prototype']
</ins><span class="cx"> PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'forEach', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift']
</span><span class="cx"> PASS getSortedOwnPropertyNames(String) is ['fromCharCode', 'length', 'name', 'prototype']
</span><span class="cx"> PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', 'valueOf']
</span></span></pre></div>
<a id="trunkLayoutTestsjsarrayofexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/array-of-expected.txt (0 => 178662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/array-of-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/array-of-expected.txt        2015-01-19 20:03:00 UTC (rev 178662)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+Tests for Array.of
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS Array.of(1) is [1]
+PASS Array.of(1, 2) is [1, 2]
+PASS Array.of(1, 2, 3) is [1, 2, 3]
+PASS Array.of() is []
+PASS Array.of(undefined) is [undefined]
+PASS Array.of('hello') is ['hello']
+Construct nested Array with Array.of(Array.of(1, 2, 3), Array.of(4, 5, 6, 7, 8)).
+PASS x.length is 2
+PASS x[0].length is 3
+PASS x[1].length is 5
+Check that a setter isn't called.
+PASS Array.of(1, 2, 3) did not throw exception.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/js/array-of-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestsjsarrayofhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/array-of.html (0 => 178662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/array-of.html                                (rev 0)
+++ trunk/LayoutTests/js/array-of.html        2015-01-19 20:03:00 UTC (rev 178662)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;script-tests/array-of.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/js/array-of.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js (178661 => 178662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2015-01-19 20:02:01 UTC (rev 178661)
+++ trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2015-01-19 20:03:00 UTC (rev 178662)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">     &quot;Object.prototype&quot;: &quot;['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', '__proto__', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']&quot;,
</span><span class="cx">     &quot;Function&quot;: &quot;['length', 'name', 'prototype']&quot;,
</span><span class="cx">     &quot;Function.prototype&quot;: &quot;['apply', 'bind', 'call', 'constructor', 'length', 'name', 'toString']&quot;,
</span><del>-    &quot;Array&quot;: &quot;['isArray', 'length', 'name', 'prototype']&quot;,
</del><ins>+    &quot;Array&quot;: &quot;['isArray', 'length', 'name', 'of', 'prototype']&quot;,
</ins><span class="cx">     &quot;Array.prototype&quot;: &quot;['concat', 'constructor', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'forEach', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift']&quot;,
</span><span class="cx">     &quot;String&quot;: &quot;['fromCharCode', 'length', 'name', 'prototype']&quot;,
</span><span class="cx">     &quot;String.prototype&quot;: &quot;['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', 'valueOf']&quot;,
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrayofjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/array-of.js (0 => 178662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/array-of.js                                (rev 0)
+++ trunk/LayoutTests/js/script-tests/array-of.js        2015-01-19 20:03:00 UTC (rev 178662)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+description(&quot;Tests for Array.of&quot;);
+
+shouldBe(&quot;Array.of(1)&quot;, &quot;[1]&quot;);
+shouldBe(&quot;Array.of(1, 2)&quot;, &quot;[1, 2]&quot;);
+shouldBe(&quot;Array.of(1, 2, 3)&quot;, &quot;[1, 2, 3]&quot;);
+
+shouldBe(&quot;Array.of()&quot;, &quot;[]&quot;);
+shouldBe(&quot;Array.of(undefined)&quot;, &quot;[undefined]&quot;);
+shouldBe(&quot;Array.of('hello')&quot;, &quot;['hello']&quot;);
+
+debug(&quot;Construct nested Array with Array.of(Array.of(1, 2, 3), Array.of(4, 5, 6, 7, 8)).&quot;);
+var x = Array.of(Array.of(1, 2, 3), Array.of(4, 5, 6, 7, 8));
+shouldBe(&quot;x.length&quot;, &quot;2&quot;);
+shouldBe(&quot;x[0].length&quot;, &quot;3&quot;);
+shouldBe(&quot;x[1].length&quot;, &quot;5&quot;);
+
+debug(&quot;Check that a setter isn't called.&quot;);
+
+Array.prototype.__defineSetter__(&quot;0&quot;, function (value) {
+    throw new Error(&quot;This should not be called.&quot;);
+});
+
+shouldNotThrow(&quot;Array.of(1, 2, 3)&quot;);
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/js/script-tests/array-of.js
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (178661 => 178662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-01-19 20:02:01 UTC (rev 178661)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-01-19 20:03:00 UTC (rev 178662)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-01-18  Dean Jackson  &lt;dino@apple.com&gt;
+
+        ES6: Support Array.of construction
+        https://bugs.webkit.org/show_bug.cgi?id=140605
+        &lt;rdar://problem/19513655&gt;
+
+        Reviewed by Geoffrey Garen.
+
+        Add and implementation of Array.of, described in 22.1.2.3 of the ES6
+        specification (15 Jan 2015). The Array.of() method creates a new Array
+        instance with a variable number of arguments, regardless of number or type
+        of the arguments.
+
+        * runtime/ArrayConstructor.cpp:
+        (JSC::arrayConstructorOf): Create a new empty Array, then iterate
+        over the arguments, setting them to the appropriate index.
+
</ins><span class="cx"> 2015-01-19  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [SVG -&gt; OTF Converter] Flip the switch on
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeArrayConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp (178661 => 178662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp        2015-01-19 20:02:01 UTC (rev 178661)
+++ trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp        2015-01-19 20:03:00 UTC (rev 178662)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*);
</span><ins>+static EncodedJSValue JSC_HOST_CALL arrayConstructorOf(ExecState*);
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -51,6 +52,7 @@
</span><span class="cx"> /* Source for ArrayConstructor.lut.h
</span><span class="cx"> @begin arrayConstructorTable
</span><span class="cx">   isArray   arrayConstructorIsArray     DontEnum|Function 1
</span><ins>+  of        arrayConstructorOf          DontEnum|Function 0
</ins><span class="cx"> @end
</span><span class="cx"> */
</span><span class="cx"> 
</span><span class="lines">@@ -126,4 +128,17 @@
</span><span class="cx">     return JSValue::encode(jsBoolean(exec-&gt;argument(0).inherits(JSArray::info())));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+EncodedJSValue JSC_HOST_CALL arrayConstructorOf(ExecState* exec)
+{
+    ArgList args(exec);
+    size_t length = args.size();
+
+    JSArray* result = constructEmptyArray(exec, nullptr, length);
+
+    for (unsigned i = 0; i &lt; length; i++)
+        result-&gt;putDirectIndex(exec, i, args.at(i));
+
+    return JSValue::encode(result);
+}
+
</ins><span class="cx"> } // namespace JSC
</span></span></pre>
</div>
</div>

</body>
</html>