summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Array/unscopables.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/non262/Array/unscopables.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/Array/unscopables.js')
-rw-r--r--js/src/tests/non262/Array/unscopables.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/js/src/tests/non262/Array/unscopables.js b/js/src/tests/non262/Array/unscopables.js
new file mode 100644
index 0000000000..de970ca1bd
--- /dev/null
+++ b/js/src/tests/non262/Array/unscopables.js
@@ -0,0 +1,61 @@
+let Array_unscopables = Array.prototype[Symbol.unscopables];
+
+let desc = Reflect.getOwnPropertyDescriptor(Array.prototype, Symbol.unscopables);
+assertDeepEq(desc, {
+ value: Array_unscopables,
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+assertEq(Reflect.getPrototypeOf(Array_unscopables), null);
+
+let desc2 = Object.getOwnPropertyDescriptor(Array_unscopables, "values");
+assertDeepEq(desc2, {
+ value: true,
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+let keys = Reflect.ownKeys(Array_unscopables);
+
+// FIXME: Once bug 1826643 is fixed, change this test so that all
+// the keys are in alphabetical order
+let expectedKeys = ["at",
+ "copyWithin",
+ "entries",
+ "fill",
+ "find",
+ "findIndex",
+ "findLast",
+ "findLastIndex",
+ "flat",
+ "flatMap",
+ "includes",
+ "keys",
+ "toReversed",
+ "toSorted",
+ "toSpliced",
+ "values"];
+
+assertDeepEq(keys, expectedKeys);
+
+for (let key of keys)
+ assertEq(Array_unscopables[key], true);
+
+// Test that it actually works
+assertThrowsInstanceOf(() => {
+ with ([]) {
+ return entries;
+ }
+}, ReferenceError);
+
+{
+ let fill = 33;
+ with (Array.prototype) {
+ assertEq(fill, 33);
+ }
+}
+
+reportCompare(0, 0);