tor-browser

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

test_threadlifetime-01.js (1586B)


      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 thread-lifetime grips last past 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 pauseGrip = packet.frame.arguments[0];
     18 
     19    // Create a thread-lifetime actor for this object.
     20    const response = await client.request({
     21      to: pauseGrip.actor,
     22      type: "threadGrip",
     23    });
     24    // Successful promotion won't return an error.
     25    Assert.equal(response.error, undefined);
     26 
     27    const packet2 = await resumeAndWaitForPause(threadFront);
     28 
     29    // Verify that the promoted actor is returned again.
     30    Assert.equal(pauseGrip.actor, packet2.frame.arguments[0].actor);
     31    // Now that we've resumed, should get unrecognizePacketType for the
     32    // promoted grip.
     33    try {
     34      await client.request({ to: pauseGrip.actor, type: "bogusRequest" });
     35      ok(false, "bogusRequest should throw");
     36    } catch (e) {
     37      Assert.equal(e.error, "unrecognizedPacketType");
     38      ok(true, "bogusRequest thrown");
     39    }
     40    await threadFront.resume();
     41  })
     42 );
     43 
     44 function evaluateTestCode(debuggee) {
     45  debuggee.eval(
     46    "(" +
     47      function () {
     48        // These arguments are tested.
     49        // eslint-disable-next-line no-unused-vars
     50        function stopMe(arg1) {
     51          debugger;
     52          debugger;
     53        }
     54        stopMe({ obj: true });
     55      } +
     56      ")()"
     57  );
     58 }