Title: [203263] trunk
Revision
203263
Author
sbar...@apple.com
Date
2016-07-14 19:11:42 -0700 (Thu, 14 Jul 2016)

Log Message

It should be a syntax error to have a 'use strict' directive inside a function that has a non-simple parameter list
https://bugs.webkit.org/show_bug.cgi?id=159790
<rdar://problem/27171636>

Reviewed by Geoffrey Garen.

Source/_javascript_Core:

Is is a syntax error for a function's parameter list to be non-simple
and for the function to also contain a 'use strict' directive.

See section 14.2.1 of the spec:
https://tc39.github.io/ecma262/#sec-arrow-function-definitions-static-semantics-early-errors

* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseSourceElements):
(JSC::Parser<LexerType>::parseFormalParameters):
* parser/Parser.h:
(JSC::Scope::Scope):
(JSC::Scope::strictMode):
(JSC::Scope::isValidStrictMode):
(JSC::Scope::shadowsArguments):
(JSC::Scope::setHasNonSimpleParameterList):
(JSC::Scope::hasNonSimpleParameterList):
(JSC::Scope::copyCapturedVariablesToVector):

LayoutTests:

* js/parser-syntax-check-expected.txt:
* js/script-tests/parser-syntax-check.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203262 => 203263)


--- trunk/LayoutTests/ChangeLog	2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/LayoutTests/ChangeLog	2016-07-15 02:11:42 UTC (rev 203263)
@@ -1,3 +1,14 @@
+2016-07-14  Saam Barati  <sbar...@apple.com>
+
+        It should be a syntax error to have a 'use strict' directive inside a function that has a non-simple parameter list
+        https://bugs.webkit.org/show_bug.cgi?id=159790
+        <rdar://problem/27171636>
+
+        Reviewed by Geoffrey Garen.
+
+        * js/parser-syntax-check-expected.txt:
+        * js/script-tests/parser-syntax-check.js:
+
 2016-07-14  Simon Fraser  <simon.fra...@apple.com>
 
         [iOS WK2] When scrolling apple.com/music on iPad Pro in landscape, left-hand tiles appear first

Modified: trunk/LayoutTests/js/parser-syntax-check-expected.txt (203262 => 203263)


--- trunk/LayoutTests/js/parser-syntax-check-expected.txt	2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/LayoutTests/js/parser-syntax-check-expected.txt	2016-07-15 02:11:42 UTC (rev 203263)
@@ -1156,6 +1156,99 @@
 PASS Invalid: "function f() { 'use strict'; function foo(...yield) { } }"
 PASS Invalid: "function foo(...if) { }"
 PASS Invalid: "function f() { function foo(...if) { } }"
+non-simple parameter list
+PASS Invalid: "function foo(...restParam) { 'use strict'; }"
+PASS Invalid: "function f() { function foo(...restParam) { 'use strict'; } }"
+PASS Invalid: "function foo(...restParam) { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { function foo(...restParam) { 'a'; 'use strict'; } }"
+PASS Invalid: "function foo({x}) { 'use strict'; }"
+PASS Invalid: "function f() { function foo({x}) { 'use strict'; } }"
+PASS Invalid: "function foo({x}) { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { function foo({x}) { 'a'; 'use strict'; } }"
+PASS Invalid: "function foo(a = 20) { 'use strict'; }"
+PASS Invalid: "function f() { function foo(a = 20) { 'use strict'; } }"
+PASS Invalid: "function foo(a = 20) { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { function foo(a = 20) { 'a'; 'use strict'; } }"
+PASS Invalid: "function foo({a} = 20) { 'use strict'; }"
+PASS Invalid: "function f() { function foo({a} = 20) { 'use strict'; } }"
+PASS Invalid: "function foo({a} = 20) { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { function foo({a} = 20) { 'a'; 'use strict'; } }"
+PASS Invalid: "function foo([a]) { 'use strict'; }"
+PASS Invalid: "function f() { function foo([a]) { 'use strict'; } }"
+PASS Invalid: "function foo([a]) { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { function foo([a]) { 'a'; 'use strict'; } }"
+PASS Invalid: "function foo(foo, bar, a = 25) { 'use strict'; }"
+PASS Invalid: "function f() { function foo(foo, bar, a = 25) { 'use strict'; } }"
+PASS Invalid: "function foo(foo, bar, a = 25) { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { function foo(foo, bar, a = 25) { 'a'; 'use strict'; } }"
+PASS Invalid: "function foo(foo, bar, baz, ...rest) { 'use strict'; }"
+PASS Invalid: "function f() { function foo(foo, bar, baz, ...rest) { 'use strict'; } }"
+PASS Invalid: "function foo(foo, bar, baz, ...rest) { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { function foo(foo, bar, baz, ...rest) { 'a'; 'use strict'; } }"
+PASS Invalid: "function foo(a = function() { }) { 'use strict'; a(); }"
+PASS Invalid: "function f() { function foo(a = function() { }) { 'use strict'; a(); } }"
+PASS Invalid: "function foo(a = function() { }) { 'a'; 'use strict'; a(); }"
+PASS Invalid: "function f() { function foo(a = function() { }) { 'a'; 'use strict'; a(); } }"
+PASS Invalid: "let foo = (...restParam) => { 'use strict'; }"
+PASS Invalid: "function f() { let foo = (...restParam) => { 'use strict'; } }"
+PASS Invalid: "let foo = (...restParam) => { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { let foo = (...restParam) => { 'a'; 'use strict'; } }"
+PASS Invalid: "let foo = ({x}) => { 'use strict'; }"
+PASS Invalid: "function f() { let foo = ({x}) => { 'use strict'; } }"
+PASS Invalid: "let foo = ({x}) => { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { let foo = ({x}) => { 'a'; 'use strict'; } }"
+PASS Invalid: "let foo = (a = 20) => { 'use strict'; }"
+PASS Invalid: "function f() { let foo = (a = 20) => { 'use strict'; } }"
+PASS Invalid: "let foo = (a = 20) => { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { let foo = (a = 20) => { 'a'; 'use strict'; } }"
+PASS Invalid: "let foo = ({a} = 20) => { 'use strict'; }"
+PASS Invalid: "function f() { let foo = ({a} = 20) => { 'use strict'; } }"
+PASS Invalid: "let foo = ({a} = 20) => { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { let foo = ({a} = 20) => { 'a'; 'use strict'; } }"
+PASS Invalid: "let foo = ([a]) => { 'use strict'; }"
+PASS Invalid: "function f() { let foo = ([a]) => { 'use strict'; } }"
+PASS Invalid: "let foo = ([a]) => { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { let foo = ([a]) => { 'a'; 'use strict'; } }"
+PASS Invalid: "let foo = (foo, bar, a = 25) => { 'use strict'; }"
+PASS Invalid: "function f() { let foo = (foo, bar, a = 25) => { 'use strict'; } }"
+PASS Invalid: "let foo = (foo, bar, a = 25) => { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { let foo = (foo, bar, a = 25) => { 'a'; 'use strict'; } }"
+PASS Invalid: "let foo = (foo, bar, baz, ...rest) => { 'use strict'; }"
+PASS Invalid: "function f() { let foo = (foo, bar, baz, ...rest) => { 'use strict'; } }"
+PASS Invalid: "let foo = (foo, bar, baz, ...rest) => { 'a'; 'use strict'; }"
+PASS Invalid: "function f() { let foo = (foo, bar, baz, ...rest) => { 'a'; 'use strict'; } }"
+PASS Invalid: "let foo = (a = function() { }) => { 'use strict'; a(); }"
+PASS Invalid: "function f() { let foo = (a = function() { }) => { 'use strict'; a(); } }"
+PASS Invalid: "let foo = (a = function() { }) => { 'a'; 'use strict'; a(); }"
+PASS Invalid: "function f() { let foo = (a = function() { }) => { 'a'; 'use strict'; a(); } }"
+PASS Valid:   "function outer() { 'use strict'; function foo(...restParam) {  } }"
+PASS Valid:   "function f() { function outer() { 'use strict'; function foo(...restParam) {  } } }"
+PASS Valid:   "function outer() { 'use strict'; function foo(a,b,c,...restParam) {  } }"
+PASS Valid:   "function f() { function outer() { 'use strict'; function foo(a,b,c,...restParam) {  } } }"
+PASS Valid:   "function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  } }"
+PASS Valid:   "function f() { function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  } } }"
+PASS Valid:   "function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) {  } }"
+PASS Valid:   "function f() { function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) {  } } }"
+PASS Valid:   "function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) {  } }"
+PASS Valid:   "function f() { function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) {  } } }"
+PASS Valid:   "function outer() { 'use strict'; function foo(a = 20) {  } }"
+PASS Valid:   "function f() { function outer() { 'use strict'; function foo(a = 20) {  } } }"
+PASS Valid:   "function outer() { 'use strict'; function foo(a,b,c,{d} = 20) {  } }"
+PASS Valid:   "function f() { function outer() { 'use strict'; function foo(a,b,c,{d} = 20) {  } } }"
+PASS Invalid: "function outer() { 'use strict'; function foo(...restParam) { 'use strict';  } }"
+PASS Invalid: "function f() { function outer() { 'use strict'; function foo(...restParam) { 'use strict';  } } }"
+PASS Invalid: "function outer() { 'use strict'; function foo(a,b,c,...restParam) {  'use strict'; } }"
+PASS Invalid: "function f() { function outer() { 'use strict'; function foo(a,b,c,...restParam) {  'use strict'; } } }"
+PASS Invalid: "function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  'use strict'; } }"
+PASS Invalid: "function f() { function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  'use strict'; } } }"
+PASS Invalid: "function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) { 'use strict'; } }"
+PASS Invalid: "function f() { function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) { 'use strict'; } } }"
+PASS Invalid: "function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) { 'use strict'; } }"
+PASS Invalid: "function f() { function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) { 'use strict'; } } }"
+PASS Invalid: "function outer() { 'use strict'; function foo(a = 20) {  'use strict';} }"
+PASS Invalid: "function f() { function outer() { 'use strict'; function foo(a = 20) {  'use strict';} } }"
+PASS Invalid: "function outer() { 'use strict'; function foo(a,b,c,{d} = 20) { 'use strict'; } }"
+PASS Invalid: "function f() { function outer() { 'use strict'; function foo(a,b,c,{d} = 20) { 'use strict'; } } }"
 Arrow function
 PASS Valid:   "var x = (x) => x;"
 PASS Valid:   "function f() { var x = (x) => x; }"

Modified: trunk/LayoutTests/js/script-tests/parser-syntax-check.js (203262 => 203263)


--- trunk/LayoutTests/js/script-tests/parser-syntax-check.js	2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/LayoutTests/js/script-tests/parser-syntax-check.js	2016-07-15 02:11:42 UTC (rev 203263)
@@ -688,6 +688,54 @@
 invalid("'use strict'; function foo(...yield) { }");
 invalid("function foo(...if) { }");
 
+debug("non-simple parameter list")
+invalid("function foo(...restParam) { 'use strict'; }");
+invalid("function foo(...restParam) { 'a'; 'use strict'; }");
+invalid("function foo({x}) { 'use strict'; }");
+invalid("function foo({x}) { 'a'; 'use strict'; }");
+invalid("function foo(a = 20) { 'use strict'; }");
+invalid("function foo(a = 20) { 'a'; 'use strict'; }");
+invalid("function foo({a} = 20) { 'use strict'; }");
+invalid("function foo({a} = 20) { 'a'; 'use strict'; }");
+invalid("function foo([a]) { 'use strict'; }");
+invalid("function foo([a]) { 'a'; 'use strict'; }");
+invalid("function foo(foo, bar, a = 25) { 'use strict'; }");
+invalid("function foo(foo, bar, a = 25) { 'a'; 'use strict'; }");
+invalid("function foo(foo, bar, baz, ...rest) { 'use strict'; }");
+invalid("function foo(foo, bar, baz, ...rest) { 'a'; 'use strict'; }");
+invalid("function foo(a = function() { }) { 'use strict'; a(); }");
+invalid("function foo(a = function() { }) { 'a'; 'use strict'; a(); }");
+invalid("let foo = (...restParam) => { 'use strict'; }");
+invalid("let foo = (...restParam) => { 'a'; 'use strict'; }");
+invalid("let foo = ({x}) => { 'use strict'; }");
+invalid("let foo = ({x}) => { 'a'; 'use strict'; }");
+invalid("let foo = (a = 20) => { 'use strict'; }");
+invalid("let foo = (a = 20) => { 'a'; 'use strict'; }");
+invalid("let foo = ({a} = 20) => { 'use strict'; }");
+invalid("let foo = ({a} = 20) => { 'a'; 'use strict'; }");
+invalid("let foo = ([a]) => { 'use strict'; }");
+invalid("let foo = ([a]) => { 'a'; 'use strict'; }");
+invalid("let foo = (foo, bar, a = 25) => { 'use strict'; }");
+invalid("let foo = (foo, bar, a = 25) => { 'a'; 'use strict'; }");
+invalid("let foo = (foo, bar, baz, ...rest) => { 'use strict'; }");
+invalid("let foo = (foo, bar, baz, ...rest) => { 'a'; 'use strict'; }");
+invalid("let foo = (a = function() { }) => { 'use strict'; a(); }");
+invalid("let foo = (a = function() { }) => { 'a'; 'use strict'; a(); }");
+valid("function outer() { 'use strict'; function foo(...restParam) {  } }");
+valid("function outer() { 'use strict'; function foo(a,b,c,...restParam) {  } }");
+valid("function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  } }");
+valid("function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) {  } }");
+valid("function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) {  } }");
+valid("function outer() { 'use strict'; function foo(a = 20) {  } }");
+valid("function outer() { 'use strict'; function foo(a,b,c,{d} = 20) {  } }");
+invalid("function outer() { 'use strict'; function foo(...restParam) { 'use strict';  } }");
+invalid("function outer() { 'use strict'; function foo(a,b,c,...restParam) {  'use strict'; } }");
+invalid("function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  'use strict'; } }");
+invalid("function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) { 'use strict'; } }");
+invalid("function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) { 'use strict'; } }");
+invalid("function outer() { 'use strict'; function foo(a = 20) {  'use strict';} }");
+invalid("function outer() { 'use strict'; function foo(a,b,c,{d} = 20) { 'use strict'; } }");
+
 debug("Arrow function");
 valid("var x = (x) => x;");
 valid("var x = (x, y, z) => x;");

Modified: trunk/Source/_javascript_Core/ChangeLog (203262 => 203263)


--- trunk/Source/_javascript_Core/ChangeLog	2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-07-15 02:11:42 UTC (rev 203263)
@@ -1,3 +1,29 @@
+2016-07-14  Saam Barati  <sbar...@apple.com>
+
+        It should be a syntax error to have a 'use strict' directive inside a function that has a non-simple parameter list
+        https://bugs.webkit.org/show_bug.cgi?id=159790
+        <rdar://problem/27171636>
+
+        Reviewed by Geoffrey Garen.
+
+        Is is a syntax error for a function's parameter list to be non-simple
+        and for the function to also contain a 'use strict' directive.
+
+        See section 14.2.1 of the spec:
+        https://tc39.github.io/ecma262/#sec-arrow-function-definitions-static-semantics-early-errors
+
+        * parser/Parser.cpp:
+        (JSC::Parser<LexerType>::parseSourceElements):
+        (JSC::Parser<LexerType>::parseFormalParameters):
+        * parser/Parser.h:
+        (JSC::Scope::Scope):
+        (JSC::Scope::strictMode):
+        (JSC::Scope::isValidStrictMode):
+        (JSC::Scope::shadowsArguments):
+        (JSC::Scope::setHasNonSimpleParameterList):
+        (JSC::Scope::hasNonSimpleParameterList):
+        (JSC::Scope::copyCapturedVariablesToVector):
+
 2016-07-14  Geoffrey Garen  <gga...@apple.com>
 
         ASSERTION FAILED: : this != replacement()

Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (203262 => 203263)


--- trunk/Source/_javascript_Core/parser/Parser.cpp	2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp	2016-07-15 02:11:42 UTC (rev 203263)
@@ -420,6 +420,7 @@
                             semanticFail("Cannot declare a variable named 'arguments' in strict mode");
                         if (hasDeclaredVariable(m_vm->propertyNames->eval))
                             semanticFail("Cannot declare a variable named 'eval' in strict mode");
+                        semanticFailIfTrue(currentScope()->hasNonSimpleParameterList(), "'use strict' directive not allowed inside a function with a non-simple parameter list");
                         semanticFailIfFalse(isValidStrictMode(), "Invalid parameters or function name in strict mode");
                     }
                     // Since strict mode is changed, restoring lexer state by calling next() may cause errors.
@@ -1775,6 +1776,8 @@
             defaultValue = parseDefaultValueForDestructuringPattern(context);
         propagateError();
         failIfDuplicateIfViolation();
+        if (isRestParameter || defaultValue || hasDestructuringPattern)
+            currentScope()->setHasNonSimpleParameterList();
         context.appendParameter(list, parameter, defaultValue);
         if (!isRestParameter)
             parameterCount++;

Modified: trunk/Source/_javascript_Core/parser/Parser.h (203262 => 203263)


--- trunk/Source/_javascript_Core/parser/Parser.h	2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/Source/_javascript_Core/parser/Parser.h	2016-07-15 02:11:42 UTC (rev 203263)
@@ -173,6 +173,7 @@
         , m_isValidStrictMode(true)
         , m_hasArguments(false)
         , m_isEvalContext(false)
+        , m_hasNonSimpleParameterList(false)
         , m_evalContextType(EvalContextType::None)
         , m_constructorKind(static_cast<unsigned>(ConstructorKind::None))
         , m_expectedSuperBinding(static_cast<unsigned>(SuperBinding::NotNeeded))
@@ -203,6 +204,7 @@
         , m_isValidStrictMode(other.m_isValidStrictMode)
         , m_hasArguments(other.m_hasArguments)
         , m_isEvalContext(other.m_isEvalContext)
+        , m_hasNonSimpleParameterList(other.m_hasNonSimpleParameterList)
         , m_constructorKind(other.m_constructorKind)
         , m_expectedSuperBinding(other.m_expectedSuperBinding)
         , m_loopDepth(other.m_loopDepth)
@@ -644,6 +646,12 @@
     bool strictMode() const { return m_strictMode; }
     bool isValidStrictMode() const { return m_isValidStrictMode; }
     bool shadowsArguments() const { return m_shadowsArguments; }
+    void setHasNonSimpleParameterList()
+    {
+        m_isValidStrictMode = false;
+        m_hasNonSimpleParameterList = true;
+    }
+    bool hasNonSimpleParameterList() const { return m_hasNonSimpleParameterList; }
 
     void copyCapturedVariablesToVector(const UniquedStringImplPtrSet& usedVariables, Vector<UniquedStringImpl*, 8>& vector)
     {
@@ -747,6 +755,7 @@
     bool m_isValidStrictMode;
     bool m_hasArguments;
     bool m_isEvalContext;
+    bool m_hasNonSimpleParameterList;
     EvalContextType m_evalContextType;
     unsigned m_constructorKind;
     unsigned m_expectedSuperBinding;

Modified: trunk/Source/_javascript_Core/tests/stress/es6-default-parameters.js (203262 => 203263)


--- trunk/Source/_javascript_Core/tests/stress/es6-default-parameters.js	2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/Source/_javascript_Core/tests/stress/es6-default-parameters.js	2016-07-15 02:11:42 UTC (rev 203263)
@@ -79,7 +79,6 @@
 shouldThrow(tricky);
 
 function strict(x, y = x) {
-    'use strict';
     assert(x === y);
 }
 strict(20);
@@ -146,24 +145,30 @@
 }
 augmentsArguments3();
 
-function augmentsArguments4(x = 10) {
+function augmentsArguments4(x) {
     "use strict";
-    assert(x === 10);
+    function inner(x = 10) {
+        assert(x === 10);
 
-    assert(arguments[0] === undefined);
-    x = 20;
-    assert(arguments[0] === undefined);
+        assert(arguments[0] === undefined);
+        x = 20;
+        assert(arguments[0] === undefined);
+    }
+    inner(x);
 }
 augmentsArguments4();
 augmentsArguments4(undefined);
 
-function augmentsArguments5(x = 10) {
+function augmentsArguments5(x) {
     "use strict";
-    assert(x === 20);
+    function inner(x = 10) {
+        assert(x === 20);
 
-    assert(arguments[0] === 20);
-    x = 20;
-    assert(arguments[0] === 20);
+        assert(arguments[0] === 20);
+        x = 20;
+        assert(arguments[0] === 20);
+    }
+    inner(x);
 }
 augmentsArguments5(20);
 

Modified: trunk/Source/_javascript_Core/tests/stress/reflect-set.js (203262 => 203263)


--- trunk/Source/_javascript_Core/tests/stress/reflect-set.js	2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/Source/_javascript_Core/tests/stress/reflect-set.js	2016-07-15 02:11:42 UTC (rev 203263)
@@ -571,126 +571,128 @@
     [ Int32Array, 4 ],
     [ Float32Array, 4 ],
     [ Float64Array, 8 ],
-].forEach(function typedArrayCase([ TypedArray, bytesPerElement ]) {
+].forEach((function() {
     'use strict';
-    var object = new TypedArray(64);
-    shouldBe(Reflect.get(object, 'hello'), undefined);
-    shouldBe(Reflect.set(object, 'hello', 42), true);
-    shouldBe(Reflect.get(object, 'hello'), 42);
-    shouldBe(Reflect.get(object, 0), 0);
-    shouldBe(Reflect.set(object, 0, 42), true);
-    shouldBe(Reflect.get(object, 0), 42);
-    shouldBe(Reflect.get(object, symbol), undefined);
-    shouldBe(Reflect.set(object, symbol, 42), true);
-    shouldBe(Reflect.get(object, symbol), 42);
-    object[1000000] = 'Hello';
-    shouldBe(Reflect.set(object, 0, 50), true);
-    shouldBe(Reflect.get(object, 0), 50);
+    return function typedArrayCase([ TypedArray, bytesPerElement ]) {
+        var object = new TypedArray(64);
+        shouldBe(Reflect.get(object, 'hello'), undefined);
+        shouldBe(Reflect.set(object, 'hello', 42), true);
+        shouldBe(Reflect.get(object, 'hello'), 42);
+        shouldBe(Reflect.get(object, 0), 0);
+        shouldBe(Reflect.set(object, 0, 42), true);
+        shouldBe(Reflect.get(object, 0), 42);
+        shouldBe(Reflect.get(object, symbol), undefined);
+        shouldBe(Reflect.set(object, symbol, 42), true);
+        shouldBe(Reflect.get(object, symbol), 42);
+        object[1000000] = 'Hello';
+        shouldBe(Reflect.set(object, 0, 50), true);
+        shouldBe(Reflect.get(object, 0), 50);
 
-    var object = new TypedArray(64);
-    shouldBe(Reflect.defineProperty(object, 'hello', {
-        value: 'Cocoa',
-        writable: false
-    }), true);
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.set(object, 'hello', 42), false);
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.defineProperty(object, 0, {
-        value: 'Cocoa',
-        writable: false
-    }), false);
-    shouldBe(Reflect.get(object, 0), 0);
-    shouldBe(Reflect.set(object, 0, 42), true);
-    shouldBe(Reflect.get(object, 0), 42);
-    shouldBe(object.length, 64);
-    shouldBe(Reflect.defineProperty(object, symbol, {
-        value: 'Cocoa',
-        writable: false
-    }), true);
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
-    shouldBe(Reflect.set(object, symbol, 42), false);
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
+        var object = new TypedArray(64);
+        shouldBe(Reflect.defineProperty(object, 'hello', {
+            value: 'Cocoa',
+            writable: false
+        }), true);
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.set(object, 'hello', 42), false);
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.defineProperty(object, 0, {
+            value: 'Cocoa',
+            writable: false
+        }), false);
+        shouldBe(Reflect.get(object, 0), 0);
+        shouldBe(Reflect.set(object, 0, 42), true);
+        shouldBe(Reflect.get(object, 0), 42);
+        shouldBe(object.length, 64);
+        shouldBe(Reflect.defineProperty(object, symbol, {
+            value: 'Cocoa',
+            writable: false
+        }), true);
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
+        shouldBe(Reflect.set(object, symbol, 42), false);
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
 
-    var object = new TypedArray(64);
-    shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
-    shouldBe(Reflect.set(object, 'byteLength', 'Cappuccino'), false);
-    shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
+        var object = new TypedArray(64);
+        shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
+        shouldBe(Reflect.set(object, 'byteLength', 'Cappuccino'), false);
+        shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
 
-    var object = new TypedArray(64);
-    shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
-    shouldBe(Reflect.set(object, 'byteLength', 2000), false);
-    shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
+        var object = new TypedArray(64);
+        shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
+        shouldBe(Reflect.set(object, 'byteLength', 2000), false);
+        shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
 
-    var object = new TypedArray(64);
-    shouldBe(Reflect.defineProperty(object, 'hello', {
-        get() {
-            return 'Cocoa';
-        },
-        set() {
-        }
-    }), true);
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.set(object, 'hello', 42), true);  // Return true since the setter exists.
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.defineProperty(object, 0, {
-        get() {
-            return 'Cocoa';
-        },
-        set() {
-        }
-    }), false);
-    shouldBe(Reflect.get(object, 0), 0);
-    shouldBe(Reflect.set(object, 0, 42), true);  // Return true since the setter exists.
-    shouldBe(Reflect.get(object, 0), 42);
-    shouldBe(Reflect.defineProperty(object, symbol, {
-        get() {
-            return 'Cocoa';
-        },
-        set() {
-        }
-    }), true);
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
-    shouldBe(Reflect.set(object, symbol, 42), true);  // Return true since the setter exists.
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
+        var object = new TypedArray(64);
+        shouldBe(Reflect.defineProperty(object, 'hello', {
+            get() {
+                return 'Cocoa';
+            },
+            set() {
+            }
+        }), true);
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.set(object, 'hello', 42), true);  // Return true since the setter exists.
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.defineProperty(object, 0, {
+            get() {
+                return 'Cocoa';
+            },
+            set() {
+            }
+        }), false);
+        shouldBe(Reflect.get(object, 0), 0);
+        shouldBe(Reflect.set(object, 0, 42), true);  // Return true since the setter exists.
+        shouldBe(Reflect.get(object, 0), 42);
+        shouldBe(Reflect.defineProperty(object, symbol, {
+            get() {
+                return 'Cocoa';
+            },
+            set() {
+            }
+        }), true);
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
+        shouldBe(Reflect.set(object, symbol, 42), true);  // Return true since the setter exists.
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
 
-    var object = new TypedArray(64);
-    shouldBe(Reflect.defineProperty(object, 'hello', {
-        get() {
-            return 'Cocoa';
-        }
-    }), true);
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.set(object, 'hello', 42), false);
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.defineProperty(object, 0, {
-        get() {
-            return 'Cocoa';
-        }
-    }), false);
-    shouldBe(Reflect.get(object, 0), 0);
-    shouldBe(Reflect.set(object, 0, 42), true);
-    shouldBe(Reflect.get(object, 0), 42);
-    shouldBe(Reflect.defineProperty(object, symbol, {
-        get() {
-            return 'Cocoa';
-        }
-    }), true);
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
-    shouldBe(Reflect.set(object, symbol, 42), false);
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
+        var object = new TypedArray(64);
+        shouldBe(Reflect.defineProperty(object, 'hello', {
+            get() {
+                return 'Cocoa';
+            }
+        }), true);
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.set(object, 'hello', 42), false);
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.defineProperty(object, 0, {
+            get() {
+                return 'Cocoa';
+            }
+        }), false);
+        shouldBe(Reflect.get(object, 0), 0);
+        shouldBe(Reflect.set(object, 0, 42), true);
+        shouldBe(Reflect.get(object, 0), 42);
+        shouldBe(Reflect.defineProperty(object, symbol, {
+            get() {
+                return 'Cocoa';
+            }
+        }), true);
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
+        shouldBe(Reflect.set(object, symbol, 42), false);
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
 
-    receiverTest(new TypedArray(64), new TypedArray(64));
-    receiverTest(new TypedArray(64), {});
-    receiverTest({}, new TypedArray(64));
+        receiverTest(new TypedArray(64), new TypedArray(64));
+        receiverTest(new TypedArray(64), {});
+        receiverTest({}, new TypedArray(64));
 
-    var object = new TypedArray(64);
-    var receiver = {};
-    // The receiver is ignored when the property name is an indexed one.
-    // shouldBe(Reflect.set(object, 0, 42, receiver), true);
-    shouldBe(Reflect.set(object, 0, 42, receiver), true);
-    shouldBe(Reflect.get(object, 0), 42);
-    shouldBe(receiver.hasOwnProperty(0), false);
-});
+        var object = new TypedArray(64);
+        var receiver = {};
+        // The receiver is ignored when the property name is an indexed one.
+        // shouldBe(Reflect.set(object, 0, 42, receiver), true);
+        shouldBe(Reflect.set(object, 0, 42, receiver), true);
+        shouldBe(Reflect.get(object, 0), 42);
+        shouldBe(receiver.hasOwnProperty(0), false);
+    };
+})());
 
 
 (function argumentCase() {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to