diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/annexB/language/expressions | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/annexB/language/expressions')
51 files changed, 560 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/language/expressions/assignment/browser.js b/js/src/tests/test262/annexB/language/expressions/assignment/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/assignment/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/assignment/dstr/array-pattern-emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/assignment/dstr/array-pattern-emulates-undefined.js new file mode 100644 index 0000000000..e65bbe0aae --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/assignment/dstr/array-pattern-emulates-undefined.js @@ -0,0 +1,46 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization +description: > + Destructuring initializer is not evaluated when value is an object + with [[IsHTMLDDA]] internal slot. +info: | + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + 2. Let result be IteratorBindingInitialization of ArrayBindingPattern with arguments + iteratorRecord and environment. + 3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result). + 4. Return result. + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer[opt] + + [...] + 5. If Initializer is present and v is undefined, then + [...] + 6. If environment is undefined, return ? PutValue(lhs, v). +features: [destructuring-binding, IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; +var initCount = 0; +var counter = function() { + initCount += 1; +}; + +var x; +([x = counter()] = [IsHTMLDDA]); + +assert.sameValue(x, IsHTMLDDA); +assert.sameValue(initCount, 0); + +var base = {}; +([base.y = counter()] = [IsHTMLDDA]); + +assert.sameValue(base.y, IsHTMLDDA); +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/assignment/dstr/browser.js b/js/src/tests/test262/annexB/language/expressions/assignment/dstr/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/assignment/dstr/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/assignment/dstr/object-pattern-emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/assignment/dstr/object-pattern-emulates-undefined.js new file mode 100644 index 0000000000..d9fe3d1bc3 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/assignment/dstr/object-pattern-emulates-undefined.js @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization +description: > + Destructuring initializer is not evaluated when value is an object + with [[IsHTMLDDA]] internal slot. +info: | + BindingPattern : ObjectBindingPattern + + 1. Perform ? RequireObjectCoercible(value). + 2. Return the result of performing BindingInitialization for + ObjectBindingPattern using value and environment as arguments. + + Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer[opt] + + [...] + 4. If Initializer is present and v is undefined, then + [...] + 5. If environment is undefined, return ? PutValue(lhs, v). +features: [destructuring-binding, IsHTMLDDA] +---*/ + +var initCount = 0; +var counter = function() { + initCount += 1; +}; + +var x, IsHTMLDDA = $262.IsHTMLDDA; +({x = counter()} = {x: IsHTMLDDA}); + +assert.sameValue(x, IsHTMLDDA); +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/assignment/dstr/shell.js b/js/src/tests/test262/annexB/language/expressions/assignment/dstr/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/assignment/dstr/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/assignment/shell.js b/js/src/tests/test262/annexB/language/expressions/assignment/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/assignment/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/browser.js b/js/src/tests/test262/annexB/language/expressions/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/coalesce/browser.js b/js/src/tests/test262/annexB/language/expressions/coalesce/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/coalesce/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/coalesce/emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/coalesce/emulates-undefined.js new file mode 100644 index 0000000000..25b883759d --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/coalesce/emulates-undefined.js @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-binary-bitwise-operators-runtime-semantics-evaluation +description: > + ?? doesn't special-case [[IsHTMLDDA]] object; rval is not evaluated. +info: | + CoalesceExpression : CoalesceExpressionHead ?? BitwiseORExpression + + 1. Let lref be the result of evaluating CoalesceExpressionHead. + 2. Let lval be ? GetValue(lref). + 3. If lval is undefined or null, then + [...] + 4. Otherwise, return lval. +features: [IsHTMLDDA, coalesce-expression] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; + +assert.sameValue(IsHTMLDDA ?? unresolved, IsHTMLDDA); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/coalesce/shell.js b/js/src/tests/test262/annexB/language/expressions/coalesce/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/coalesce/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/conditional/browser.js b/js/src/tests/test262/annexB/language/expressions/conditional/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/conditional/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/conditional/emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/conditional/emulates-undefined.js new file mode 100644 index 0000000000..733d6b239b --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/conditional/emulates-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-conditional-operator-runtime-semantics-evaluation +description: > + ToBoolean returns `false` for [[IsHTMLDDA]] object; trueRef is not evaluated. +info: | + ConditionalExpression : ShortCircuitExpression ? AssignmentExpression : AssignmentExpression + + 1. Let lref be the result of evaluating ShortCircuitExpression. + 2. Let lval be ! ToBoolean(? GetValue(lref)). + 3. If lval is true, then + [...] + 4. Else, + a. Let falseRef be the result of evaluating the second AssignmentExpression. + b. Return ? GetValue(falseRef). + + The [[IsHTMLDDA]] Internal Slot / Changes to ToBoolean + + 1. If argument has an [[IsHTMLDDA]] internal slot, return false. + 2. Return true. +features: [IsHTMLDDA] +---*/ + +assert.sameValue($262.IsHTMLDDA ? unresolved : 2, 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/conditional/shell.js b/js/src/tests/test262/annexB/language/expressions/conditional/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/conditional/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/does-not-equals/browser.js b/js/src/tests/test262/annexB/language/expressions/does-not-equals/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/does-not-equals/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/does-not-equals/emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/does-not-equals/emulates-undefined.js new file mode 100644 index 0000000000..15928d2065 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/does-not-equals/emulates-undefined.js @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-equality-operators-runtime-semantics-evaluation +description: > + Abstract Equality special-cases [[IsHTMLDDA]] objects with `undefined` and `null`. +info: | + EqualityExpression : EqualityExpression != RelationalExpression + + [...] + 5. Let r be the result of performing Abstract Equality Comparison rval == lval. + 6. ReturnIfAbrupt(r). + 7. If r is true, return false. Otherwise, return true. + + The [[IsHTMLDDA]] Internal Slot / Changes to Abstract Equality Comparison + + The following steps are inserted after step 3 of the Abstract Equality Comparison algorithm: + + 1. If Type(x) is Object and x has an [[IsHTMLDDA]] internal slot and y is either null or undefined, return true. + 2. If x is either null or undefined and Type(y) is Object and y has an [[IsHTMLDDA]] internal slot, return true. +features: [IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; + +assert.sameValue(IsHTMLDDA != undefined, false, "!= with `undefined`"); +assert.sameValue(undefined != IsHTMLDDA, false, "!= with `undefined`"); + +assert.sameValue(IsHTMLDDA != null, false, "!= with `null`"); +assert.sameValue(null != IsHTMLDDA, false, "!= with `null`"); + +assert.sameValue(IsHTMLDDA != IsHTMLDDA, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/does-not-equals/shell.js b/js/src/tests/test262/annexB/language/expressions/does-not-equals/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/does-not-equals/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/equals/browser.js b/js/src/tests/test262/annexB/language/expressions/equals/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/equals/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/equals/emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/equals/emulates-undefined.js new file mode 100644 index 0000000000..ca0a8805f1 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/equals/emulates-undefined.js @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-equality-operators-runtime-semantics-evaluation +description: > + Abstract Equality special-cases [[IsHTMLDDA]] objects with `undefined` and `null`. +info: | + EqualityExpression : EqualityExpression == RelationalExpression + + [...] + 5. Return the result of performing Abstract Equality Comparison rval == lval. + + The [[IsHTMLDDA]] Internal Slot / Changes to Abstract Equality Comparison + + The following steps are inserted after step 3 of the Abstract Equality Comparison algorithm: + + 1. If Type(x) is Object and x has an [[IsHTMLDDA]] internal slot and y is either null or undefined, return true. + 2. If x is either null or undefined and Type(y) is Object and y has an [[IsHTMLDDA]] internal slot, return true. +features: [IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; + +assert(IsHTMLDDA == undefined, "== with `undefined`"); +assert(undefined == IsHTMLDDA, "== with `undefined`"); + +assert(IsHTMLDDA == null, "== with `null`"); +assert(null == IsHTMLDDA, "== with `null`"); + +assert(IsHTMLDDA == IsHTMLDDA); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/equals/shell.js b/js/src/tests/test262/annexB/language/expressions/equals/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/equals/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/logical-and/browser.js b/js/src/tests/test262/annexB/language/expressions/logical-and/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-and/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/logical-and/emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/logical-and/emulates-undefined.js new file mode 100644 index 0000000000..ddfaa3c5fa --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-and/emulates-undefined.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-binary-logical-operators-runtime-semantics-evaluation +description: > + ToBoolean returns `false` for [[IsHTMLDDA]] object; rval is not evaluated. +info: | + LogicalANDExpression : LogicalANDExpression && BitwiseORExpression + + 1. Let lref be the result of evaluating LogicalANDExpression. + 2. Let lval be ? GetValue(lref). + 3. Let lbool be ! ToBoolean(lval). + 4. If lbool is false, return lval. + + The [[IsHTMLDDA]] Internal Slot / Changes to ToBoolean + + 1. If argument has an [[IsHTMLDDA]] internal slot, return false. + 2. Return true. +features: [IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; + +assert.sameValue(IsHTMLDDA && unresolved, IsHTMLDDA); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/logical-and/shell.js b/js/src/tests/test262/annexB/language/expressions/logical-and/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-and/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/logical-assignment/browser.js b/js/src/tests/test262/annexB/language/expressions/logical-assignment/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-assignment/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/logical-assignment/emulates-undefined-and.js b/js/src/tests/test262/annexB/language/expressions/logical-assignment/emulates-undefined-and.js new file mode 100644 index 0000000000..51587a812e --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-assignment/emulates-undefined-and.js @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-assignment-operators-runtime-semantics-evaluation +description: > + ToBoolean returns `false` for [[IsHTMLDDA]] object; rval is not evaluated. +info: | + AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression + + 1. Let lref be the result of evaluating LeftHandSideExpression. + 2. Let lval be ? GetValue(lref). + 3. Let lbool be ! ToBoolean(lval). + 4. If lbool is false, return lval. + + The [[IsHTMLDDA]] Internal Slot / Changes to ToBoolean + + 1. If argument has an [[IsHTMLDDA]] internal slot, return false. + 2. Return true. +features: [IsHTMLDDA, logical-assignment-operators] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; +var value = IsHTMLDDA; +assert.sameValue(value &&= unresolved, IsHTMLDDA); +assert.sameValue(value, IsHTMLDDA); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/logical-assignment/emulates-undefined-coalesce.js b/js/src/tests/test262/annexB/language/expressions/logical-assignment/emulates-undefined-coalesce.js new file mode 100644 index 0000000000..621b6ee8da --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-assignment/emulates-undefined-coalesce.js @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-assignment-operators-runtime-semantics-evaluation +description: > + ??= doesn't special-case [[IsHTMLDDA]] object; rval is not evaluated. +info: | + AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression + + 1. Let lref be the result of evaluating LeftHandSideExpression. + 2. Let lval be ? GetValue(lref). + 3. If lval is neither undefined nor null, return lval. +features: [IsHTMLDDA, logical-assignment-operators] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; +var value = IsHTMLDDA; +assert.sameValue(value ??= unresolved, IsHTMLDDA); +assert.sameValue(value, IsHTMLDDA); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/logical-assignment/emulates-undefined-or.js b/js/src/tests/test262/annexB/language/expressions/logical-assignment/emulates-undefined-or.js new file mode 100644 index 0000000000..a79beda74d --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-assignment/emulates-undefined-or.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-assignment-operators-runtime-semantics-evaluation +description: > + ToBoolean returns `false` for [[IsHTMLDDA]] object; rval is evaluated. +info: | + AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression + + 1. Let lref be the result of evaluating LeftHandSideExpression. + 2. Let lval be ? GetValue(lref). + 3. Let lbool be ! ToBoolean(lval). + [...] + 7. Perform ? PutValue(lref, rval). + 8. Return rval. + + The [[IsHTMLDDA]] Internal Slot / Changes to ToBoolean + + 1. If argument has an [[IsHTMLDDA]] internal slot, return false. + 2. Return true. +features: [IsHTMLDDA, logical-assignment-operators] +---*/ + +var value = $262.IsHTMLDDA; +assert.sameValue(value ||= 2, 2); +assert.sameValue(value, 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/logical-assignment/shell.js b/js/src/tests/test262/annexB/language/expressions/logical-assignment/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-assignment/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/logical-not/browser.js b/js/src/tests/test262/annexB/language/expressions/logical-not/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-not/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/logical-not/emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/logical-not/emulates-undefined.js new file mode 100644 index 0000000000..b559b94730 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-not/emulates-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-binary-logical-operators-runtime-semantics-evaluation +description: > + ToBoolean returns `false` for [[IsHTMLDDA]] object. +info: | + UnaryExpression : ! UnaryExpression + + 1. Let expr be the result of evaluating UnaryExpression. + 2. Let oldValue be ! ToBoolean(? GetValue(expr)). + 3. If oldValue is true, return false. + 4. Return true. + + The [[IsHTMLDDA]] Internal Slot / Changes to ToBoolean + + 1. If argument has an [[IsHTMLDDA]] internal slot, return false. + 2. Return true. +features: [IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; + +assert(!IsHTMLDDA); +assert.sameValue(!!IsHTMLDDA, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/logical-not/shell.js b/js/src/tests/test262/annexB/language/expressions/logical-not/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-not/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/logical-or/browser.js b/js/src/tests/test262/annexB/language/expressions/logical-or/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-or/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/logical-or/emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/logical-or/emulates-undefined.js new file mode 100644 index 0000000000..13049c5c55 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-or/emulates-undefined.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-binary-logical-operators-runtime-semantics-evaluation +description: > + ToBoolean returns `false` for [[IsHTMLDDA]] object; rval is evaluated. +info: | + LogicalORExpression : LogicalORExpression || LogicalANDExpression + + 1. Let lref be the result of evaluating LogicalORExpression. + 2. Let lval be ? GetValue(lref). + 3. Let lbool be ! ToBoolean(lval). + 4. If lbool is true, return lval. + 5. Let rref be the result of evaluating LogicalANDExpression. + 6. Return ? GetValue(rref). + + The [[IsHTMLDDA]] Internal Slot / Changes to ToBoolean + + 1. If argument has an [[IsHTMLDDA]] internal slot, return false. + 2. Return true. +features: [IsHTMLDDA] +---*/ + +assert.sameValue($262.IsHTMLDDA || 2, 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/logical-or/shell.js b/js/src/tests/test262/annexB/language/expressions/logical-or/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/logical-or/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/shell.js b/js/src/tests/test262/annexB/language/expressions/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/strict-does-not-equals/browser.js b/js/src/tests/test262/annexB/language/expressions/strict-does-not-equals/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/strict-does-not-equals/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/strict-does-not-equals/emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/strict-does-not-equals/emulates-undefined.js new file mode 100644 index 0000000000..7717308664 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/strict-does-not-equals/emulates-undefined.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-equality-operators-runtime-semantics-evaluation +description: > + Strict Equality Comparison doesn't special-case [[IsHTMLDDA]] objects. +info: | + EqualityExpression : EqualityExpression !== RelationalExpression + + [...] + 5. Let r be the result of performing Strict Equality Comparison rval === lval. + 6. Assert: r is a normal completion. + 7. If r.[[Value]] is true, return false. Otherwise, return true. + + Strict Equality Comparison + + 1. If Type(x) is different from Type(y), return false. +features: [IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; + +assert(IsHTMLDDA !== undefined, "!== with `undefined`"); +assert(undefined !== IsHTMLDDA, "!== with `undefined`"); + +assert(IsHTMLDDA !== null, "!== with `null`"); +assert(null !== IsHTMLDDA, "!== with `null`"); + +assert.sameValue(IsHTMLDDA !== IsHTMLDDA, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/strict-does-not-equals/shell.js b/js/src/tests/test262/annexB/language/expressions/strict-does-not-equals/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/strict-does-not-equals/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/strict-equals/browser.js b/js/src/tests/test262/annexB/language/expressions/strict-equals/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/strict-equals/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/strict-equals/emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/strict-equals/emulates-undefined.js new file mode 100644 index 0000000000..67c6603cdd --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/strict-equals/emulates-undefined.js @@ -0,0 +1,29 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-equality-operators-runtime-semantics-evaluation +description: > + Strict Equality Comparison doesn't special-case [[IsHTMLDDA]] objects. +info: | + EqualityExpression : EqualityExpression === RelationalExpression + + [...] + 5. Return the result of performing Strict Equality Comparison rval === lval. + + Strict Equality Comparison + + 1. If Type(x) is different from Type(y), return false. +features: [IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; + +assert.sameValue(IsHTMLDDA === undefined, false, "=== with `undefined`"); +assert.sameValue(undefined === IsHTMLDDA, false, "=== with `undefined`"); + +assert.sameValue(IsHTMLDDA === null, false, "=== with `null`"); +assert.sameValue(null === IsHTMLDDA, false, "=== with `null`"); + +assert(IsHTMLDDA === IsHTMLDDA); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/strict-equals/shell.js b/js/src/tests/test262/annexB/language/expressions/strict-equals/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/strict-equals/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/template-literal/browser.js b/js/src/tests/test262/annexB/language/expressions/template-literal/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/template-literal/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/template-literal/legacy-octal-escape-sequence-non-strict.js b/js/src/tests/test262/annexB/language/expressions/template-literal/legacy-octal-escape-sequence-non-strict.js new file mode 100644 index 0000000000..20ecbcc80b --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/template-literal/legacy-octal-escape-sequence-non-strict.js @@ -0,0 +1,15 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.2.8 +description: > + The expression within the template should be evaluated according to the + semantics of the surrounding context. + The SV of EscapeSequence :: HexEscapeSequence is the SV of the + HexEscapeSequence. +flags: [noStrict] +---*/ + +assert.sameValue(`${'\07'}`, '\u0007'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/template-literal/legacy-octal-escape-sequence-strict-strict.js b/js/src/tests/test262/annexB/language/expressions/template-literal/legacy-octal-escape-sequence-strict-strict.js new file mode 100644 index 0000000000..19a2f03bd4 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/template-literal/legacy-octal-escape-sequence-strict-strict.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.2.8 +description: > + The expression within the template should be evaluated according to the + semantics of the surrounding context. + The SV of EscapeSequence :: HexEscapeSequence is the SV of the + HexEscapeSequence. +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +`${'\07'}`; diff --git a/js/src/tests/test262/annexB/language/expressions/template-literal/shell.js b/js/src/tests/test262/annexB/language/expressions/template-literal/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/template-literal/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/typeof/browser.js b/js/src/tests/test262/annexB/language/expressions/typeof/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/typeof/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/typeof/emulates-undefined.js b/js/src/tests/test262/annexB/language/expressions/typeof/emulates-undefined.js new file mode 100644 index 0000000000..464a80f84c --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/typeof/emulates-undefined.js @@ -0,0 +1,29 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-IsHTMLDDA-internal-slot-typeof +description: > + `typeof` operator returns "undefined" for [[IsHTMLDDA]] object. +info: | + Changes to the typeof Operator + + The following table entry is inserted into Table 35 immediately + preceeding the entry for "Object (implements [[Call]])": + + Type of val: Object (has an [[IsHTMLDDA]] internal slot) + Result: "undefined" +features: [IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; + +assert(typeof IsHTMLDDA === "undefined", '=== "undefined"'); +assert.sameValue(typeof IsHTMLDDA, "undefined"); + +assert(typeof IsHTMLDDA !== "object", '!== "object"'); +assert.sameValue(typeof IsHTMLDDA === "object", false, '!== "object"'); + +assert(typeof IsHTMLDDA !== "function", '!== "function"'); +assert.sameValue(typeof IsHTMLDDA === "function", false, '!== "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/typeof/shell.js b/js/src/tests/test262/annexB/language/expressions/typeof/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/typeof/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/yield/browser.js b/js/src/tests/test262/annexB/language/expressions/yield/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/yield/browser.js diff --git a/js/src/tests/test262/annexB/language/expressions/yield/shell.js b/js/src/tests/test262/annexB/language/expressions/yield/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/yield/shell.js diff --git a/js/src/tests/test262/annexB/language/expressions/yield/star-iterable-return-emulates-undefined-throws-when-called.js b/js/src/tests/test262/annexB/language/expressions/yield/star-iterable-return-emulates-undefined-throws-when-called.js new file mode 100644 index 0000000000..c424651c61 --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/yield/star-iterable-return-emulates-undefined-throws-when-called.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluation +description: > + If <iterator>.return is an object emulating `undefined` (e.g. `document.all` + in browsers), it shouldn't be treated as if it were actually `undefined` by + the yield* operator. +features: [generators, IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; +var iter = { + [Symbol.iterator]() { return this; }, + next() { return {}; }, + return: IsHTMLDDA, +}; + +var outer = (function*() { yield* iter; })(); + +outer.next(); + +assert.throws(TypeError, function() { + // `IsHTMLDDA` is called here with `iter` as `this` and `emptyString` as the + // sole argument, and it's specified to return `null` under these conditions. + // As `iter`'s iteration isn't ending because of a throw, the iteration + // protocol will then throw a `TypeError` because `null` isn't an object. + var emptyString = ""; + outer.return(emptyString); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/expressions/yield/star-iterable-throw-emulates-undefined-throws-when-called.js b/js/src/tests/test262/annexB/language/expressions/yield/star-iterable-throw-emulates-undefined-throws-when-called.js new file mode 100644 index 0000000000..bdeaa2051a --- /dev/null +++ b/js/src/tests/test262/annexB/language/expressions/yield/star-iterable-throw-emulates-undefined-throws-when-called.js @@ -0,0 +1,50 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluation +description: > + If <iterator>.throw is an object emulating `undefined` (e.g. `document.all` + in browsers), it shouldn't be treated as if it were actually `undefined` by + the yield* operator. +info: | + YieldExpression : yield * AssignmentExpression + + [...] + 7. Repeat, + [...] + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + [...] + 4. If Type(innerResult) is not Object, throw a TypeError exception. +features: [generators, IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; +var returnCalls = 0; +var inner = { + [Symbol.iterator]() { return this; }, + next() { return {done: false}; }, + throw: IsHTMLDDA, + return() { + returnCalls += 1; + return {done: true}; + }, +}; + +var outer = (function* () { yield* inner; })(); +outer.next(); + +assert.throws(TypeError, function() { + // `IsHTMLDDA` is called here with `iter` as `this` and `emptyString` as the + // sole argument, and it's specified to return `null` under these conditions. + // As `iter`'s iteration isn't ending because of a throw, the iteration + // protocol will then throw a `TypeError` because `null` isn't an object. + var emptyString = ""; + outer.throw(emptyString); +}); + +assert.sameValue(returnCalls, 0); + +reportCompare(0, 0); |