Debian Codegraph @

js/src/jit-test/tests/debug/Frame-newTargetEval-02.js

raw
1 // Test that new.target is acceptably usable in RematerializedFrames.
2
3 gczeal(0);
4
5 load(libdir + "jitopts.js");
6
7 if (!jitTogglesMatch(Opts_Ion2NoOffthreadCompilation))
8 quit();
9
10 withJitOptions(Opts_Ion2NoOffthreadCompilation, function () {
11 var g = newGlobal({newCompartment: true});
12 var dbg = new Debugger;
13
14 g.toggle = function toggle(d, expected) {
15 if (d) {
16 dbg.addDebuggee(g);
17
18 var frame = dbg.getNewestFrame();
19 assertEq(frame.implementation, "ion");
20
21 // the arrow function will not be constructing, even though it has a
22 // new.target value.
23 assertEq(frame.constructing, false);
24
25 // CONGRATS IF THIS FAILS! You, proud saviour, have made new.target parse
26 // in debug frame evals (presumably by hooking up static scope walks).
27 // Uncomment the assert below for efaust's undying gratitude.
28 // Note that we use .name here because of CCW nonsense.
29 assertEq(frame.eval('new.target').throw.unsafeDereference().name, "SyntaxError");
30 // assertEq(frame.eval('new.target').return.unsafeDereference(), expected);
31 }
32 };
33
34 g.eval("" + function f(d) { new g(d, g, 15); });
35
36 g.eval("" + function g(d, expected) { (() => toggle(d, expected))(); });
37
38 g.eval("(" + function test() {
39 for (var i = 0; i < 5; i++)
40 f(false);
41 f(true);
42 } + ")();");
43 });