Created
September 18, 2013 10:07
-
-
Save DavidBruant/6607096 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = gBrowser.selectedBrowser.contentWindow; | |
var console = win.console; | |
var P = Object.getPrototypeOf; | |
Components.utils.import("resource://gre/modules/jsdebugger.jsm").addDebuggerToGlobal(this); | |
//console.log(Debugger) | |
var dbg = new Debugger(); | |
var dbgwin = dbg.addDebuggee(win) | |
//console.log(dbgwin) | |
var code = "(function(global){ var secret = Math.random(); window.whatever = function(){ var a = Math.random(); debugger; return String(secret+a)[5] } })(window);"; | |
var envInsideCall; | |
dbg.onDebuggerStatement = function(){ | |
envInsideCall = dbgwin.getOwnPropertyDescriptor('whatever').value.environment; | |
console.log('envInsideCall at debugger statement', envInsideCall.names(), envInsideCall.getVariable('secret'), envInsideCall.getVariable('a')); | |
} | |
dbgwin.getOwnPropertyDescriptor('eval').value.call(undefined, code); | |
envOutsideCall = dbgwin.getOwnPropertyDescriptor('whatever').value.environment; | |
dbgwin.getOwnPropertyDescriptor('whatever').value.call() | |
console.log("same env?", envInsideCall, envOutsideCall, envInsideCall === envOutsideCall) | |
console.log(envInsideCall.names(), envInsideCall.getVariable('secret')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment