Frame-onStep-08.js (824B)
1 // frame.onStep can coexist with breakpoints. 2 3 var g = newGlobal({newCompartment: true}); 4 var dbg = Debugger(g); 5 var log = ''; 6 dbg.onEnterFrame = function (frame) { 7 var handler = {hit: function () { log += 'B'; }}; 8 var lines = frame.script.getAllOffsets(); 9 for (var line in lines) { 10 line = Number(line); 11 var offs = lines[line]; 12 for (var i = 0; i < offs.length; i++) 13 frame.script.setBreakpoint(offs[i], handler); 14 } 15 16 frame.onStep = function () { log += 's'; }; 17 }; 18 19 g.eval("one = 1;\n" + 20 "two = 2;\n" + 21 "three = 3;\n" + 22 "four = 4;\n"); 23 assertEq(g.four, 4); 24 25 // Breakpoints hit on all four lines, plus the final line. 26 assertEq(log.replace(/[^B]/g, ''), 'BBBBB'); 27 28 // onStep was called between each pair of breakpoints. 29 assertEq(/BB/.exec(log), null);