tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

onDebuggerStatement-async-resumption-02.js (844B)


      1 // |jit-test| error:all-jobs-completed-successfully
      2 // Verifiy that onDebuggerStatement'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    debugger;
     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 debugger runs after await resume.
     20  dbg.onDebuggerStatement = () => {
     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 })();