tor-browser

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

test_framebindings-02.js (1729B)


      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 a frame actor's parent bindings.
      8 */
      9 
     10 add_task(
     11  threadFrontTest(async ({ threadFront, debuggee }) => {
     12    const packet = await executeOnNextTickAndWaitForPause(
     13      () => evalCode(debuggee),
     14      threadFront
     15    );
     16 
     17    const environment = await packet.frame.getEnvironment();
     18    let parentEnv = environment.parent;
     19    const bindings = parentEnv.bindings;
     20    const args = bindings.arguments;
     21    const vars = bindings.variables;
     22    Assert.notEqual(parentEnv, undefined);
     23    Assert.equal(args.length, 0);
     24    Assert.equal(vars.stopMe.value.type, "object");
     25    Assert.equal(vars.stopMe.value.class, "Function");
     26    Assert.ok(!!vars.stopMe.value.actor);
     27 
     28    // Skip the global lexical scope.
     29    parentEnv = parentEnv.parent.parent;
     30    Assert.notEqual(parentEnv, undefined);
     31    const objClient = threadFront.pauseGrip(parentEnv.object);
     32    const response = await objClient.getPrototypeAndProperties();
     33    Assert.equal(response.ownProperties.Object.value.getGrip().type, "object");
     34    Assert.equal(
     35      response.ownProperties.Object.value.getGrip().class,
     36      "Function"
     37    );
     38    Assert.ok(!!response.ownProperties.Object.value.actorID);
     39 
     40    await threadFront.resume();
     41  })
     42 );
     43 
     44 function evalCode(debuggee) {
     45  /* eslint-disable */
     46  debuggee.eval(
     47    "(" +
     48      function () {
     49        function stopMe(number, bool, string, null_, undef, object) {
     50          var a = 1;
     51          var b = true;
     52          var c = { a: "a" };
     53          eval("");
     54          debugger;
     55        }
     56        stopMe(42, true, "nasu", null, undefined, { foo: "bar" });
     57      } +
     58      ")()"
     59  );
     60 }