Frame-script-02.js (943B)
1 // Frame.prototype.script for call 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, "call"); 13 f(frame.script); 14 }; 15 g.eval(code); 16 } 17 18 ApplyToFrameScript('(function () { debugger; })();', 0, 19 function (script) { 20 assertEq(script instanceof Debugger.Script, true); 21 }); 22 23 // This would be nice, once we can get host call frames: 24 // ApplyToFrameScript("(function () { debugger; }).call(null);", 1, 25 // function (script) { 26 // assertEq(script, null); 27 // });