Debian Codegraph @

js/src/jit-test/tests/debug/Frame-onPop-assign-function.js

raw
1 // Changing onPop while the function is dead is allowed.
2
3 load(libdir + "asserts.js");
4
5 const g = newGlobal({ newCompartment: true });
6 const dbg = new Debugger(g);
7
8 let steps = new Set();
9 dbg.onDebuggerStatement = function(frame) {
10 // Setting 'onPop' while alive is allowed.
11 steps.add("debugger 1");
12 assertEq(frame.onStack, true);
13 frame.onPop = function() {
14 steps.add("onpop 1");
15 };
16
17 dbg.onDebuggerStatement = function() {
18 // Clear the 'onPop' while dead.
19 steps.add("debugger 2");
20 assertEq(frame.onStack, false);
21
22 // Clearing 'onPop' while dead is allowed.
23 frame.onPop = undefined;
24
25 // Setting 'onPop' while dead is allowed.
26 frame.onPop = function() {
27 steps.add("onpop 2");
28 };
29 };
30 };
31
32 g.eval(
33 `
34 function myGen() {
35 debugger;
36 }
37
38 const g = myGen();
39
40 debugger;
41 `
42 );
43
44 assertDeepEq(Array.from(steps), [
45 "debugger 1",
46 "onpop 1",
47 "debugger 2",
48 ]);