incorrect window object returned by if forced into same tab

RESOLVED FIXED in Firefox1.0



Tabbed Browser
14 years ago
12 years ago


(Reporter: Dan M, Assigned: Dan M)



1.0 Branch
Windows XP

Firefox Tracking Flags

(Not tracked)



(1 attachment)

1.49 KB, patch
: review+
Ben Goodger (use ben at mozilla dot org for email)
: approval-aviary+
Details | Diff | Splinter Review


14 years ago
The object returned to the calling script by the function is
incorrect if you have prefs set to open new windows into the current window.
This probably isn't a huge problem right now because if the calling script
refers to the new window, which has just replaced the old window, the script
will fail pretty quickly, anyway. But it may as well fail on the correct window.
Note this *will* become a problem if bug 264395 is ever fixed.

I don't really have a testcase. I don't think you can tell that something is
going wrong without a debug build. But the current code is clearly wrong.

Comment 1

14 years ago
Created attachment 163899 [details] [diff] [review]
return correct window object

This seems like the correct code to me (and works for all cases I can think
of). If the requesting opener is known, we load into and return its topmost
window. Otherwise we use the current active tab. and I believe
every codepath currently in use will always have a known opener.


14 years ago
Attachment #163899 - Flags: review?(jst)
Comment on attachment 163899 [details] [diff] [review]
return correct window object

       default : // OPEN_CURRENTWINDOW or an illegal value
	 try {
	   if (aOpener) {
+	     newWindow =;

Seems like this should use XPCNativeWrapper() to get .top to ensure you're
getting the real top, and not a value set by the JS in the opener.

	     referrer.spec = Components.lookupMethod(aOpener,"location")

Ah, or do what you're doing here...

r=jst with that...
Attachment #163899 - Flags: review?(jst) → review+

Comment 3

14 years ago
Comment on attachment 163899 [details] [diff] [review]
return correct window object

Yes, the safe .top lookup method is obviously called for. Thx!
Attachment #163899 - Flags: approval-aviary?
Comment on attachment 163899 [details] [diff] [review]
return correct window object

assuming this is restricted to the single window mode case,
Attachment #163899 - Flags: approval-aviary? → approval-aviary+

Comment 5

14 years ago
Yes, it affects only the ugliest stepsister of single window mode. Patch is in.
Keywords: fixed-aviary1.0
Whiteboard: trunk req: 172962
So if I understand this correctly, a call to inside a webpage with
the prefs set to divert all windows into the current tab will NOT return the
original window object, but the window object of the window that does not exist
and is now the current tab?

(Yeah, I know that's a tangled lump)

Comment 7

14 years ago
Unless I made another mistake, it now returns the correct window, which is the
same window. More clever approaches like returning a new window and letting the
original window spin down on its own are the purview of bug 264395.


14 years ago
Last Resolved: 14 years ago
Resolution: --- → FIXED
Whiteboard: trunk req: 172962
Target Milestone: --- → Firefox1.0
You need to log in before you can comment on or make changes to this bug.