Last active
August 29, 2015 14:00
-
-
Save jimblandy/12c8b6fc1e9591489701 to your computer and use it in GitHub Desktop.
Firefox chrome JS function to return a function's inferred display name.
This file contains hidden or 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
Cu.import("resource://gre/modules/jsdebugger.jsm"); | |
addDebuggerToGlobal(this); | |
function functionDisplayName(obj) { | |
var dbg = new Debugger; | |
var globalDO = dbg.addDebuggee(new Components.utils.Sandbox(this)); | |
return globalDO.makeDebuggeeValue(obj).unwrap().displayName; | |
}; | |
var obj = {}; | |
obj.x = function() {}; | |
uneval(functionDisplayName(obj.x)); | |
/* | |
"obj.x" | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment