Closed Bug 513566 Opened 12 years ago Closed 10 years ago

onbeforeunload event fires twice when a popup window is closed by its opener

Categories

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

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 305085

People

(Reporter: duncan.loveday, Unassigned)

References

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2

Given a script that executes w=window.open(...) and then w.close(), the onbeforeunload event in the referenced window fires twice.

Reproducible: Always

Steps to Reproduce:
1. Open the attached test case in window/tab 1.
2. Click "open" - this will open window/tab 2 and load the same document.
3. Switch back to window/tab 1.
4. Click "close" and note the alerts produced.
Actual Results:  
In step 4 the alerts I see are "beforeUnload with 1", then "beforeUnload with 2", then "unload with 1". These show that the beforeunload event has fired twice whilst the unload event has fired once.

Expected Results:  
Unless there's a reason why beforeunload should fire twice the alerts should be "beforeUnload with 1" followed by "unload with 1".

If instead of steps 3 and 4 you simply close tab 2 then both events fire once as expected.
Attached file test case
Keywords: testcase
This is a regression in Firefox 3.5 (OK in 3.0.13).
Keywords: regression
(In reply to comment #2)
> This is a regression in Firefox 3.5 (OK in 3.0.13).

No it isn't, just that I can't follow my own instructions.

Same behaviour on Fx 3.0.13 and 2.0.0.20
Keywords: regression
Status: UNCONFIRMED → NEW
Ever confirmed: true
See Also: → 531199
See Also: → 369955
This is bug 305085.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 305085
I can't reproduce this using Fx 7.0.1. Not 100% sure it is a duplicate of the other bug but it is definitely WFM.
Not a duplicated of 305085 as that bug is still an issue (just tried it) whilst this one is resolved.
Resolution: DUPLICATE → WORKSFORME
(In reply to Duncan Loveday from comment #7)
> Not a duplicated of 305085 as that bug is still an issue (just tried it)
> whilst this one is resolved.

How do the two bugs differ?  They both describe windows with onbeforeunload closed via window.close(); what makes the procedures different?
Josh, you may well be right. I was wrong earlier when I said this was working, was clicking the "Close Tab" icon on the tab header instead of the "Close" button in the document. And the bugs are indeed very similar, the only difference is that mine has the window.close() being invoked from the opener but that may not be significant.

I've set the status back to how you had it, sorry for the misunderstanding.
Resolution: WORKSFORME → DUPLICATE
Duplicate of bug: 305085
Component: Event Handling → User events and focus handling

I'm still experiencing this. Is this still in the works?

You need to log in before you can comment on or make changes to this bug.