tor-browser

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

test_stepping-15.js (2237B)


      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 stepping from inside a blackboxed function
      8 * test-page: https://dbg-blackbox-stepping.glitch.me/
      9 */
     10 
     11 async function invokeAndPause({ global, threadFront }, expression, url) {
     12  return executeOnNextTickAndWaitForPause(
     13    () => Cu.evalInSandbox(expression, global, "1.8", url, 1),
     14    threadFront
     15  );
     16 }
     17 add_task(
     18  threadFrontTest(async ({ commands, threadFront, debuggee }) => {
     19    const dbg = { global: debuggee, threadFront };
     20 
     21    // Test stepping from a blackboxed location
     22    async function testStepping(action, expectedLine) {
     23      commands.scriptCommand.execute(`outermost()`);
     24      await waitForPause(threadFront);
     25      await blackBox(blackboxedSourceFront);
     26      const packet = await action(threadFront);
     27      const { line, actor } = packet.frame.where;
     28      equal(actor, unblackboxedActor, "paused in unblackboxed source");
     29      equal(line, expectedLine, "paused at correct line");
     30      await threadFront.resume();
     31      await unBlackBox(blackboxedSourceFront);
     32    }
     33 
     34    invokeAndPause(
     35      dbg,
     36      `function outermost() {
     37        const value = blackboxed1();
     38        return value + 1;
     39      }
     40      function innermost() {
     41        return 1;
     42      }`,
     43      "http://example.com/unblackboxed.js"
     44    );
     45    invokeAndPause(
     46      dbg,
     47      `function blackboxed1() {
     48        return blackboxed2();
     49      }
     50      function blackboxed2() {
     51        return innermost();
     52      }`,
     53      "http://example.com/blackboxed.js"
     54    );
     55 
     56    const { sources } = await getSources(threadFront);
     57    const blackboxedSourceFront = threadFront.source(
     58      sources.find(source => source.url == "http://example.com/blackboxed.js")
     59    );
     60    const unblackboxedActor = sources.find(
     61      source => source.url == "http://example.com/unblackboxed.js"
     62    ).actor;
     63 
     64    await setBreakpoint(threadFront, {
     65      sourceUrl: blackboxedSourceFront.url,
     66      line: 5,
     67    });
     68 
     69    info("Step Out to outermost");
     70    await testStepping(stepOut, 3);
     71 
     72    info("Step Over to outermost");
     73    await testStepping(stepOver, 3);
     74 
     75    info("Step In to innermost");
     76    await testStepping(stepIn, 6);
     77  })
     78 );