tor-browser

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

breakpoint-resume-04.js (1016B)


      1 // |jit-test| error:all-jobs-completed-successfully
      2 // Verifiy that a breakpoints force-return queues the promise microtask to run
      3 // 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 await resumes and steps.
     20  dbg.onEnterFrame = frame => {
     21    dbg.onEnterFrame = undefined;
     22    const bps = frame.script.getPossibleBreakpoints({ line: 4 });
     23    assertEq(bps.length, 1);
     24    frame.script.setBreakpoint(bps[0].offset, {
     25      hit: () => ({ return: "exit" })
     26    });
     27  };
     28 
     29  const result = await it;
     30  assertEq(result, "exit");
     31  // If execution here is resumed from the debugger's queue, this call will
     32  // trigger DebuggeeWouldRun exception.
     33  g.enterDebuggee();
     34 
     35 
     36  throw "all-jobs-completed-successfully";
     37 })();