Frame-onStep-async-01.js (978B)
1 // Stepping works across `await` in async functions. 2 3 // Set up debuggee. 4 var g = newGlobal({newCompartment: true}); 5 g.log = ""; 6 g.eval(` // line 1 7 async function aloop() { // 2 8 for (let i = 0; i < 3; i++) { // 3 9 await i; // 4 10 log += " "; // 5 11 } // 6 12 log += "^"; // 7 13 } // 8 14 `); 15 16 // Set up debugger. 17 let previousLine = -1; 18 let dbg = new Debugger(g); 19 dbg.onEnterFrame = frame => { 20 frame.onStep = function () { 21 assertEq(this, frame); 22 let line = frame.script.getOffsetLocation(frame.offset).lineNumber; 23 if (previousLine != line) { 24 g.log += line; // We stepped to a new line. 25 previousLine = line; 26 } 27 }; 28 dbg.onEnterFrame = undefined; 29 }; 30 31 // Run. 32 g.aloop(); 33 drainJobQueue(); 34 35 assertEq(g.log, "2345 345 345 37^8");