Open Bug 531199 Opened 15 years ago Updated 2 years ago

beforeunload fires twice when closing popup with "Close" menu item

Categories

(Firefox :: General, defect)

11 Branch
x86
All
defect

Tracking

()

People

(Reporter: david.stark, Unassigned)

References

Details

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-GB; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-GB; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5

When the beforeunload handler is set on a popup window, using the "Close" menu item (or command-W) to close the window causes beforeunload to be fired once, and if the user chooses "OK" in the resulting "Are you sure you want to navigate away from this page?" dialog, beforeunload is fired a second time and the dialog comes up again.

If the popup window is closed by clicking on the close button, this problem does not occur.

Reproducible: Always

Steps to Reproduce:
Code the following:
1. In one file, using Javascript's window.open, create a popup window (a separate window, not a tab).
2. In the popup, set the window.beforeunload handler, eg:

window.onbeforeunload =  function () { return "HAPPENS TWICE"; };

3. Load the first file.
4. Cause the popup to appear.
5. Close the popup *using the File->Close menu item*.
6. When the dialog saying "Are you sure you want to navigate away from this page?" comes up, choose "OK".
Actual Results:  
The dialog is displayed a second time.

Expected Results:  
The window should close immediately.

I will attach two files, loader.html and popup.html that demonstrate the problem.
This may be a relative of bug 369955 .
See Also: → 369955
Version: unspecified → 3.5 Branch
I am seeing the same symptoms on FF 3.5.5, and I feel it has only started happening recently.
For me, a popup is irrelevant. This happens on a single page with a beforeunload handler, when using Ctrl W to close the (single) tab.
Compare
http://code.google.com/p/chromium/issues/detail?id=11647
(In reply to comment #3)
> This may be a relative of bug 369955 .

also https://bugzilla.mozilla.org/show_bug.cgi?id=513566
Status: UNCONFIRMED → NEW
Ever confirmed: true
See Also: → 513566
OS: Mac OS X → All
I can confirm that this bug is still extant as of Firefox 11.0.
Version: 3.5 Branch → 11 Branch
Still exists in Firefox 16.0.1
Also exists in Firefox 26.0.

Test case:
1. Execute in JS-Konsole: window.open('https://bugzilla.mozilla.org/show_bug.cgi?id=531199', 'test');
2. Allow popup
3. Open JS-Konsole in the newly opened tab
4. Execute: window.onbeforeunload = function() { return "test"; };
5. Execute: window.close();
--> The dialog is shown twice.

I'm still experiencing this in Firefox 84. Will this eventually get fixed or is this no longer the right bug tracking software?

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: