diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/non262/WeakMap | |
parent | Initial commit. (diff) | |
download | firefox-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/WeakMap')
-rw-r--r-- | js/src/tests/non262/WeakMap/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/non262/WeakMap/shell.js | 0 | ||||
-rw-r--r-- | js/src/tests/non262/WeakMap/symbols.js | 21 | ||||
-rw-r--r-- | js/src/tests/non262/WeakMap/symbols_not_as_weakmap_keys.js | 8 |
4 files changed, 29 insertions, 0 deletions
diff --git a/js/src/tests/non262/WeakMap/browser.js b/js/src/tests/non262/WeakMap/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/non262/WeakMap/browser.js diff --git a/js/src/tests/non262/WeakMap/shell.js b/js/src/tests/non262/WeakMap/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/non262/WeakMap/shell.js diff --git a/js/src/tests/non262/WeakMap/symbols.js b/js/src/tests/non262/WeakMap/symbols.js new file mode 100644 index 0000000000..92d8412f47 --- /dev/null +++ b/js/src/tests/non262/WeakMap/symbols.js @@ -0,0 +1,21 @@ +// |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(!xulRuntime.shell||!(this.hasOwnProperty('getBuildConfiguration')&&!getBuildConfiguration('release_or_beta'))) -- requires shell-options +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ */ + +var m = new WeakMap; +var sym = Symbol(); +m.set(sym, 0); +assertEq(m.get(sym), 0); + +// sym1 will be registered in global Symbol registry hence cannot be used as a +// key in WeakMap. +var sym1 = Symbol.for("testKey"); +assertThrowsInstanceOf(() => m.set(sym1, 1), TypeError); + +// Well-known symbols can be used as weakmap keys. +var sym2 = Symbol.hasInstance; +m.set(sym2, 2); +assertEq(m.get(sym2), 2); + +if (typeof reportCompare === "function") + reportCompare(0, 0); diff --git a/js/src/tests/non262/WeakMap/symbols_not_as_weakmap_keys.js b/js/src/tests/non262/WeakMap/symbols_not_as_weakmap_keys.js new file mode 100644 index 0000000000..682bd6b02f --- /dev/null +++ b/js/src/tests/non262/WeakMap/symbols_not_as_weakmap_keys.js @@ -0,0 +1,8 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ */ +var m = new WeakMap; +var sym = Symbol(); +assertThrowsInstanceOf(() => m.set(sym, 0), TypeError); + +if (typeof reportCompare === "function") + reportCompare(0, 0); |