Skip to content

Instantly share code, notes, and snippets.

@jimblandy
Last active August 29, 2015 14:00
Show Gist options
  • Save jimblandy/12c8b6fc1e9591489701 to your computer and use it in GitHub Desktop.
Save jimblandy/12c8b6fc1e9591489701 to your computer and use it in GitHub Desktop.
Firefox chrome JS function to return a function's inferred display name.
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