tor-browser

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

test_pauselifetime-01.js (1360B)


      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 pauseActor = packet.actor;
     18 
     19    // Make a bogus request to the pause-lifetime actor. Should get
     20    // unrecognized-packet-type (and not no-such-actor).
     21    try {
     22      await client.request({ to: pauseActor, type: "bogusRequest" });
     23      ok(false, "bogusRequest should throw");
     24    } catch (e) {
     25      ok(true, "bogusRequest thrown");
     26      Assert.equal(e.error, "unrecognizedPacketType");
     27    }
     28 
     29    await threadFront.resume();
     30 
     31    // Now that we've resumed, should get no-such-actor for the
     32    // same request.
     33    try {
     34      await client.request({ to: pauseActor, type: "bogusRequest" });
     35      ok(false, "bogusRequest should throw");
     36    } catch (e) {
     37      ok(true, "bogusRequest thrown");
     38      Assert.equal(e.error, "noSuchActor");
     39    }
     40  })
     41 );
     42 
     43 function evaluateTestCode(debuggee) {
     44  debuggee.eval(
     45    "(" +
     46      function () {
     47        function stopMe() {
     48          debugger;
     49        }
     50        stopMe();
     51      } +
     52      ")()"
     53  );
     54 }