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/non262/TypedArray/from_realms.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/tests/non262/TypedArray/from_realms.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/js/src/tests/non262/TypedArray/from_realms.js b/js/src/tests/non262/TypedArray/from_realms.js new file mode 100644 index 0000000000..590589392f --- /dev/null +++ b/js/src/tests/non262/TypedArray/from_realms.js @@ -0,0 +1,32 @@ +for (var constructor of anyTypedArrayConstructors) { + if (typeof newGlobal !== 'function') + break; + + // G[constructor.name].from, where G is any global, produces an array whose prototype + // is G[constructor.name].prototype. + var g = newGlobal(); + var ga = g[constructor.name].from([1, 2, 3]); + assertEq(ga instanceof g[constructor.name], true); + + // %TypedArray%.from can be applied to a constructor from another realm. + var p = constructor.from.call(g[constructor.name], [1, 2, 3]); + assertEq(p instanceof g[constructor.name], true); + var q = g[constructor.name].from.call(constructor, [3, 4, 5]); + assertEq(q instanceof constructor, true); + + // The default 'this' value received by a non-strict mapping function is + // that function's global, not %TypedArray%.from's global or the caller's global. + var h = newGlobal(), result = undefined; + h.mainGlobal = this; + h.eval("function f() { mainGlobal.result = this; }"); + g[constructor.name].from.call(constructor, [5, 6, 7], h.f); + // (Give each global in the test a name, for better error messages. But use + // globalName, because window.name is complicated.) + this.globalName = "main"; + g.globalName = "g"; + h.globalName = "h"; + assertEq(result.globalName, "h"); +} + +if (typeof reportCompare === "function") + reportCompare(true, true); |