Closed
Bug 266776
Opened 20 years ago
Closed 20 years ago
incorrect window object returned by window.open if forced into same tab
Categories
(Firefox :: Tabbed Browser, defect)
Tracking
()
RESOLVED
FIXED
Firefox1.0
People
(Reporter: danm.moz, Assigned: danm.moz)
Details
(Keywords: fixed-aviary1.0)
Attachments
(1 file)
1.49 KB,
patch
|
jst
:
review+
bugs
:
approval-aviary+
|
Details | Diff | Splinter Review |
The object returned to the calling script by the function window.open 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.
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. window.open and I believe
every codepath currently in use will always have a known opener.
Attachment #163899 -
Flags: review?(jst)
Comment 2•20 years ago
|
||
Comment on attachment 163899 [details] [diff] [review]
return correct window object
default : // OPEN_CURRENTWINDOW or an illegal value
try {
if (aOpener) {
+ newWindow = aOpener.top;
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")
.call(aOpener);
Ah, or do what you're doing here...
r=jst with that...
Attachment #163899 -
Flags: review?(jst) → review+
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 4•20 years ago
|
||
Comment on attachment 163899 [details] [diff] [review]
return correct window object
assuming this is restricted to the single window mode case, a=ben@mozilla.org
Attachment #163899 -
Flags: approval-aviary? → approval-aviary+
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 window.open 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)
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.
Status: NEW → RESOLVED
Closed: 20 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.
Description
•