tor-browser

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

Frame-script-environment-nondebuggee.js (887B)


      1 // The script and environment of a non-debuggee frame are inaccessible.
      2 
      3 load(libdir + 'asserts.js');
      4 
      5 var g = newGlobal({newCompartment: true});
      6 var dbg = new Debugger;
      7 
      8 var log;
      9 dbg.onDebuggerStatement = function (frame) {
     10  log += frame.type;
     11  // Initially, 'frame' is a debuggee frame, and we should be able to see its script and environment.
     12  assertEq(frame.script instanceof Debugger.Script, true);
     13  assertEq(frame.environment instanceof Debugger.Environment, true);
     14 
     15  // If we make g no longer a debuggee, then trying to touch the frame at
     16  // all should throw.
     17  dbg.removeDebuggee(g);
     18  assertThrowsInstanceOf(() => frame.script, Error);
     19  assertThrowsInstanceOf(() => frame.environment, Error);
     20 }
     21 
     22 g.eval('function f() { debugger; }');
     23 
     24 log = '';
     25 dbg.addDebuggee(g);
     26 g.f();
     27 assertEq(log, 'call');
     28 
     29 log = '';
     30 dbg.addDebuggee(g);
     31 g.eval('debugger;');
     32 assertEq(log, 'eval');