tor-browser

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

test_framebindings-01.js (2314B)


      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 bindings property.
      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    const bindings = environment.bindings;
     19    const args = bindings.arguments;
     20    const vars = bindings.variables;
     21 
     22    Assert.equal(args.length, 6);
     23    Assert.equal(args[0].number.value, 42);
     24    Assert.equal(args[1].bool.value, true);
     25    Assert.equal(args[2].string.value, "nasu");
     26    Assert.equal(args[3].null_.value.type, "null");
     27    Assert.equal(args[4].undef.value.type, "undefined");
     28    Assert.equal(args[5].object.value.type, "object");
     29    Assert.equal(args[5].object.value.class, "Object");
     30    Assert.ok(!!args[5].object.value.actor);
     31 
     32    Assert.equal(vars.a.value, 1);
     33    Assert.equal(vars.b.value, true);
     34    Assert.equal(vars.c.value.type, "object");
     35    Assert.equal(vars.c.value.class, "Object");
     36    Assert.ok(!!vars.c.value.actor);
     37 
     38    const objClient = threadFront.pauseGrip(vars.c.value);
     39    const response = await objClient.getPrototypeAndProperties();
     40    Assert.equal(response.ownProperties.a.configurable, true);
     41    Assert.equal(response.ownProperties.a.enumerable, true);
     42    Assert.equal(response.ownProperties.a.writable, true);
     43    Assert.equal(response.ownProperties.a.value, "a");
     44 
     45    Assert.equal(response.ownProperties.b.configurable, true);
     46    Assert.equal(response.ownProperties.b.enumerable, true);
     47    Assert.equal(response.ownProperties.b.writable, true);
     48    Assert.equal(response.ownProperties.b.value.type, "undefined");
     49    Assert.equal(false, "class" in response.ownProperties.b.value);
     50 
     51    await threadFront.resume();
     52  })
     53 );
     54 
     55 function evalCode(debuggee) {
     56  /* eslint-disable */
     57  debuggee.eval(
     58    "(" +
     59      function () {
     60        function stopMe(number, bool, string, null_, undef, object) {
     61          var a = 1;
     62          var b = true;
     63          var c = { a: "a", b: undefined };
     64          debugger;
     65        }
     66        stopMe(42, true, "nasu", null, undefined, { foo: "bar" });
     67      } +
     68      ")()"
     69  );
     70  /* eslint-enable */
     71 }