onEnterFrame-async-resumption-08.js (1318B)
1 // Terminate execution from within the onPop handler, the result promise will 2 // never be resolved. 3 4 load(libdir + "array-compare.js"); 5 6 let g = newGlobal({newCompartment: true}); 7 let dbg = new Debugger(g); 8 9 let log = []; 10 g.log = log; 11 12 g.eval(` 13 async function f() { 14 log.push("START"); 15 await 0; 16 log.push("MIDDLE"); 17 await 0; 18 log.push("END"); 19 } 20 `); 21 22 const expectedTick1 = ["START"]; 23 const expectedTickN = [ 24 "START", 25 "enter: f", 26 "MIDDLE", 27 "pop: f", 28 ]; 29 30 Promise.resolve(0) 31 .then(() => assertEq(arraysEqual(log, expectedTick1), true)) 32 .then(() => assertEq(arraysEqual(log, expectedTickN), true)) 33 .then(() => assertEq(arraysEqual(log, expectedTickN), true)) 34 .then(() => assertEq(arraysEqual(log, expectedTickN), true)) 35 .then(() => assertEq(arraysEqual(log, expectedTickN), true)) 36 .catch(e => { 37 // Quit with non-zero exit code to ensure a test suite error is shown, 38 // even when this function is called within promise handlers which normally 39 // swallow any exceptions. 40 print("Error: " + e + "\nstack:\n" + e.stack); 41 quit(1); 42 }); 43 44 g.f(); 45 46 dbg.onEnterFrame = frame => { 47 log.push(`enter: ${frame.callee.name}`); 48 49 frame.onPop = () => { 50 log.push(`pop: ${frame.callee.name}`); 51 return null; // Terminate execution. 52 }; 53 };