tor-browser

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

test_objectgrips-03.js (1839B)


      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    const args = packet.frame.arguments;
     18 
     19    Assert.equal(args[0].class, "Object");
     20 
     21    const objClient = threadFront.pauseGrip(args[0]);
     22    let response = await objClient.getProperty("x");
     23    Assert.equal(response.descriptor.configurable, true);
     24    Assert.equal(response.descriptor.enumerable, true);
     25    Assert.equal(response.descriptor.writable, true);
     26    Assert.equal(response.descriptor.value, 10);
     27 
     28    response = await objClient.getProperty("y");
     29    Assert.equal(response.descriptor.configurable, true);
     30    Assert.equal(response.descriptor.enumerable, true);
     31    Assert.equal(response.descriptor.writable, true);
     32    Assert.equal(response.descriptor.value, "kaiju");
     33 
     34    response = await objClient.getProperty("a");
     35    Assert.equal(response.descriptor.configurable, true);
     36    Assert.equal(response.descriptor.enumerable, true);
     37    Assert.equal(response.descriptor.get.type, "object");
     38    Assert.equal(response.descriptor.get.class, "Function");
     39    Assert.equal(response.descriptor.set.type, "undefined");
     40 
     41    await threadFront.resume();
     42  })
     43 );
     44 
     45 function evalCode(debuggee) {
     46  debuggee.eval(
     47    // These arguments are tested.
     48    // eslint-disable-next-line no-unused-vars
     49    function stopMe(arg1) {
     50      debugger;
     51    }.toString()
     52  );
     53  debuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })");
     54 }