tor-browser

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

test_symbols-02.js (1163B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Test that we don't run debuggee code when getting symbol names.
      8 */
      9 
     10 const URL = "foo.js";
     11 
     12 add_task(
     13  threadFrontTest(async ({ threadFront, debuggee }) => {
     14    await testSymbols(threadFront, debuggee);
     15  })
     16 );
     17 
     18 async function testSymbols(threadFront, debuggee) {
     19  const evalCode = () => {
     20    /* eslint-disable mozilla/var-only-at-top-level, no-extend-native, no-unused-vars */
     21    // prettier-ignore
     22    Cu.evalInSandbox(
     23      "(" + function () {
     24        Symbol.prototype.toString = () => {
     25          throw new Error("lololol");
     26        };
     27        var sym = Symbol("le troll");
     28        debugger;
     29      } + "())",
     30      debuggee,
     31      "1.8",
     32      URL,
     33      1
     34    );
     35    /* eslint-enable mozilla/var-only-at-top-level, no-extend-native, no-unused-vars */
     36  };
     37 
     38  const packet = await executeOnNextTickAndWaitForPause(evalCode, threadFront);
     39  const environment = await packet.frame.getEnvironment();
     40  const { sym } = environment.bindings.variables;
     41 
     42  equal(sym.value.type, "symbol");
     43  equal(sym.value.name, "le troll");
     44 }