summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_2017
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/ecma_2017')
-rw-r--r--js/src/tests/ecma_2017/AsyncFunctions/browser.js0
-rw-r--r--js/src/tests/ecma_2017/AsyncFunctions/cover-init-name-syntax.js65
-rw-r--r--js/src/tests/ecma_2017/AsyncFunctions/duplicate-__proto__.js22
-rw-r--r--js/src/tests/ecma_2017/AsyncFunctions/shell.js0
-rw-r--r--js/src/tests/ecma_2017/Expressions/browser.js0
-rw-r--r--js/src/tests/ecma_2017/Expressions/shell.js1
-rw-r--r--js/src/tests/ecma_2017/Expressions/trailing_comma_arguments.js85
-rw-r--r--js/src/tests/ecma_2017/Expressions/trailing_comma_arrow.js108
-rw-r--r--js/src/tests/ecma_2017/Expressions/trailing_comma_getter_setter.js88
-rw-r--r--js/src/tests/ecma_2017/Expressions/trailing_comma_parameters.js165
-rw-r--r--js/src/tests/ecma_2017/Statements/browser.js0
-rw-r--r--js/src/tests/ecma_2017/Statements/for-in-with-assignment-semantics.js46
-rw-r--r--js/src/tests/ecma_2017/Statements/for-in-with-assignment-syntax.js68
-rw-r--r--js/src/tests/ecma_2017/Statements/for-in-with-assignments.js82
-rw-r--r--js/src/tests/ecma_2017/Statements/shell.js1
-rw-r--r--js/src/tests/ecma_2017/Statements/trailing_comma_parameters.js92
-rw-r--r--js/src/tests/ecma_2017/browser.js0
-rw-r--r--js/src/tests/ecma_2017/shell.js1
18 files changed, 824 insertions, 0 deletions
diff --git a/js/src/tests/ecma_2017/AsyncFunctions/browser.js b/js/src/tests/ecma_2017/AsyncFunctions/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_2017/AsyncFunctions/browser.js
diff --git a/js/src/tests/ecma_2017/AsyncFunctions/cover-init-name-syntax.js b/js/src/tests/ecma_2017/AsyncFunctions/cover-init-name-syntax.js
new file mode 100644
index 000000000..cb7858a67
--- /dev/null
+++ b/js/src/tests/ecma_2017/AsyncFunctions/cover-init-name-syntax.js
@@ -0,0 +1,65 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// CoverInitName in async arrow parameters.
+async ({a = 1}) => {};
+async ({a = 1}, {b = 2}) => {};
+async ({a = 1}, {b = 2}, {c = 3}) => {};
+async ({a = 1} = {}, {b = 2}, {c = 3}) => {};
+async ({a = 1} = {}, {b = 2} = {}, {c = 3}) => {};
+async ({a = 1} = {}, {b = 2} = {}, {c = 3} = {}) => {};
+
+// CoverInitName nested in array destructuring.
+async ([{a = 0}]) => {};
+
+// CoverInitName nested in rest pattern.
+async ([...[{a = 0}]]) => {};
+
+// CoverInitName nested in object destructuring.
+async ({p: {a = 0}}) => {};
+
+// CoverInitName in CoverCallExpressionAndAsyncArrowHead, but not AsyncArrowHead.
+assertThrowsInstanceOf(() => eval(`
+ NotAsync({a = 1});
+`), SyntaxError);
+assertThrowsInstanceOf(() => eval(`
+ NotAsync({a = 1}, {b = 2}, {c = 3});
+`), SyntaxError);
+assertThrowsInstanceOf(() => eval(`
+ NotAsync({a = 1}, {b = 2}, {c = 3} = {});
+`), SyntaxError);
+assertThrowsInstanceOf(() => eval(`
+ NotAsync({a = 1}, {b = 2} = {}, {c = 3} = {});
+`), SyntaxError);
+
+// Starts with "async", but not called from AssignmentExpression.
+assertThrowsInstanceOf(() => eval(`
+ typeof async({a = 1});
+`), SyntaxError);
+assertThrowsInstanceOf(() => eval(`
+ typeof async({a = 1}, {b = 2}, {c = 3});
+`), SyntaxError);
+assertThrowsInstanceOf(() => eval(`
+ typeof async({a = 1}, {b = 2}, {c = 3} = {});
+`), SyntaxError);
+assertThrowsInstanceOf(() => eval(`
+ typeof async({a = 1}, {b = 2} = {}, {c = 3} = {});
+`), SyntaxError);
+
+// CoverInitName in CoverCallExpressionAndAsyncArrowHead, but not AsyncArrowHead.
+assertThrowsInstanceOf(() => eval(`
+ obj.async({a = 1});
+`), SyntaxError);
+assertThrowsInstanceOf(() => eval(`
+ obj.async({a = 1}, {b = 2}, {c = 3});
+`), SyntaxError);
+assertThrowsInstanceOf(() => eval(`
+ obj.async({a = 1}, {b = 2}, {c = 3} = {});
+`), SyntaxError);
+assertThrowsInstanceOf(() => eval(`
+ obj.async({a = 1}, {b = 2} = {}, {c = 3} = {});
+`), SyntaxError);
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/ecma_2017/AsyncFunctions/duplicate-__proto__.js b/js/src/tests/ecma_2017/AsyncFunctions/duplicate-__proto__.js
new file mode 100644
index 000000000..d60b05248
--- /dev/null
+++ b/js/src/tests/ecma_2017/AsyncFunctions/duplicate-__proto__.js
@@ -0,0 +1,22 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Async arrow function parameters.
+async ({__proto__: a, __proto__: b}) => {};
+
+// Async arrow function parameters with defaults (initially parsed as destructuring assignment).
+async ({__proto__: a, __proto__: b} = {}) => {};
+
+// Duplicate __proto__ in CoverCallExpressionAndAsyncArrowHead, but not AsyncArrowHead.
+assertThrowsInstanceOf(() => eval(`
+ NotAsync({__proto__: a, __proto__: b});
+`), SyntaxError);
+
+// Starts with "async", but not called from AssignmentExpression.
+assertThrowsInstanceOf(() => eval(`
+ typeof async({__proto__: a, __proto__: b});
+`), SyntaxError);
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/ecma_2017/AsyncFunctions/shell.js b/js/src/tests/ecma_2017/AsyncFunctions/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_2017/AsyncFunctions/shell.js
diff --git a/js/src/tests/ecma_2017/Expressions/browser.js b/js/src/tests/ecma_2017/Expressions/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_2017/Expressions/browser.js
diff --git a/js/src/tests/ecma_2017/Expressions/shell.js b/js/src/tests/ecma_2017/Expressions/shell.js
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/js/src/tests/ecma_2017/Expressions/shell.js
@@ -0,0 +1 @@
+
diff --git a/js/src/tests/ecma_2017/Expressions/trailing_comma_arguments.js b/js/src/tests/ecma_2017/Expressions/trailing_comma_arguments.js
new file mode 100644
index 000000000..612fd46a1
--- /dev/null
+++ b/js/src/tests/ecma_2017/Expressions/trailing_comma_arguments.js
@@ -0,0 +1,85 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Trailing comma in Arguments production.
+
+// 12.3 Left-Hand-Side Expressions
+// Arguments[Yield]:
+// ()
+// ( ArgumentList[?Yield] )
+// ( ArgumentList[?Yield] , )
+
+
+function argsLength() {
+ return {value: arguments.length};
+}
+function sum(...rest) {
+ return {value: rest.reduce((a, c) => a + c, 0)};
+}
+
+function call(f, argList) {
+ return eval(`(${f}(${argList})).value`);
+}
+
+function newCall(F, argList) {
+ return eval(`(new ${F}(${argList})).value`);
+}
+
+function superCall(superClass, argList) {
+ return eval(`(new class extends ${superClass} {
+ constructor() {
+ super(${argList});
+ }
+ }).value`);
+}
+
+// Ensure the correct number of arguments is passed.
+for (let type of [call, newCall, superCall]) {
+ let test = type.bind(null, "argsLength");
+
+ assertEq(test("10, "), 1);
+ assertEq(test("10, 20, "), 2);
+ assertEq(test("10, 20, 30, "), 3);
+ assertEq(test("10, 20, 30, 40, "), 4);
+
+ assertEq(test("...[10, 20], "), 2);
+ assertEq(test("...[10, 20], 30, "), 3);
+ assertEq(test("...[10, 20], ...[30], "), 3);
+}
+
+// Ensure the arguments themselves are passed correctly.
+for (let type of [call, newCall, superCall]) {
+ let test = type.bind(null, "sum");
+
+ assertEq(test("10, "), 10);
+ assertEq(test("10, 20, "), 30);
+ assertEq(test("10, 20, 30, "), 60);
+ assertEq(test("10, 20, 30, 40, "), 100);
+
+ assertEq(test("...[10, 20], "), 30);
+ assertEq(test("...[10, 20], 30, "), 60);
+ assertEq(test("...[10, 20], ...[30], "), 60);
+}
+
+// Error cases.
+for (let type of [call, newCall, superCall]) {
+ let test = type.bind(null, "f");
+
+ // Trailing comma in empty arguments list.
+ assertThrowsInstanceOf(() => test(","), SyntaxError);
+
+ // Leading comma.
+ assertThrowsInstanceOf(() => test(", a"), SyntaxError);
+ assertThrowsInstanceOf(() => test(", ...a"), SyntaxError);
+
+ // Multiple trailing comma.
+ assertThrowsInstanceOf(() => test("a, , "), SyntaxError);
+ assertThrowsInstanceOf(() => test("...a, , "), SyntaxError);
+
+ // Elision.
+ assertThrowsInstanceOf(() => test("a, , b"), SyntaxError);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/ecma_2017/Expressions/trailing_comma_arrow.js b/js/src/tests/ecma_2017/Expressions/trailing_comma_arrow.js
new file mode 100644
index 000000000..f36b476ef
--- /dev/null
+++ b/js/src/tests/ecma_2017/Expressions/trailing_comma_arrow.js
@@ -0,0 +1,108 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Trailing comma in CoverParenthesizedExpressionAndArrowParameterList production.
+
+// 12.2 Primary Expression
+// CoverParenthesizedExpressionAndArrowParameterList[Yield]:
+// ( Expression[In, ?Yield] )
+// ( Expression[In, ?Yield] , )
+// ()
+// ( ...BindingIdentifier[?Yield] )
+// ( Expression[In, ?Yield] , ...BindingIdentifier[?Yield] )
+
+
+function arrow(argList, parameters = "", returnExpr = "") {
+ return eval(`
+ let fun = (${argList}) => {
+ return ${returnExpr};
+ }
+ fun(${parameters});
+ `);
+}
+
+function arrowConcise(argList, parameters = "", returnExpr = "null") {
+ return eval(`
+ let fun = (${argList}) => ${returnExpr};
+ fun(${parameters});
+ `);
+}
+
+const tests = [
+ arrow,
+ arrowConcise,
+];
+
+// Ensure parameters are passed correctly.
+for (let test of tests) {
+ assertEq(test("a, ", "10", "a"), 10);
+ assertEq(test("a, b, ", "10, 20", "a + b"), 30);
+ assertEq(test("a = 30, ", "", "a"), 30);
+ assertEq(test("a = 30, b = 40, ", "", "a + b"), 70);
+
+ assertEq(test("[a], ", "[10]", "a"), 10);
+ assertEq(test("[a], [b], ", "[10], [20]", "a + b"), 30);
+ assertEq(test("[a] = [30], ", "", "a"), 30);
+ assertEq(test("[a] = [30], [b] = [40], ", "", "a + b"), 70);
+
+ assertEq(test("{a}, ", "{a: 10}", "a"), 10);
+ assertEq(test("{a}, {b}, ", "{a: 10}, {b: 20}", "a + b"), 30);
+ assertEq(test("{a} = {a: 30}, ", "", "a"), 30);
+ assertEq(test("{a} = {a: 30}, {b} = {b: 40}, ", "", "a + b"), 70);
+}
+
+// Ensure function length doesn't change.
+for (let test of tests) {
+ assertEq(test("a, ", "", "fun.length"), 1);
+ assertEq(test("a, b, ", "", "fun.length"), 2);
+
+ assertEq(test("[a], ", "[]", "fun.length"), 1);
+ assertEq(test("[a], [b], ", "[], []", "fun.length"), 2);
+
+ assertEq(test("{a}, ", "{}", "fun.length"), 1);
+ assertEq(test("{a}, {b}, ", "{}, {}", "fun.length"), 2);
+}
+
+for (let test of tests) {
+ // Trailing comma in empty parameters list.
+ assertThrowsInstanceOf(() => test(","), SyntaxError);
+
+ // Leading comma.
+ assertThrowsInstanceOf(() => test(", a"), SyntaxError);
+ assertThrowsInstanceOf(() => test(", ...a"), SyntaxError);
+
+ // Multiple trailing comma.
+ assertThrowsInstanceOf(() => test("a, , "), SyntaxError);
+ assertThrowsInstanceOf(() => test("a..., , "), SyntaxError);
+
+ // Trailing comma after rest parameter.
+ assertThrowsInstanceOf(() => test("...a, "), SyntaxError);
+ assertThrowsInstanceOf(() => test("a, ...b, "), SyntaxError);
+
+ // Elision.
+ assertThrowsInstanceOf(() => test("a, , b"), SyntaxError);
+}
+
+// Trailing comma in non-parenthesized arrow head.
+assertThrowsInstanceOf(() => eval("a, => {}"), SyntaxError);
+assertThrowsInstanceOf(() => eval("a, => null"), SyntaxError);
+
+// Parenthesized expression is not an arrow function expression.
+for (let trail of ["", ";", "\n => {}"]) {
+ assertThrowsInstanceOf(() => eval("(a,)" + trail), SyntaxError);
+ assertThrowsInstanceOf(() => eval("(a, b,)" + trail), SyntaxError);
+ assertThrowsInstanceOf(() => eval("(...a, )" + trail), SyntaxError);
+ assertThrowsInstanceOf(() => eval("(a, ...b, )" + trail), SyntaxError);
+ assertThrowsInstanceOf(() => eval("(a, , b)" + trail), SyntaxError);
+
+ assertThrowsInstanceOf(() => eval("(,)" + trail), SyntaxError);
+ assertThrowsInstanceOf(() => eval("(, a)" + trail), SyntaxError);
+ assertThrowsInstanceOf(() => eval("(, ...a)" + trail), SyntaxError);
+ assertThrowsInstanceOf(() => eval("(a, , )" + trail), SyntaxError);
+ assertThrowsInstanceOf(() => eval("(...a, , )" + trail), SyntaxError);
+}
+
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/ecma_2017/Expressions/trailing_comma_getter_setter.js b/js/src/tests/ecma_2017/Expressions/trailing_comma_getter_setter.js
new file mode 100644
index 000000000..258dd8df6
--- /dev/null
+++ b/js/src/tests/ecma_2017/Expressions/trailing_comma_getter_setter.js
@@ -0,0 +1,88 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Trailing comma is not allowed in getter and setter methods
+
+// 14.3 Method Definitions
+// MethodDefinition[Yield]:
+// get PropertyName[?Yield] () { FunctionBody[~Yield] }
+// set PropertyName[?Yield] ( PropertySetParameterList ) { FunctionBody[~Yield] }
+// PropertySetParameterList:
+// FormalParameter[~Yield]
+
+function objectGetter(argList) {
+ return eval(`({
+ get m(${argList}) {}
+ })`);
+}
+
+function objectSetter(argList) {
+ return eval(`({
+ set m(${argList}) {}
+ })`);
+}
+
+function classGetter(argList) {
+ return eval(`(class {
+ get m(${argList}) {}
+ })`);
+}
+
+function classStaticGetter(argList) {
+ return eval(`(class {
+ static get m(${argList}) {}
+ })`);
+}
+
+function classSetter(argList) {
+ return eval(`(class {
+ set m(${argList}) {}
+ })`);
+}
+
+function classStaticSetter(argList) {
+ return eval(`(class {
+ static set m(${argList}) {}
+ })`);
+}
+
+const tests = [
+ objectGetter,
+ objectSetter,
+ classGetter,
+ classStaticGetter,
+ classSetter,
+ classStaticSetter,
+];
+
+for (let test of tests) {
+ // Trailing comma.
+ assertThrowsInstanceOf(() => test("a, "), SyntaxError);
+ assertThrowsInstanceOf(() => test("[], "), SyntaxError);
+ assertThrowsInstanceOf(() => test("{}, "), SyntaxError);
+ assertThrowsInstanceOf(() => test("a = 0, "), SyntaxError);
+ assertThrowsInstanceOf(() => test("[] = [], "), SyntaxError);
+ assertThrowsInstanceOf(() => test("{} = {}, "), SyntaxError);
+
+ // Trailing comma in empty parameters list.
+ assertThrowsInstanceOf(() => test(","), SyntaxError);
+
+ // Leading comma.
+ assertThrowsInstanceOf(() => test(", a"), SyntaxError);
+ assertThrowsInstanceOf(() => test(", ...a"), SyntaxError);
+
+ // Multiple trailing comma.
+ assertThrowsInstanceOf(() => test("a, ,"), SyntaxError);
+ assertThrowsInstanceOf(() => test("a..., ,"), SyntaxError);
+
+ // Trailing comma after rest parameter.
+ assertThrowsInstanceOf(() => test("...a ,"), SyntaxError);
+ assertThrowsInstanceOf(() => test("a, ...b, "), SyntaxError);
+
+ // Elision.
+ assertThrowsInstanceOf(() => test("a, , b"), SyntaxError);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/ecma_2017/Expressions/trailing_comma_parameters.js b/js/src/tests/ecma_2017/Expressions/trailing_comma_parameters.js
new file mode 100644
index 000000000..d0e756b86
--- /dev/null
+++ b/js/src/tests/ecma_2017/Expressions/trailing_comma_parameters.js
@@ -0,0 +1,165 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Trailing comma in functions and methods.
+
+// 14.1 Function Definitions
+// FunctionExpression:
+// function BindingIdentifier[~Yield]opt ( FormalParameters[~Yield] ) { FunctionBody[~Yield] }
+
+// 14.3 Method Definitions
+// MethodDefinition[Yield]:
+// PropertyName[?Yield] ( UniqueFormalParameters[~Yield] ) { FunctionBody[~Yield] }
+// GeneratorMethod[?Yield]
+// PropertySetParameterList:
+// FormalParameter[~Yield]
+
+// 14.4 Generator Function Definitions
+// GeneratorExpression:
+// function * BindingIdentifier[+Yield]opt ( FormalParameters[+Yield] ) { GeneratorBody }
+// GeneratorMethod[Yield]:
+// * PropertyName[?Yield] ( UniqueFormalParameters[+Yield] ) { GeneratorBody }
+
+
+function functionExpression(argList, parameters = "", returnExpr = "") {
+ return eval(`(function f(${argList}) {
+ var fun = f;
+ return ${returnExpr};
+ })(${parameters})`);
+}
+
+function generatorExpression(argList, parameters = "", returnExpr = "") {
+ return eval(`(function* f(${argList}) {
+ var fun = f;
+ return ${returnExpr};
+ })(${parameters}).next().value`);
+}
+
+function objectMethod(argList, parameters = "", returnExpr = "") {
+ return eval(`({
+ m(${argList}) {
+ var fun = this.m;
+ return ${returnExpr};
+ }
+ }).m(${parameters})`);
+}
+
+function objectGeneratorMethod(argList, parameters = "", returnExpr = "") {
+ return eval(`({
+ * m(${argList}) {
+ var fun = this.m;
+ return ${returnExpr};
+ }
+ }).m(${parameters}).next().value`);
+}
+
+function classMethod(argList, parameters = "", returnExpr = "") {
+ return eval(`(new class {
+ m(${argList}) {
+ var fun = this.m;
+ return ${returnExpr};
+ }
+ }).m(${parameters})`);
+}
+
+function classStaticMethod(argList, parameters = "", returnExpr = "") {
+ return eval(`(class {
+ static m(${argList}) {
+ var fun = this.m;
+ return ${returnExpr};
+ }
+ }).m(${parameters})`);
+}
+
+function classGeneratorMethod(argList, parameters = "", returnExpr = "") {
+ return eval(`(new class {
+ * m(${argList}) {
+ var fun = this.m;
+ return ${returnExpr};
+ }
+ }).m(${parameters}).next().value`);
+}
+
+function classStaticGeneratorMethod(argList, parameters = "", returnExpr = "") {
+ return eval(`(class {
+ static * m(${argList}) {
+ var fun = this.m;
+ return ${returnExpr};
+ }
+ }).m(${parameters}).next().value`);
+}
+
+function classConstructorMethod(argList, parameters = "", returnExpr = "null") {
+ return eval(`new (class {
+ constructor(${argList}) {
+ var fun = this.constructor;
+ return { value: ${returnExpr} };
+ }
+ })(${parameters}).value`);
+}
+
+const tests = [
+ functionExpression,
+ generatorExpression,
+ objectMethod,
+ objectGeneratorMethod,
+ classMethod,
+ classStaticMethod,
+ classGeneratorMethod,
+ classStaticGeneratorMethod,
+ classConstructorMethod,
+];
+
+// Ensure parameters are passed correctly.
+for (let test of tests) {
+ assertEq(test("a, ", "10", "a"), 10);
+ assertEq(test("a, b, ", "10, 20", "a + b"), 30);
+ assertEq(test("a = 30, ", "", "a"), 30);
+ assertEq(test("a = 30, b = 40, ", "", "a + b"), 70);
+
+ assertEq(test("[a], ", "[10]", "a"), 10);
+ assertEq(test("[a], [b], ", "[10], [20]", "a + b"), 30);
+ assertEq(test("[a] = [30], ", "", "a"), 30);
+ assertEq(test("[a] = [30], [b] = [40], ", "", "a + b"), 70);
+
+ assertEq(test("{a}, ", "{a: 10}", "a"), 10);
+ assertEq(test("{a}, {b}, ", "{a: 10}, {b: 20}", "a + b"), 30);
+ assertEq(test("{a} = {a: 30}, ", "", "a"), 30);
+ assertEq(test("{a} = {a: 30}, {b} = {b: 40}, ", "", "a + b"), 70);
+}
+
+// Ensure function length doesn't change.
+for (let test of tests) {
+ assertEq(test("a, ", "", "fun.length"), 1);
+ assertEq(test("a, b, ", "", "fun.length"), 2);
+
+ assertEq(test("[a], ", "[]", "fun.length"), 1);
+ assertEq(test("[a], [b], ", "[], []", "fun.length"), 2);
+
+ assertEq(test("{a}, ", "{}", "fun.length"), 1);
+ assertEq(test("{a}, {b}, ", "{}, {}", "fun.length"), 2);
+}
+
+for (let test of tests) {
+ // Trailing comma in empty parameters list.
+ assertThrowsInstanceOf(() => test(","), SyntaxError);
+
+ // Leading comma.
+ assertThrowsInstanceOf(() => test(", a"), SyntaxError);
+ assertThrowsInstanceOf(() => test(", ...a"), SyntaxError);
+
+ // Multiple trailing comma.
+ assertThrowsInstanceOf(() => test("a, , "), SyntaxError);
+ assertThrowsInstanceOf(() => test("a..., , "), SyntaxError);
+
+ // Trailing comma after rest parameter.
+ assertThrowsInstanceOf(() => test("...a, "), SyntaxError);
+ assertThrowsInstanceOf(() => test("a, ...b, "), SyntaxError);
+
+ // Elision.
+ assertThrowsInstanceOf(() => test("a, , b"), SyntaxError);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/ecma_2017/Statements/browser.js b/js/src/tests/ecma_2017/Statements/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_2017/Statements/browser.js
diff --git a/js/src/tests/ecma_2017/Statements/for-in-with-assignment-semantics.js b/js/src/tests/ecma_2017/Statements/for-in-with-assignment-semantics.js
new file mode 100644
index 000000000..f1dbb3438
--- /dev/null
+++ b/js/src/tests/ecma_2017/Statements/for-in-with-assignment-semantics.js
@@ -0,0 +1,46 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const unreachable = () => { throw "unreachable"; };
+
+// var-initializer expression is executed before for-in expression.
+var log = "";
+for (var x = (log += "head") in (log += "|expr", null)) unreachable();
+assertEq(log, "head|expr");
+
+log = "";
+for (var x = (log += "head") in (log += "|expr", {})) unreachable();
+assertEq(log, "head|expr");
+
+
+// for-in expression isn't executed when var-initializer throws exception.
+function ExpectedError() {}
+assertThrowsInstanceOf(() => {
+ var throwErr = () => { throw new ExpectedError(); };
+ for (var x = throwErr() in unreachable()) unreachable();
+}, ExpectedError);
+
+
+// Ensure environment operations are performed correctly.
+var scope = new Proxy({x: 0}, new Proxy({}, {
+ get(t, pk, r) {
+ log += pk + "|";
+ }
+}));
+
+log = "";
+with (scope) {
+ for (var x = 0 in {}) ;
+}
+assertEq(log, "has|get|set|getOwnPropertyDescriptor|defineProperty|");
+
+log = "";
+with (scope) {
+ for (var x = 0 in {p: 0}) ;
+}
+assertEq(log, "has|get|set|getOwnPropertyDescriptor|defineProperty|".repeat(2));
+
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
diff --git a/js/src/tests/ecma_2017/Statements/for-in-with-assignment-syntax.js b/js/src/tests/ecma_2017/Statements/for-in-with-assignment-syntax.js
new file mode 100644
index 000000000..4ac711e21
--- /dev/null
+++ b/js/src/tests/ecma_2017/Statements/for-in-with-assignment-syntax.js
@@ -0,0 +1,68 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const validSyntax = [
+ "var x",
+];
+
+const destructuring = [
+ "[]",
+ "[,]",
+ "[a]",
+ "[a = 0]",
+ "[...a]",
+ "[...[]]",
+ "[...[a]]",
+ "{}",
+ "{p: x}",
+ "{p: x = 0}",
+ "{x}",
+ "{x = 0}",
+];
+
+const invalidSyntax = [
+ ...destructuring.map(binding => `var ${binding}`),
+ "let x",
+ ...destructuring.map(binding => `let ${binding}`),
+ "const x",
+ ...destructuring.map(binding => `const ${binding}`),
+ "x",
+ ...destructuring.map(binding => `${binding}`),
+ "o.p",
+ "o[0]",
+ "f()",
+];
+
+for (let valid of validSyntax) {
+ eval(`for (${valid} = 0 in {});`);
+ assertThrowsInstanceOf(() => eval(`"use strict"; for (${valid} = 0 in {});`),
+ SyntaxError);
+}
+
+for (let invalid of invalidSyntax) {
+ assertThrowsInstanceOf(() => eval(`for (${invalid} = 0 in {});`), SyntaxError);
+}
+
+// Invalid syntax, needs method context to parse.
+assertThrowsInstanceOf(() => eval(`({ m() { for (super.p = 0 in {}); } })`), SyntaxError);
+assertThrowsInstanceOf(() => eval(`({ m() { for (super[0] = 0 in {}); } })`), SyntaxError);
+
+// Throws ReferenceError instead of SyntaxError, because we intermingle parsing
+// and early error checking.
+assertThrowsInstanceOf(() => eval(`for (0 = 0 in {});`), ReferenceError);
+assertThrowsInstanceOf(() => eval(`for (i++ = 0 in {});`), ReferenceError);
+assertThrowsInstanceOf(() => eval(`for (new F() = 0 in {});`), ReferenceError);
+assertThrowsInstanceOf(() => eval(`function f() { for (new.target = 0 in {}); }`), ReferenceError);
+assertThrowsInstanceOf(() => eval(`class C extends D { constructor() { for (super() = 0 in {}); } }`), ReferenceError);
+
+// Same as above, only this time don't make it look like we actually parse a for-in statement.
+assertThrowsInstanceOf(() => eval(`for (0 = 0 #####`), ReferenceError);
+assertThrowsInstanceOf(() => eval(`for (i++ = 0 #####`), ReferenceError);
+assertThrowsInstanceOf(() => eval(`for (new F() = 0 #####`), ReferenceError);
+assertThrowsInstanceOf(() => eval(`function f() { for (new.target = 0 #####`), ReferenceError);
+assertThrowsInstanceOf(() => eval(`class C extends D { constructor() { for (super() = 0 #####`), ReferenceError);
+
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
diff --git a/js/src/tests/ecma_2017/Statements/for-in-with-assignments.js b/js/src/tests/ecma_2017/Statements/for-in-with-assignments.js
new file mode 100644
index 000000000..9a9782ee4
--- /dev/null
+++ b/js/src/tests/ecma_2017/Statements/for-in-with-assignments.js
@@ -0,0 +1,82 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+var gTestfile = "for-in-with-assignments.js";
+var BUGNUMBER = 1164741;
+var summary = "Parse |for (var ... = ... in ...)|."
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+// This is a total grab-bag of junk originally in tests changed when this
+// syntax was removed. Leaving it all in one file will make it easier to
+// eventually remove. Avert your eyes!
+// TC39 has revived this syntax for ES2017 - "What is dead may never die."
+
+if (typeof Reflect !== "undefined" && Reflect.parse)
+ Reflect.parse("for (var x = 3 in []) { }");
+
+/******************************************************************************/
+
+function testQ() {
+ try {
+ for (var i = 0 in this) throw p;
+ } catch (e) {
+ if (i !== 94)
+ return "what";
+ }
+}
+testQ();
+
+/******************************************************************************/
+
+function f3(i,o){for(var x=i in o)parseInt(o[x]); return x}
+function f4(i,o){with(this)for(var x=i in o)parseInt(o[x]); return x}
+
+assertEq(f3(42, []), 42);
+assertEq(f3(42, ['first']), "0");
+assertEq(f4(42, []), 42);
+assertEq(f4(42, ['first']), "0");
+
+/******************************************************************************/
+
+function SetLangHead(l){
+ with(p){
+ for(var i=0 in x)
+ if(getElementById("TxtH"+i)!=undefined)
+ parseInt('huh');
+ }
+}
+x=[0,1,2,3];
+p={getElementById: function (id){parseInt(uneval(this), id); return undefined;}};
+SetLangHead(1);
+
+/******************************************************************************/
+
+(function(){for(var x = arguments in []){} function x(){}})();
+
+/******************************************************************************/
+
+with (0)
+ for (var b = 0 in 0); // don't assert in parser
+
+/******************************************************************************/
+
+function* g1() {
+ for (var x = yield in {}) ;
+}
+var it = g1();
+assertEq(it.next().done, false);
+assertEq(it.next().done, true);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/ecma_2017/Statements/shell.js b/js/src/tests/ecma_2017/Statements/shell.js
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/js/src/tests/ecma_2017/Statements/shell.js
@@ -0,0 +1 @@
+
diff --git a/js/src/tests/ecma_2017/Statements/trailing_comma_parameters.js b/js/src/tests/ecma_2017/Statements/trailing_comma_parameters.js
new file mode 100644
index 000000000..8612f7b1b
--- /dev/null
+++ b/js/src/tests/ecma_2017/Statements/trailing_comma_parameters.js
@@ -0,0 +1,92 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Trailing comma in functions and generators.
+
+// 14.1 Function Definitions
+// FunctionDeclaration[Yield, Default]:
+// function BindingIdentifier[?Yield] ( FormalParameters[~Yield] ) { FunctionBody[~Yield] }
+
+// 14.4 Generator Function Definitions
+// GeneratorDeclaration[Yield, Default]:
+// function * BindingIdentifier[?Yield] ( FormalParameters[+Yield] ) { GeneratorBody }
+
+
+function functionDeclaration(argList, parameters = "", returnExpr = "") {
+ return eval(`
+ function f(${argList}) {
+ var fun = f;
+ return ${returnExpr};
+ }
+ f(${parameters});
+ `);
+}
+
+function generatorDeclaration(argList, parameters = "", returnExpr = "") {
+ return eval(`
+ function* f(${argList}) {
+ var fun = f;
+ return ${returnExpr};
+ }
+ f(${parameters}).next().value;
+ `);
+}
+
+const tests = [
+ functionDeclaration,
+ generatorDeclaration,
+];
+
+// Ensure parameters are passed correctly.
+for (let test of tests) {
+ assertEq(test("a, ", "10", "a"), 10);
+ assertEq(test("a, b, ", "10, 20", "a + b"), 30);
+ assertEq(test("a = 30, ", "", "a"), 30);
+ assertEq(test("a = 30, b = 40, ", "", "a + b"), 70);
+
+ assertEq(test("[a], ", "[10]", "a"), 10);
+ assertEq(test("[a], [b], ", "[10], [20]", "a + b"), 30);
+ assertEq(test("[a] = [30], ", "", "a"), 30);
+ assertEq(test("[a] = [30], [b] = [40], ", "", "a + b"), 70);
+
+ assertEq(test("{a}, ", "{a: 10}", "a"), 10);
+ assertEq(test("{a}, {b}, ", "{a: 10}, {b: 20}", "a + b"), 30);
+ assertEq(test("{a} = {a: 30}, ", "", "a"), 30);
+ assertEq(test("{a} = {a: 30}, {b} = {b: 40}, ", "", "a + b"), 70);
+}
+
+// Ensure function length doesn't change.
+for (let test of tests) {
+ assertEq(test("a, ", "", "fun.length"), 1);
+ assertEq(test("a, b, ", "", "fun.length"), 2);
+
+ assertEq(test("[a], ", "[]", "fun.length"), 1);
+ assertEq(test("[a], [b], ", "[], []", "fun.length"), 2);
+
+ assertEq(test("{a}, ", "{}", "fun.length"), 1);
+ assertEq(test("{a}, {b}, ", "{}, {}", "fun.length"), 2);
+}
+
+for (let test of tests) {
+ // Trailing comma in empty parameters list.
+ assertThrowsInstanceOf(() => test(","), SyntaxError);
+
+ // Leading comma.
+ assertThrowsInstanceOf(() => test(", a"), SyntaxError);
+ assertThrowsInstanceOf(() => test(", ...a"), SyntaxError);
+
+ // Multiple trailing comma.
+ assertThrowsInstanceOf(() => test("a, , "), SyntaxError);
+ assertThrowsInstanceOf(() => test("a..., , "), SyntaxError);
+
+ // Trailing comma after rest parameter.
+ assertThrowsInstanceOf(() => test("...a, "), SyntaxError);
+ assertThrowsInstanceOf(() => test("a, ...b, "), SyntaxError);
+
+ // Elision.
+ assertThrowsInstanceOf(() => test("a, , b"), SyntaxError);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/ecma_2017/browser.js b/js/src/tests/ecma_2017/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_2017/browser.js
diff --git a/js/src/tests/ecma_2017/shell.js b/js/src/tests/ecma_2017/shell.js
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/js/src/tests/ecma_2017/shell.js
@@ -0,0 +1 @@
+