jimblandy / DebuggerDocs

Mozilla JavaScript Debugging Documentation
37 stars 12 forks source link

Getting a Debugger.Object without adding debuggees #7

Closed simonlindholm closed 11 years ago

simonlindholm commented 11 years ago

Firebug wants to get Debugger.Objects for globals without having to go into debug mode, so that it can expose functions environments to content (wiki link), and use evalInGlobalWithBindings for command line evaluation, neither of which (seemingly) requires the global to be held as a debuggee. I presume that the Web Console also wants to avoid the perf impact of the latter.

There doesn't seem to be a technical reason for not having such an API, because as far as I can tell e.g.

s = /*unrelated window*/;
d = new Debugger;
d.enabled = false;
o = d.addDebuggee(s);
d.removeDebuggee(s);
g = o.makeDebuggeeValue(content).unwrap().global;
// g.evalInGlobalWithBindings, etc.

has the same effect (though it's a hack and also triggers debug mode in some unrelated compartment).

Could a Debugger.prototype.makeUnwrappedDebuggeeValue or Debugger.prototype.makeDebuggeeValueFromGlobal or something be added?

Or is it against the API design, with the aim instead being to fix debugger performance (e.g. bug 783428, bug 809563)?

jimblandy commented 11 years ago

Ideally, a Debugger with no hooks certainly wouldn't impose any overhead.

Debugger.prototype.makeDebuggeeValueFromGlobal seems like a good idea. Would you like to give it a shot?

simonlindholm commented 11 years ago

I don't have have the Firefox source code checked out, but I guess something like this should do it: https://gist.github.com/simonlindholm/5627711

Can you take it from there?

simonlindholm commented 11 years ago

Or should I open a bug?

jimblandy commented 11 years ago

If you could file a bug in Bugzilla for this, that would help me and Honza keep track of it.

I can't work on this immediately, but if the bug is filed, then Honza can shepherd it forward.

Thanks for the proposed patch. The implementation is a little odd, but the API looks fine.

On Wed, Jun 5, 2013 at 3:07 PM, Simon Lindholm notifications@github.comwrote:

Or should I open a bug?

— Reply to this email directly or view it on GitHubhttps://github.com/jimblandy/DebuggerDocs/issues/7#issuecomment-19012347 .

jimblandy commented 11 years ago

Please CC Honza and me on the bug.

simonlindholm commented 11 years ago

Okay, thanks. Filed bug 880177.

simonlindholm commented 11 years ago

jimb: ping!