summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Iterator/from/wrap-method-with-non-wrap-this-throws.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /js/src/tests/non262/Iterator/from/wrap-method-with-non-wrap-this-throws.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/Iterator/from/wrap-method-with-non-wrap-this-throws.js')
-rw-r--r--js/src/tests/non262/Iterator/from/wrap-method-with-non-wrap-this-throws.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/tests/non262/Iterator/from/wrap-method-with-non-wrap-this-throws.js b/js/src/tests/non262/Iterator/from/wrap-method-with-non-wrap-this-throws.js
new file mode 100644
index 0000000000..7ff8539923
--- /dev/null
+++ b/js/src/tests/non262/Iterator/from/wrap-method-with-non-wrap-this-throws.js
@@ -0,0 +1,42 @@
+// |reftest| skip-if(!this.hasOwnProperty('Iterator')) -- Iterator is not enabled unconditionally
+// All methods on %WrapForValidIteratorPrototype% require an [[Iterated]]
+// internal slot on the `this` object.
+
+class TestIterator {
+ next() {
+ return {
+ done: false,
+ value: 0,
+ };
+ }
+}
+
+const nextMethod = Iterator.from(new TestIterator()).next;
+assertThrowsInstanceOf(() => nextMethod.call(undefined), TypeError);
+assertThrowsInstanceOf(() => nextMethod.call(null), TypeError);
+assertThrowsInstanceOf(() => nextMethod.call(0), TypeError);
+assertThrowsInstanceOf(() => nextMethod.call(false), TypeError);
+assertThrowsInstanceOf(() => nextMethod.call('test'), TypeError);
+assertThrowsInstanceOf(() => nextMethod.call(Object(1)), TypeError);
+assertThrowsInstanceOf(() => nextMethod.call({}), TypeError);
+
+const returnMethod = Iterator.from(new TestIterator()).next;
+assertThrowsInstanceOf(() => returnMethod.call(undefined), TypeError);
+assertThrowsInstanceOf(() => returnMethod.call(null), TypeError);
+assertThrowsInstanceOf(() => returnMethod.call(0), TypeError);
+assertThrowsInstanceOf(() => returnMethod.call(false), TypeError);
+assertThrowsInstanceOf(() => returnMethod.call('test'), TypeError);
+assertThrowsInstanceOf(() => returnMethod.call(Object(1)), TypeError);
+assertThrowsInstanceOf(() => returnMethod.call({}), TypeError);
+
+const throwMethod = Iterator.from(new TestIterator()).next;
+assertThrowsInstanceOf(() => throwMethod.call(undefined), TypeError);
+assertThrowsInstanceOf(() => throwMethod.call(null), TypeError);
+assertThrowsInstanceOf(() => throwMethod.call(0), TypeError);
+assertThrowsInstanceOf(() => throwMethod.call(false), TypeError);
+assertThrowsInstanceOf(() => throwMethod.call('test'), TypeError);
+assertThrowsInstanceOf(() => throwMethod.call(Object(1)), TypeError);
+assertThrowsInstanceOf(() => throwMethod.call({}), TypeError);
+
+if (typeof reportCompare === 'function')
+ reportCompare(0, 0);