Frame-onStep-assign-function.js (1010B)
1 // Changing onStep 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 'onStep' while alive is allowed. 11 steps.add("debugger 1"); 12 assertEq(frame.onStack, true); 13 frame.onStep = function() { 14 steps.add("onstep 1"); 15 }; 16 17 dbg.onDebuggerStatement = function() { 18 // Clear the 'onStep' while dead. 19 steps.add("debugger 2"); 20 assertEq(frame.onStack, false); 21 22 // Clearing 'onStep' while dead is allowed. 23 frame.onStep = undefined; 24 25 // Setting 'onStep' while dead is allowed. 26 frame.onStep = function() { 27 steps.add("onstep 2"); 28 }; 29 }; 30 }; 31 32 g.eval( 33 ` 34 function myGen() { 35 debugger; 36 print("make sure we have a place to step to inside the frame"); 37 } 38 39 const g = myGen(); 40 41 debugger; 42 ` 43 ); 44 45 assertDeepEq(Array.from(steps), [ 46 "debugger 1", 47 "onstep 1", 48 "debugger 2", 49 ]);