tor-browser

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

test_breakpoint-08.js (2826B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 /* eslint-disable no-shadow, max-nested-callbacks */
      4 
      5 "use strict";
      6 
      7 /**
      8 * Check that setting a breakpoint in a line without code in a child script
      9 * will skip forward, in a file with two scripts.
     10 */
     11 
     12 add_task(
     13  threadFrontTest(({ threadFront, debuggee }) => {
     14    return new Promise(resolve => {
     15      threadFront.once("paused", async function (packet) {
     16        const line = debuggee.line0 + 3;
     17        const source = await getSourceById(
     18          threadFront,
     19          packet.frame.where.actor
     20        );
     21 
     22        // this test has been disabled for a long time so the functionality doesn't work
     23        const response = await threadFront.setBreakpoint(
     24          { sourceUrl: source.url, line },
     25          {}
     26        );
     27        // check that the breakpoint has properly skipped forward one line.
     28        assert.equal(response.actuallocation.source.actor, source.actor);
     29        // This is wrong - location is not defined, but the test has been disabled
     30        // for a long time and currently doesn't work.
     31        // eslint-disable-next-line no-undef
     32        Assert.equal(response.actualLocation.line, location.line + 1);
     33 
     34        threadFront.once("paused", function (packet) {
     35          // Check the return value.
     36          Assert.equal(packet.frame.where.actor, source.actor);
     37          // eslint-disable-next-line no-undef
     38          Assert.equal(packet.frame.where.line, location.line + 1);
     39          Assert.equal(packet.why.type, "breakpoint");
     40          Assert.equal(packet.why.actors[0], response.bpClient.actor);
     41          // Check that the breakpoint worked.
     42          Assert.equal(debuggee.a, 1);
     43          Assert.equal(debuggee.b, undefined);
     44 
     45          // Remove the breakpoint.
     46          response.bpClient.remove(function () {
     47            threadFront.resume().then(resolve);
     48          });
     49        });
     50 
     51        // Continue until the breakpoint is hit.
     52        threadFront.resume();
     53      });
     54 
     55      // prettier-ignore
     56      Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
     57                       "function foo() {\n" + // line0 + 1
     58                       "  this.a = 1;\n" +    // line0 + 2
     59                       "  // A comment.\n" +  // line0 + 3
     60                       "  this.b = 2;\n" +    // line0 + 4
     61                       "}\n",                 // line0 + 5
     62                       debuggee,
     63                       "1.7",
     64                       "script1.js");
     65 
     66      // prettier-ignore
     67      Cu.evalInSandbox("var line1 = Error().lineNumber;\n" +
     68                       "debugger;\n" +        // line1 + 1
     69                       "foo();\n",           // line1 + 2
     70                       debuggee,
     71                       "1.7",
     72                       "script2.js");
     73    });
     74  })
     75 );