tor-browser

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

test_conditional_breakpoint-03.js (1451B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * If pauseOnExceptions is checked, when condition throws,
      8 * make sure conditional breakpoint pauses but doesn't trigger an exception breakpoint.
      9 */
     10 
     11 add_task(
     12  threadFrontTest(async ({ threadFront, debuggee, commands }) => {
     13    const packet1 = await executeOnNextTickAndWaitForPause(
     14      () => evalCode(debuggee),
     15      threadFront
     16    );
     17 
     18    const source = await getSourceById(threadFront, packet1.frame.where.actor);
     19 
     20    await commands.threadConfigurationCommand.updateConfiguration({
     21      pauseOnExceptions: true,
     22      ignoreCaughtExceptions: false,
     23    });
     24    const location = { sourceUrl: source.url, line: 3 };
     25    threadFront.setBreakpoint(location, { condition: "throw new Error()" });
     26 
     27    // Continue until the breakpoint is hit.
     28    const packet2 = await resumeAndWaitForPause(threadFront);
     29 
     30    // Check the return value.
     31    Assert.equal(packet2.why.type, "breakpointConditionThrown");
     32    Assert.equal(packet2.frame.where.line, 3);
     33 
     34    // Remove the breakpoint.
     35    await threadFront.removeBreakpoint(location);
     36    await threadFront.resume();
     37  })
     38 );
     39 
     40 function evalCode(debuggee) {
     41  /* eslint-disable */
     42  Cu.evalInSandbox(
     43    "debugger;\n" + // line 1
     44      "var a = 1;\n" + // line 2
     45      "var b = 2;\n", // line 3
     46    debuggee,
     47    "1.8",
     48    "test.js",
     49    1
     50  );
     51  /* eslint-enable */
     52 }