Frame-onStep-17.js (976B)
1 // Test how stepping interacts with for-in/of statements. 2 3 var g = newGlobal({newCompartment: true}); 4 var dbg = new Debugger; 5 var gw = dbg.addDebuggee(g); 6 var log; 7 var previous; 8 9 dbg.onDebuggerStatement = function (frame) { 10 let debugLine = frame.script.getOffsetLocation(frame.offset).lineNumber; 11 log = ''; 12 previous = ''; 13 frame.onStep = function() { 14 let foundLine = this.script.getOffsetLocation(this.offset).lineNumber; 15 if (this.script.getLineOffsets(foundLine).indexOf(this.offset) >= 0) { 16 let thisline = (foundLine - debugLine).toString(16); 17 if (thisline !== previous) { 18 log += thisline; 19 previous = thisline; 20 } 21 } 22 }; 23 }; 24 25 function testOne(decl, loopKind) { 26 let body = "var array = [2, 4, 6];\ndebugger;\nfor (" + decl + " iter " + 27 loopKind + " array) {\n print(iter);\n}\n"; 28 g.eval(body); 29 assertEq(log, "12121214"); 30 } 31 32 for (let decl of ["", "var", "let"]) { 33 testOne(decl, "in"); 34 testOne(decl, "of"); 35 }