Open Bug 485688 Opened 16 years ago Updated 4 years ago

Closing a tab dispatches a load event to the browser

Categories

(SeaMonkey :: Tabbed Browser, defect)

defect
Not set
normal

Tracking

(Not tracked)

People

(Reporter: mossop, Unassigned)

References

Details

This is not so much a bug as an oddity in how the tabbrowser works that might be tripping up people. It tripped me up in bug 480752.

The issue is that when a tab is closed the browser element isn't actually destroyed. Instead it has about:blank loaded into it. This means that anything that has added a load event listener to the browser sees the load.

I imagine a lot of the time this will be harmless, maybe only causing some unnecessary work. I guess you need to load about:blank to get rid of plugins etc in the existing page so I'm not sure if there is a way around this anyway.
(In reply to comment #0)
> I guess you need to load about:blank to get rid of plugins
> etc in the existing page so I'm not sure if there is a way around this anyway.

The first question would be: how does Firefox handle this ?
Blocks: 480752
Flags: wanted-seamonkey2?
Version: unspecified → Trunk
(In reply to comment #1)
> (In reply to comment #0)
> > I guess you need to load about:blank to get rid of plugins
> > etc in the existing page so I'm not sure if there is a way around this anyway.
> 
> The first question would be: how does Firefox handle this ?

Firefox doesn't keep the browser around, it just destroys it when it is removed.
For reference: See http://hg.mozilla.org/comm-central/annotate/054adad6539d/suite/browser/tabbrowser.xml#l1478 for the why. Firefox uses nsSessionStore to implement this feature. I guess at that time it was not possible to use the same implementation as Firefox as SeaMonkey was using xpfe/ at that time. But I'm not sure about that.
Neil, any idea what we can do to at least get those event listeners detached or so when we're closing those tabs?
Perhaps we could temporarily add a capturing event listener to the window to stop the propagation of the load event? Unfortunately that would only help people not already capturing load events on the window. There is a proposed API that we would in time be able to use to enumerate and remove such event listeners so that nobody would ever know about that load event.

On the other hand, maybe we could do something underhand such as pushing the existing document into bfcache using document.open() but never actually closing the document thus forestalling the possibility of a load event...
You can't call document.open() from chrome on a content document on trunk, for security reasons.
I don't see any reason to give this special priority, but it's also not unwanted, so cancelling the wanted flag.
Flags: wanted-seamonkey2.0?
You need to log in before you can comment on or make changes to this bug.