Open Bug 265591 Opened 16 years ago Updated 2 years ago

window.close can close the wrong window


(Core :: DOM: Core & HTML, defect, P5)

Windows XP





(Reporter: Peter.Binney, Unassigned)


(Keywords: testcase)


(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a5) Gecko/20041021

The supplied files demonstrate what appears to be a pretty fundamental bug in
Mozilla and Firefox.

To demonstrate: 
- open default.htm (either as a direct file, or with the files here installed on
a webserver)
- click the link, which opens a new, non-modal window
- click the link in the new window, which opens a modal window
- click the link in the modal window, which should
  a) reload the non-modal window
  b) close the modal one

This works as expected on all versions of IE and Opera.
On Firefox the final click closes both the modal and the non-modal windows.
This appears to be due to the "window.close" in the modalWindowCloser function
(line 1951 in includes/common.js).

Reproducible: Always
Steps to Reproduce:
See details
Actual Results:  
See details

Expected Results:  
See details
If I remove this line in common.js: var parent = opener.parent	// Allow for
then it also works fine in Mozilla (and still in IE6).

This line of code at line 1949 appr.:
if (closeParent && exists(parent.close) )
is true for Mozilla, but false for IE6.
closeParent returns false for me in IE6 if I alert it just before that code.
I have no idea why closeParent returns true in Mozilla for me.
Some clarification on comment 2:
Adding this code in the try block at line 1948 in common.js:
and then following the steps in the bug.
It first alerts false, but it alerts a second time and then it alerts true.
closeParent is set by the function modalWindowCloser. This function is fired
inside the modal popup window during onunload (<BODY class='noMarginAluminium'
onUnload='modalWindowCloser(true)' )
Mozilla is firing this onUnload when the window gets closed. IE6 isn't doing that.
Attached file Testcase
This document has an onunload="alert('unloaded')"
In Mozilla this gives the alert when you close the window.
In IE6 this doesn't give an alert.

I think that is the fundamental difference that is causing this bug.
is this NEW or what ?
Comment 5 is wrong, with "Testcase" I also get an alert when closing the window
in IE6.
But anyway, I think this bug is now fixed somehow in current trunk builds (which
you can download here: )
I don't get the issue anymore with the initial bug description.
Please reopen if this still can be reproduced in current trunk builds.
Closed: 16 years ago
Resolution: --- → WORKSFORME
I still get exactly the same behaviour with Firefox 1.0.7
Resolution: WORKSFORME → ---
(In reply to comment #8)
> I still get exactly the same behaviour with Firefox 1.0.7

Yeah, fix on trunk in this case means fixed for FF1.5 NOT 1.0.X

Assignee: firefox → general
Component: General → DOM
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → Trunk
Keywords: testcase
Assignee: general → nobody
QA Contact: ian → general

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.