jimblandy / DebuggerDocs

Mozilla JavaScript Debugging Documentation
37 stars 12 forks source link

Getting the global of a frame #19

Closed simonlindholm closed 10 years ago

simonlindholm commented 10 years ago

I haven't been able to find a clear way to get from a frame to its owning global. It may be possible to walk parent links until we get to a frame with type "call" or "global", and then use (frame.callee || frame.environment.object).global, but I'm not sure that's always correct, and in any case it seems rather fragile.

Can we add Debugger.Frame.global?

jimblandy commented 10 years ago

If we were to add an accessor for a script's global, Debugger.Script.prototype.global, then would using frame.script.global work as well, in this case? At present, all the frame types we actually support have scripts. The ones that don't have scripts aren't really associated with any given global, I think.

simonlindholm commented 10 years ago

If we were to add an accessor for a script's global, Debugger.Script.prototype.global, then would using frame.script.global work as well, in this case?

For Firebug's use-cases, absolutely.

jimblandy commented 10 years ago

Filed as Mozilla bug 958646.

jimblandy commented 10 years ago

Okay, bug 958646's patch has landed: https://hg.mozilla.org/integration/mozilla-inbound/rev/35cba8ed009d

simonlindholm commented 10 years ago

Nice! Thanks, Jim.