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
|
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell)
let sr = new ShadowRealm();
try {
sr.evaluate("var x /");
assertEq(true, false, "Should have thrown");
} catch (e) {
assertEq(e instanceof SyntaxError, true, "Same Global Error")
assertEq(/unterminated regular expression literal/.test(e.message), true, "Should have reported a sensible error message");
}
try {
sr.evaluate("var x =");
assertEq(true, false, "Should have thrown");
} catch (e) {
assertEq(e instanceof SyntaxError, true, "Same Global Error")
assertEq(/expected expression/.test(e.message), true, "Should have reported a sensible error message");
}
try {
sr.evaluate("#x in this");
assertEq(true, false, "Should have thrown");
} catch (e) {
assertEq(e instanceof SyntaxError, true, "Same Global Error")
assertEq(/reference to undeclared private field or method/.test(e.message), true, "Should have reported a sensible error message");
}
if (typeof reportCompare === 'function')
reportCompare(true, true);
|