tor-browser

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

test_objectgrips-07.js (1606B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * This test checks that objects which are not extensible report themselves as
      8 * such.
      9 */
     10 
     11 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
     12 registerCleanupFunction(() => {
     13  Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
     14 });
     15 
     16 add_task(
     17  threadFrontTest(async ({ threadFront, debuggee }) => {
     18    const packet = await executeOnNextTickAndWaitForPause(
     19      () => evalCode(debuggee),
     20      threadFront
     21    );
     22 
     23    const [f, s, ne, e] = packet.frame.arguments;
     24    const [fClient, sClient, neClient, eClient] = packet.frame.arguments.map(
     25      a => threadFront.pauseGrip(a)
     26    );
     27 
     28    Assert.ok(!f.extensible);
     29    Assert.ok(!fClient.isExtensible);
     30 
     31    Assert.ok(!s.extensible);
     32    Assert.ok(!sClient.isExtensible);
     33 
     34    Assert.ok(!ne.extensible);
     35    Assert.ok(!neClient.isExtensible);
     36 
     37    Assert.ok(e.extensible);
     38    Assert.ok(eClient.isExtensible);
     39 
     40    await threadFront.resume();
     41  })
     42 );
     43 
     44 function evalCode(debuggee) {
     45  debuggee.eval(
     46    // These arguments are tested.
     47    // eslint-disable-next-line no-unused-vars
     48    function stopMe(arg1) {
     49      debugger;
     50    }.toString()
     51  );
     52  /* eslint-disable no-undef */
     53  debuggee.eval(
     54    "(" +
     55      function () {
     56        const f = {};
     57        Object.freeze(f);
     58        const s = {};
     59        Object.seal(s);
     60        const ne = {};
     61        Object.preventExtensions(ne);
     62        stopMe(f, s, ne, {});
     63      } +
     64      "())"
     65  );
     66  /* eslint-enable no-undef */
     67 }