Re: scopes, execution contexts, and scripts

John J Barton <[email protected]> Tue, 26 Jan 2010 17:15:15 -0800
Newsgroups gmane.comp.mozilla.devel.jsdebugger
Message-ID <[email protected]>
John J. Barton wrote:
> Boris Zbarsky wrote:
>> On 1/26/10 2:04 PM, John J. Barton wrote:
>>> and how to distinguish the (and possibly..) case from
>>> unload-because-we-are-being-deleted.
>>
>> You can't.  But onload does mean whatever was in that window before is 
>> gone.
>>
>>> And so to handle this case, I guess I need to track onLocationChange
>>> events for every nsIDOMWindow? I don't understand how to tell if a
>>> window is being destroyed after unload vs being reused.
>>
>> You can't tell right now.
>>
>> I plan to add a notification (with the window id) when a window is 
>> "torn down" sometime in the next 1-1.5 weeks.
>>
>> -Boris
> 
> Ok, in the meantime I can delete the metadata about the unloaded window 
> on the unload handler without delay and new metadata for the window will 
> be created.  It means that unload handlers may not debug if they fire 
> after mine.

Just FYI, (or me I suppose) the XBL destructors seem to run after the 
unload event handlers, so again I find myself re-creating metadata for a 
dead window. (The unload runs, deletes my context, the XBL destructor 
compiles, I track it back to the outer DOM window context, create a new 
context for it). Similarly XBL fields. In fact the unload event comes 
earlier than I expected. So for the outer DOM window in a XUL window, I 
queue the closer and trigger it when the global event 
xul-window-destroyed arrives (which is very late).

jjb