tor-browser

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

test_watchpoint-04.js (1706B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Test that watchpoints ignore blackboxed sources
      8 */
      9 
     10 const BLACK_BOXED_URL = "http://example.com/blackboxme.js";
     11 const SOURCE_URL = "http://example.com/source.js";
     12 
     13 add_task(
     14  threadFrontTest(async ({ threadFront, debuggee }) => {
     15    await executeOnNextTickAndWaitForPause(
     16      () => evalCode(debuggee),
     17      threadFront
     18    );
     19 
     20    info(`blackbox the source`);
     21    const { error, sources } = await threadFront.getSources();
     22    Assert.ok(!error, "Should not get an error: " + error);
     23    const sourceFront = threadFront.source(
     24      sources.filter(s => s.url == BLACK_BOXED_URL)[0]
     25    );
     26 
     27    await blackBox(sourceFront);
     28 
     29    await threadFront.resume();
     30    const packet = await executeOnNextTickAndWaitForPause(
     31      debuggee.runTest,
     32      threadFront
     33    );
     34 
     35    Assert.equal(
     36      packet.frame.where.line,
     37      3,
     38      "Paused at first debugger statement"
     39    );
     40 
     41    await addWatchpoint(threadFront, packet.frame, "obj", "a", "set");
     42 
     43    info(`Resume and skip the watchpoint`);
     44    const pausePacket = await resumeAndWaitForPause(threadFront);
     45 
     46    Assert.equal(
     47      pausePacket.frame.where.line,
     48      5,
     49      "Paused at second debugger statement"
     50    );
     51 
     52    await threadFront.resume();
     53  })
     54 );
     55 
     56 function evalCode(debuggee) {
     57  Cu.evalInSandbox(
     58    `function doStuff(obj) {
     59      obj.a = 2;
     60    }`,
     61    debuggee,
     62    "1.8",
     63    BLACK_BOXED_URL,
     64    1
     65  );
     66  Cu.evalInSandbox(
     67    `function runTest() {
     68      const obj = {a: 1}
     69      debugger
     70      doStuff(obj);
     71      debugger
     72    }; debugger;`,
     73    debuggee,
     74    "1.8",
     75    SOURCE_URL,
     76    1
     77  );
     78 }