Frame-onStep-20.js (1081B)
1 // Stepping should always pause in a frame between two function calls. 2 3 let g = newGlobal({newCompartment: true}); 4 g.evaluate(` 5 class X { 6 constructor() { this._p = 0; } 7 m() { return this; } 8 get p() { return this._p; } 9 set p(value) { this._p = value; } 10 } 11 let x = new X; 12 13 function f() { return 1; } 14 function inc(x) { return x + 1; } 15 `); 16 17 let dbg = Debugger(g); 18 19 // `code` is a snippet of JS that performs two JS calls. 20 function test(code) { 21 let hits = 0; 22 let log = ""; 23 dbg.onEnterFrame = frame => { 24 if (hits++ === 0) 25 frame.onStep = () => { log += "s"; }; 26 else 27 log += "E"; 28 }; 29 30 g.eval(code); 31 assertEq(log.includes("EE"), false, "should have received onStep between onEnterFrame events"); 32 assertEq(log.match(/^s+Es+Es*$/) !== null, true, 33 "should get two calls, with steps before, between, and possibly after"); 34 } 35 36 test("f(); f();"); 37 test("f() + f()"); 38 test("inc(f())"); 39 test("x.m().m()"); 40 test("new X().m()"); 41 test("x.p = x.p"); // getter, then setter