tor-browser

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

test_conditional_breakpoint-04.js (1494B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Confirm that conditional breakpoint are triggered in case of exceptions,
      8 * even when pause-on-exceptions is disabled.
      9 */
     10 
     11 add_task(
     12  threadFrontTest(async ({ threadFront, debuggee }) => {
     13    await threadFront.setBreakpoint(
     14      { sourceUrl: "conditional_breakpoint-04.js", line: 3 },
     15      { condition: "throw new Error()" }
     16    );
     17 
     18    const packet = await executeOnNextTickAndWaitForPause(
     19      () => evalCode(debuggee),
     20      threadFront
     21    );
     22 
     23    Assert.equal(packet.frame.where.line, 1);
     24    Assert.equal(packet.why.type, "debuggerStatement");
     25 
     26    const pausedPacket = await resumeAndWaitForPause(threadFront);
     27    Assert.equal(pausedPacket.frame.where.line, 3);
     28    Assert.equal(pausedPacket.why.type, "breakpointConditionThrown");
     29 
     30    const secondPausedPacket = await resumeAndWaitForPause(threadFront);
     31    Assert.equal(secondPausedPacket.frame.where.line, 4);
     32    Assert.equal(secondPausedPacket.why.type, "debuggerStatement");
     33 
     34    // Remove the breakpoint.
     35    await threadFront.removeBreakpoint({
     36      sourceUrl: "conditional_breakpoint-04.js",
     37      line: 3,
     38    });
     39    await threadFront.resume();
     40  })
     41 );
     42 
     43 function evalCode(debuggee) {
     44  /* eslint-disable */
     45  Cu.evalInSandbox(
     46    `debugger;
     47    var a = 1;
     48    var b = 2;
     49    debugger;`,
     50    debuggee,
     51    "1.8",
     52    "conditional_breakpoint-04.js",
     53    1
     54  );
     55  /* eslint-enable */
     56 }