tor-browser

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

test_nativewrappers.js (1149B)


      1 "use strict";
      2 
      3 function run_test() {
      4  const { addDebuggerToGlobal } = ChromeUtils.importESModule(
      5    "resource://gre/modules/jsdebugger.sys.mjs"
      6  );
      7 
      8  Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
      9  registerCleanupFunction(() => {
     10    Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
     11  });
     12 
     13  addDebuggerToGlobal(globalThis);
     14  const g = testGlobal("test1");
     15 
     16  const dbg = new Debugger();
     17  dbg.addDebuggee(g);
     18  dbg.onDebuggerStatement = function (frame) {
     19    const args = frame.arguments;
     20    try {
     21      args[0];
     22      Assert.ok(true);
     23    } catch (ex) {
     24      Assert.ok(false);
     25    }
     26  };
     27 
     28  g.eval("function stopMe(arg) {debugger;}");
     29 
     30  const g2 = testGlobal("test2");
     31  g2.g = g;
     32  g2.eval(
     33    "(" +
     34      function createBadEvent() {
     35        // eslint-disable-next-line mozilla/reject-importGlobalProperties
     36        Cu.importGlobalProperties(["DOMParser"]);
     37        const parser = new DOMParser();
     38        const doc = parser.parseFromString("<foo></foo>", "text/xml");
     39        g.stopMe(doc.createEvent("MouseEvent"));
     40      } +
     41      ")()"
     42  );
     43 
     44  dbg.removeAllDebuggees();
     45 }