tor-browser

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

test_longstringgrips-01.js (2312B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 var gDebuggee;
      7 var gClient;
      8 var gThreadFront;
      9 
     10 add_task(
     11  threadFrontTest(
     12    async ({ threadFront, debuggee, client }) => {
     13      gThreadFront = threadFront;
     14      gDebuggee = debuggee;
     15      gClient = client;
     16      test_longstring_grip();
     17    },
     18    { waitForFinish: true }
     19  )
     20 );
     21 
     22 function test_longstring_grip() {
     23  const longString =
     24    "All I want is to be a monkey of moderate intelligence who" +
     25    " wears a suit... that's why I'm transferring to business school! Maybe I" +
     26    " love you so much, I love you no matter who you are pretending to be." +
     27    " Enough about your promiscuous mother, Hermes! We have bigger problems." +
     28    " For example, if you killed your grandfather, you'd cease to exist! What" +
     29    " kind of a father would I be if I said no? Yep, I remember. They came in" +
     30    " last at the Olympics, then retired to promote alcoholic beverages! And" +
     31    " remember, don't do anything that affects anything, unless it turns out" +
     32    " you were supposed to, in which case, for the love of God, don't not do" +
     33    " it!";
     34 
     35  DevToolsServer.LONG_STRING_LENGTH = 200;
     36 
     37  gThreadFront.once("paused", function (packet) {
     38    const args = packet.frame.arguments;
     39    Assert.equal(args.length, 1);
     40    const grip = args[0];
     41 
     42    try {
     43      Assert.equal(grip.type, "longString");
     44      Assert.equal(grip.length, longString.length);
     45      Assert.equal(
     46        grip.initial,
     47        longString.substr(0, DevToolsServer.LONG_STRING_INITIAL_LENGTH)
     48      );
     49 
     50      const longStringFront = createLongStringFront(gClient, grip);
     51      longStringFront.substring(22, 28).then(function (response) {
     52        try {
     53          Assert.equal(response, "monkey");
     54        } finally {
     55          gThreadFront.resume().then(function () {
     56            finishClient(gClient);
     57          });
     58        }
     59      });
     60    } catch (error) {
     61      gThreadFront.resume().then(function () {
     62        finishClient(gClient);
     63        do_throw(error);
     64      });
     65    }
     66  });
     67 
     68  gDebuggee.eval(
     69    // These arguments are tested.
     70    // eslint-disable-next-line no-unused-vars
     71    function stopMe(arg1) {
     72      debugger;
     73    }.toString()
     74  );
     75 
     76  gDebuggee.eval('stopMe("' + longString + '")');
     77 }