tor-browser

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

Frame-script-01.js (880B)


      1 // Frame.prototype.script for eval frames.
      2 
      3 var g = newGlobal({newCompartment: true});
      4 var dbg = new Debugger(g);
      5 
      6 // Apply |f| to each frame that is |skip| frames up from each frame that
      7 // executes a 'debugger' statement when evaluating |code| in the global g.
      8 function ApplyToFrameScript(code, skip, f) {
      9    dbg.onDebuggerStatement = function (frame) {
     10        while (skip-- > 0)
     11            frame = frame.older;
     12        assertEq(frame.type, "eval");
     13        f(frame.script);
     14    };
     15    g.eval(code);
     16 }
     17 
     18 ApplyToFrameScript('debugger;', 0,
     19                   function (script) {
     20                       assertEq(script instanceof Debugger.Script, true);
     21                   });
     22 ApplyToFrameScript("(function () { eval('debugger;'); })();", 0,
     23                   function (script) {
     24                       assertEq(script instanceof Debugger.Script, true);
     25                   });