Closed Bug 6354 Opened 25 years ago Closed 25 years ago

[BLOCK] onunload doesn't fire when a window is closed

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

x86
Other
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: hyatt, Assigned: joki)

Details

When a window is closed, the onunload handlers in the documents don't fire.
We're depending on this to do some cleanup and releasing of stuff.

I'm not actually sure if this is the correct behavior or not, but I'm hoping
that it is.

Below is a simple test case.

<html>
<body onunload="dump('HI');">
<a href="http://www.mozillazine.org/">MOZILLAZINE!</a>
</body>
</html>

If you switch to the MOZILLAZINE page, you'll see the onunload handler fire.
If, however, you just close the window (instead of following the link), the
onunload handler won't fire.

This is a blocker.
Assignee: nisheeth → joki
Re-assigning this to Tom Pixley, the events guru.
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Well this is at least partially fixed.  Before a webshell is destroyed it now
fires an unload event.  I can maybe see a potential problem with being able to
access of the content in sibling/parent webshells during the unload since we
don't have a single spot to fire this event from before any destruction occurs
but we'll address those bugs as and if we come to them.
it seems a window receive onunload when a child frame is unloaded. You can see the problem with the message
compose window when we reload a new url into the editor frame. In my understanding, a window should only receive
an onunload message when it goes away and not when one of its child goes away right?
Yes, that's true, it's a known bug, and it's a separate one from this one.
Bug number for that other bug?
Don't know.  Talked to rpotts about it a while back.  He was working on
document loading notification changes so any fix was waiting on those.
I filed bug 6365 to track the incorrect onunload handling. joki, if rpotts is
unable to get to this in the near future, please find a new owner for this
problem; it's a serious blocker for much of the appcores work.
Status: RESOLVED → REOPENED
I don't see how this bug could be marked as fixed.  Run the test case in
viewer.  The onunload handler doesn't fire at all when you close up the
window.  You're either not firing the event, or you're leaking the webshell.
In either case, this certainly isn't resolved.

This has nothing to do with apprunner.  HTML pages in viewer don't have their
onunload handlers fired when you close up the viewer window.  Reopening the bug.
Status: REOPENED → RESOLVED
Closed: 25 years ago25 years ago
D'oh! Never mind.  I have been schooled.
Status: RESOLVED → VERIFIED
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.