onEnterFrame-async-resumption-04.js (843B)
1 // Returning {throw:} from onEnterFrame when resuming inside a try block in an 2 // async function causes control to jump to the catch block. 3 4 let g = newGlobal({newCompartment: true}); 5 g.eval(` 6 async function af() { 7 try { 8 return await Promise.resolve("fail"); 9 } catch (exc) { 10 assertEq(exc, "fit"); 11 return "ok"; 12 } 13 } 14 `) 15 16 let dbg = new Debugger(g); 17 dbg.onEnterFrame = frame => { 18 if (!("hits" in frame)) { 19 frame.hits = 1; 20 } else if (++frame.hits === 2) { 21 // First hit happens when g.af() is called; 22 // second hit is resuming at the `await` inside the try block. 23 return {throw: "fit"}; 24 } 25 }; 26 27 let p = g.af(); 28 let hits = 0; 29 p.then(value => { 30 result = value; 31 hits++; 32 }); 33 drainJobQueue(); 34 assertEq(hits, 1); 35 assertEq(result, "ok");