Frame-onPop-async-01.js (949B)
1 // When an async function awaits, if Frame.onPop processes microtasks, 2 // the async function itself will not run. It'll run later. 3 // 4 // This is a reentrancy test, like Frame-onPop-generators-03. 5 6 let g = newGlobal({newCompartment: true}); 7 g.log = ""; 8 g.eval(` 9 async function f() { 10 log += "1"; 11 debugger; 12 log += "2"; 13 await Promise.resolve(3); 14 log += "3"; 15 return "ok"; 16 } 17 `); 18 19 let dbg = Debugger(g); 20 dbg.onDebuggerStatement = frame => { 21 frame.onPop = completion => { 22 // What we are really testing is that when onPop is called, we have not 23 // yet thrown this async function activation back into the hopper. 24 g.log += 'A'; 25 drainJobQueue(); 26 g.log += 'B'; 27 28 frame.onPop = completion => { 29 g.log += 'C'; 30 }; 31 }; 32 }; 33 34 let status = "FAIL - g.f() did not resolve"; 35 g.f().then(value => { status = value; }); 36 assertEq(g.log, "12AB"); 37 drainJobQueue(); 38 assertEq(g.log, "12AB3C"); 39 assertEq(status, "ok");