summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/language/expressions/yield
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/annexB/language/expressions/yield
parentInitial commit. (diff)
downloadfirefox-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/yield')
-rw-r--r--js/src/tests/test262/annexB/language/expressions/yield/browser.js0
-rw-r--r--js/src/tests/test262/annexB/language/expressions/yield/shell.js0
-rw-r--r--js/src/tests/test262/annexB/language/expressions/yield/star-iterable-return-emulates-undefined-throws-when-called.js33
-rw-r--r--js/src/tests/test262/annexB/language/expressions/yield/star-iterable-throw-emulates-undefined-throws-when-called.js50
4 files changed, 83 insertions, 0 deletions
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);