tor-browser

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

test_dbgclient_debuggerstatement.js (966B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(
      7  Ci.nsIJSInspector
      8 );
      9 
     10 add_task(
     11  threadFrontTest(async ({ threadFront, debuggee }) => {
     12    await executeOnNextTickAndWaitForPause(
     13      () => evalCode(debuggee),
     14      threadFront
     15    );
     16 
     17    Assert.equal(threadFront.state, "paused");
     18    // Reach around the protocol to check that the debuggee is in the state
     19    // we expect.
     20    Assert.ok(debuggee.a);
     21    Assert.ok(!debuggee.b);
     22 
     23    Assert.equal(xpcInspector.eventLoopNestLevel, 1);
     24 
     25    await threadFront.resume();
     26 
     27    // Now make sure that we've run the code after the debugger statement...
     28    Assert.ok(debuggee.b);
     29 
     30    Assert.equal(xpcInspector.eventLoopNestLevel, 0);
     31  })
     32 );
     33 
     34 function evalCode(debuggee) {
     35  Cu.evalInSandbox(
     36    "var a = true; var b = false; debugger; var b = true;",
     37    debuggee
     38  );
     39 }