<!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
<rdar://problem/19513655>
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 <dino@apple.com>
+
+ ES6: Support Array.of construction
+ https://bugs.webkit.org/show_bug.cgi?id=140605
+ <rdar://problem/19513655>
+
+ 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 <adachan@apple.com>
</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 "PASS" messages, followed by "TEST COMPLETE".
+
+
+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>+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/array-of.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</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"> "Object.prototype": "['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', '__proto__', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']",
</span><span class="cx"> "Function": "['length', 'name', 'prototype']",
</span><span class="cx"> "Function.prototype": "['apply', 'bind', 'call', 'constructor', 'length', 'name', 'toString']",
</span><del>- "Array": "['isArray', 'length', 'name', 'prototype']",
</del><ins>+ "Array": "['isArray', 'length', 'name', 'of', 'prototype']",
</ins><span class="cx"> "Array.prototype": "['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"> "String": "['fromCharCode', 'length', 'name', 'prototype']",
</span><span class="cx"> "String.prototype": "['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="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("Tests for Array.of");
+
+shouldBe("Array.of(1)", "[1]");
+shouldBe("Array.of(1, 2)", "[1, 2]");
+shouldBe("Array.of(1, 2, 3)", "[1, 2, 3]");
+
+shouldBe("Array.of()", "[]");
+shouldBe("Array.of(undefined)", "[undefined]");
+shouldBe("Array.of('hello')", "['hello']");
+
+debug("Construct nested Array with Array.of(Array.of(1, 2, 3), Array.of(4, 5, 6, 7, 8)).");
+var x = Array.of(Array.of(1, 2, 3), Array.of(4, 5, 6, 7, 8));
+shouldBe("x.length", "2");
+shouldBe("x[0].length", "3");
+shouldBe("x[1].length", "5");
+
+debug("Check that a setter isn't called.");
+
+Array.prototype.__defineSetter__("0", function (value) {
+ throw new Error("This should not be called.");
+});
+
+shouldNotThrow("Array.of(1, 2, 3)");
+
</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 <dino@apple.com>
+
+ ES6: Support Array.of construction
+ https://bugs.webkit.org/show_bug.cgi?id=140605
+ <rdar://problem/19513655>
+
+ 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 <mmaxfield@apple.com>
</span><span class="cx">
</span><span class="cx"> [SVG -> 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->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 < length; i++)
+ result->putDirectIndex(exec, i, args.at(i));
+
+ return JSValue::encode(result);
+}
+
</ins><span class="cx"> } // namespace JSC
</span></span></pre>
</div>
</div>
</body>
</html>