summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/parser/bug-1431353-2.js
blob: 67e05d77a13b42fbd3a1411ca899582465af6db5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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));