tor-browser

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

test_objectgrips-05.js (1377B)


      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 frozen objects report themselves as frozen in their
      8 * grip.
      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 obj1 = packet.frame.arguments[0];
     24    Assert.ok(obj1.frozen);
     25 
     26    const obj1Client = threadFront.pauseGrip(obj1);
     27    Assert.ok(obj1Client.isFrozen);
     28 
     29    const obj2 = packet.frame.arguments[1];
     30    Assert.ok(!obj2.frozen);
     31 
     32    const obj2Client = threadFront.pauseGrip(obj2);
     33    Assert.ok(!obj2Client.isFrozen);
     34 
     35    await threadFront.resume();
     36  })
     37 );
     38 
     39 function evalCode(debuggee) {
     40  debuggee.eval(
     41    // These arguments are tested.
     42    // eslint-disable-next-line no-unused-vars
     43    function stopMe(arg1) {
     44      debugger;
     45    }.toString()
     46  );
     47  /* eslint-disable no-undef */
     48  debuggee.eval(
     49    "(" +
     50      function () {
     51        const obj1 = {};
     52        Object.freeze(obj1);
     53        stopMe(obj1, {});
     54      } +
     55      "())"
     56  );
     57  /* eslint-enable no-undef */
     58 }