tor-browser

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

test_objectgrips-08.js (1614B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
      7 registerCleanupFunction(() => {
      8  Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
      9 });
     10 
     11 add_task(
     12  threadFrontTest(async ({ threadFront, debuggee }) => {
     13    const packet = await executeOnNextTickAndWaitForPause(
     14      () => evalCode(debuggee),
     15      threadFront
     16    );
     17 
     18    const args = packet.frame.arguments;
     19 
     20    Assert.equal(args[0].class, "Object");
     21 
     22    const objClient = threadFront.pauseGrip(args[0]);
     23    const response = await objClient.getPrototypeAndProperties();
     24    const { a, b, c, d, e, f, g } = response.ownProperties;
     25    testPropertyType(a, "Infinity");
     26    testPropertyType(b, "-Infinity");
     27    testPropertyType(c, "NaN");
     28    testPropertyType(d, "-0");
     29    testPropertyType(e, "BigInt");
     30    testPropertyType(f, "BigInt");
     31    testPropertyType(g, "BigInt");
     32 
     33    await threadFront.resume();
     34  })
     35 );
     36 
     37 function evalCode(debuggee) {
     38  debuggee.eval(
     39    // These arguments are tested.
     40    // eslint-disable-next-line no-unused-vars
     41    function stopMe(arg1) {
     42      debugger;
     43    }.toString()
     44  );
     45  debuggee.eval(
     46    `stopMe({
     47      a: Infinity,
     48      b: -Infinity,
     49      c: NaN,
     50      d: -0,
     51      e: 1n,
     52      f: -2n,
     53      g: 0n,
     54    })`
     55  );
     56 }
     57 
     58 function testPropertyType(prop, expectedType) {
     59  Assert.equal(prop.configurable, true);
     60  Assert.equal(prop.enumerable, true);
     61  Assert.equal(prop.writable, true);
     62  Assert.equal(prop.value.type, expectedType);
     63 }