Debian Codegraph @

js/src/jit-test/tests/debug/onExceptionUnwind-resumption-async-02.js

raw
1 // |jit-test| error:all-jobs-completed-successfully
2 // Verifiy that onExceptionUnwind's force-return queues the promise
3 // microtask to run in the debuggee's job queue, not the debugger's
4 // AutoDebuggerJobQueueInterruption.
5
6 let g = newGlobal({ newCompartment: true });
7 g.eval(`
8 async function asyncFn(x) {
9 await Promise.resolve();
10 throw new Error();
11 }
12 function enterDebuggee(){}
13 `);
14 const dbg = new Debugger(g);
15
16 (async function() {
17 let it = g.asyncFn();
18
19 // Force-return when the exception throws after await resume.
20 dbg.onExceptionUnwind = () => {
21 return { return: "exit" };
22 };
23
24 const result = await it;
25 assertEq(result, "exit");
26 // If execution here is resumed from the debugger's queue, this call will
27 // trigger DebuggeeWouldRun exception.
28 g.enterDebuggee();
29
30 throw "all-jobs-completed-successfully";
31 })();