diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/jit-test/tests/parser/bug-1431353-2.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/parser/bug-1431353-2.js')
-rw-r--r-- | js/src/jit-test/tests/parser/bug-1431353-2.js | 55 |
1 files changed, 55 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..f4a8017fb4 --- /dev/null +++ b/js/src/jit-test/tests/parser/bug-1431353-2.js @@ -0,0 +1,55 @@ +// |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) +{ + offThreadCompileScript(source); + return runOffThreadScript(); +} + +function parseModuleOffThread(source) +{ + offThreadCompileModule(source); + return finishOffThreadModule(); +} + +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)); |