summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/parser/bug-1431353-2.js
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/jit-test/tests/parser/bug-1431353-2.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.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/jit-test/tests/parser/bug-1431353-2.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/parser/bug-1431353-2.js b/js/src/jit-test/tests/parser/bug-1431353-2.js
new file mode 100644
index 0000000000..67e05d77a1
--- /dev/null
+++ b/js/src/jit-test/tests/parser/bug-1431353-2.js
@@ -0,0 +1,57 @@
+// |jit-test| skip-if: helperThreadCount() === 0
+
+// Test off-thread parsing correctly fixes up prototypes of special objects when
+// merging back to the target compartment.
+
+function execOffThread(source)
+{
+ offThreadCompileToStencil(source);
+ var stencil = finishOffThreadStencil();
+ return evalStencil(stencil);
+}
+
+function parseModuleOffThread(source)
+{
+ offThreadCompileModuleToStencil(source);
+ var stencil = finishOffThreadStencil();
+ return instantiateModuleStencil(stencil);
+}
+
+let a = { x: 1 };
+let b = execOffThread("undefined, { x: 1 }")
+let c = execOffThread("undefined, { x: 1 }")
+
+assertEq(Object.getPrototypeOf(a), Object.prototype);
+assertEq(Object.getPrototypeOf(b), Object.prototype);
+assertEq(Object.getPrototypeOf(c), Object.prototype);
+
+a = () => 1;
+b = execOffThread("() => 1")
+c = execOffThread("() => 1")
+
+assertEq(Object.getPrototypeOf(a), Function.prototype);
+assertEq(Object.getPrototypeOf(b), Function.prototype);
+assertEq(Object.getPrototypeOf(c), Function.prototype);
+
+a = [1, 2, 3];
+b = execOffThread("[1, 2, 3]")
+c = execOffThread("[1, 2, 3]")
+
+assertEq(Object.getPrototypeOf(a), Array.prototype);
+assertEq(Object.getPrototypeOf(b), Array.prototype);
+assertEq(Object.getPrototypeOf(c), Array.prototype);
+
+a = /a/;
+b = execOffThread("/a/")
+c = execOffThread("/a/")
+
+assertEq(Object.getPrototypeOf(a), RegExp.prototype);
+assertEq(Object.getPrototypeOf(b), RegExp.prototype);
+assertEq(Object.getPrototypeOf(c), RegExp.prototype);
+
+a = parseModule("");
+b = parseModuleOffThread("");
+c = parseModuleOffThread("");
+
+assertEq(Object.getPrototypeOf(b), Object.getPrototypeOf(a));
+assertEq(Object.getPrototypeOf(c), Object.getPrototypeOf(a));