tor-browser

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

test_source-02.js (1554B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // This test ensures that we can create SourceActors and SourceFronts properly,
      7 // and that they can communicate over the protocol to fetch the source text for
      8 // a given script.
      9 
     10 const SOURCE_URL = "http://example.com/foobar.js";
     11 const SOURCE_CONTENT = `
     12  stopMe();
     13  for(var i = 0; i < 2; i++) {
     14    debugger;
     15  }
     16 `;
     17 
     18 add_task(
     19  threadFrontTest(async ({ threadFront, debuggee }) => {
     20    DevToolsServer.LONG_STRING_LENGTH = 200;
     21 
     22    await executeOnNextTickAndWaitForPause(
     23      () => evaluateTestCode(debuggee),
     24      threadFront
     25    );
     26 
     27    let response = await threadFront.getSources();
     28    Assert.ok(!!response);
     29    Assert.ok(!!response.sources);
     30 
     31    const source = response.sources.filter(function (s) {
     32      return s.url === SOURCE_URL;
     33    })[0];
     34 
     35    Assert.ok(!!source);
     36 
     37    const sourceFront = threadFront.source(source);
     38    response = await sourceFront.getBreakpointPositionsCompressed();
     39    Assert.ok(!!response);
     40 
     41    Assert.deepEqual(response, {
     42      2: [2],
     43      3: [14, 17, 24],
     44      4: [4],
     45      6: [0],
     46    });
     47 
     48    await threadFront.resume();
     49  })
     50 );
     51 
     52 function evaluateTestCode(debuggee) {
     53  Cu.evalInSandbox(
     54    "" +
     55      // These arguments are tested.
     56      // eslint-disable-next-line no-unused-vars
     57      function stopMe(arg1) {
     58        debugger;
     59      },
     60    debuggee,
     61    "1.8",
     62    getFileUrl("test_source-02.js")
     63  );
     64 
     65  Cu.evalInSandbox(SOURCE_CONTENT, debuggee, "1.8", SOURCE_URL);
     66 }