Re: scopes, execution contexts, and scripts

Boris Zbarsky <[email protected]> Mon, 25 Jan 2010 20:46:43 -0500
Newsgroups gmane.comp.mozilla.devel.jsdebugger
Message-ID <[email protected]>
On 1/25/10 6:18 PM, John J Barton wrote:
> If true, we chase the global.parent until it is null or equal to itself,
> then test
> if (context.window == rootWindow)
> where context.window is set to a previous reference from the same(?) API
> call.

OK, so this is correctly testing outer window identity.  In particular, 
this is the object that (currently) does NOT change identity when you 
perform navigation (e.g. clicking a link).

Is that really what you want?

> I can see this is wrong: we should use the child window directly in
> chromebug, not the top window as in Firebug. So I need to test whether
> the window is a content or chrome window. The only way I know how to do
> this is with some bizarre nsIDocShellTreeItem.itemType test. Is there a
> better way?

   if (win instanceof ChromeWindow) {
     /* It's a chrome window */
   }

> If the global is not a Window, then we test (context.global == global),
> where context.global was set to a global from a previous call.

So I'm curious... at what point is the reference from context to the 
global removed?

> Obviously based on the above, I am relying on these paths to all give
> similar objects.

Those all give you outer windows.

> I hope that bug 342715 is planning to do this.

It can build on top of that, yes.

-Boris