tor-browser

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

test_pauselifetime-02.js (1563B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Check that pause-lifetime grips go away correctly after a resume.
      8 */
      9 
     10 add_task(
     11  threadFrontTest(async ({ threadFront, debuggee, client }) => {
     12    const packet = await executeOnNextTickAndWaitForPause(
     13      () => evaluateTestCode(debuggee),
     14      threadFront
     15    );
     16 
     17    const args = packet.frame.arguments;
     18    const objActor = args[0].actor;
     19    Assert.equal(args[0].class, "Object");
     20    Assert.ok(!!objActor);
     21 
     22    // Make a bogus request to the grip actor. Should get
     23    // unrecognized-packet-type (and not no-such-actor).
     24    try {
     25      await client.request({ to: objActor, type: "bogusRequest" });
     26      ok(false, "bogusRequest should throw");
     27    } catch (e) {
     28      ok(true, "bogusRequest thrown");
     29      Assert.equal(e.error, "unrecognizedPacketType");
     30    }
     31 
     32    await threadFront.resume();
     33 
     34    // Now that we've resumed, should get no-such-actor for the
     35    // same request.
     36    try {
     37      await client.request({ to: objActor, type: "bogusRequest" });
     38      ok(false, "bogusRequest should throw");
     39    } catch (e) {
     40      ok(true, "bogusRequest thrown");
     41      Assert.equal(e.error, "noSuchActor");
     42    }
     43  })
     44 );
     45 
     46 function evaluateTestCode(debuggee) {
     47  debuggee.eval(
     48    "(" +
     49      function () {
     50        // These arguments are tested.
     51        // eslint-disable-next-line no-unused-vars
     52        function stopMe(obj) {
     53          debugger;
     54        }
     55        stopMe({ foo: "bar" });
     56      } +
     57      ")()"
     58  );
     59 }