Closed Bug 111752 Opened 23 years ago Closed 23 years ago

document.open(a, b, c); should act like window.open(a, b, c) when all 3 arguments are specified.

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.8

People

(Reporter: maxozilla, Assigned: jst)

References

()

Details

(Whiteboard: [HAVE FIX])

Attachments

(5 files)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.6) Gecko/20011120
BuildID:    2001112009

In the page http://www.bravenet.com/reviews/coolscripts/ , clicking on the
listed hyperlinks should bring up a pop-up window. It doesn't

Reproducible: Always
Steps to Reproduce:
1. Click on one of the listed links, for example 'ColorPicker Script'


Actual Results:  It stays in the same window, keeps the background and just show
it's loading in the top-right corner.

Expected Results:  It should just open up a pop-up window.

All the hyperlinks are using javscript
Evangelism.  Page is using "open()" instead of "window.open()".  The problem is
that "open()" on it's own is "document.open()" and hence we just open the
current document for writing (wiping out all the content) instead of opening a
new window.  The page should use "window.open()"

In some other browsers "open()" is treated as "window.open()" in spite of the
fact that "document.open()" is also supported. This leads to very inconsistent
behavior in scripts that are assuming correctly implemented Javascript namespaces...
Assignee: asa → bclary
Status: UNCONFIRMED → NEW
Component: Browser-General → English: US
Ever confirmed: true
OS: Windows 98 → All
Product: Browser → Tech Evangelism
QA Contact: doronr → zach
Hardware: PC → All
Whiteboard: [XBROWSER-JAVASCRIPT]
Version: other → unspecified
bz, why is open considered to be document.open and not window.open? window is
the global object in js in a browser and I would have thought that an
unqualified open would resolve against the global object not document. --bc
An unqualified variable name of any kind resolves against document first, then
window, if I recall correctly....
This example shows that a regular variable is resolved against the window as
global object rather than document.
OK, that's weird.  jst, what's up here?
Event handlers run with the node they're execeuted on as the scope, thus in this
case we'll end up resolving |open| in the link's scope. The link doesn't have a
|open| property, so we go to the link's parent and its parent until we find a
JSObject with a |open| property on it, the first one we find is |document.open|
so we call that. They need to qualify the name |open| when called from an event
handler. IE is broken, that's why this code works in IE.
Priority: -- → P2
Summary: If I go onto a certain page and click on a link, a popup window doesn't open when it should → bravenet.com - open resolves against document
Whiteboard: [XBROWSER-JAVASCRIPT] → [XBROWSER-JAVASCRIPT][OPEN]
This is actually a 4x compatible dom 0 bug since both IE and Navigator 4, treat
a javascript:open as a document.open with 0-2 arguments and as window.open if it
has 3+ arguments.
Assignee: bclary → jst
Component: English: US → DOM Level 0
Product: Tech Evangelism → Browser
QA Contact: zach → amar
Version: unspecified → other
*** Bug 113147 has been marked as a duplicate of this bug. ***
Oh man, I can't believe this quirky behavior, this is really really weird :-)

Patch coming up to hack up this quirky DOM0 behavior, document.open() works
exactly like window.open() does when called with 3 or more arguments.
Status: NEW → ASSIGNED
Whiteboard: [XBROWSER-JAVASCRIPT][OPEN] → [HAVE FIX][XBROWSER-JAVASCRIPT][OPEN]
Target Milestone: --- → mozilla0.9.8
Summary: bravenet.com - open resolves against document → document.open(a, b, c); should act like window.open(a, b, c) when all 3 arguments are specified.
Whiteboard: [HAVE FIX][XBROWSER-JAVASCRIPT][OPEN] → [HAVE FIX]
Chouck, what does the 4.x code do? 
http://lxr.mozilla.org/classic/source/lib/libmocha/lm_doc.c#1617 turns
document.open (open in an event handler) calls into window.open if argc > 2 ||
argv[0] == [the "" value].

/be
We should push this into the embedding branch befroe we ship something real off
of that branch since this has shown up in a number of bug reports already, and I
bet there will be many many more.
Keywords: edt0.9.4
As I pointed out to jst, and mentioned in passing in my last comment here, this
quirk was added because <input type=button onclick='open("http://foo.com", "",
"resizable=no,height=400,width=500")'> should call window.open, not
document.open as the scope chain would have it.

/be
Comment on attachment 61570 [details] [diff] [review]
Fixes a bug pointed out by Fabian, the callee's window must be used when calling window.open(), not the callers window.

r=fabian
Attachment #61570 - Flags: review+
Johnny, what other bug reports has this shown up in? Just trying to get an
understanding of the gravity of this.
*** Bug 113568 has been marked as a duplicate of this bug. ***
Brendan, would you sr the latest patch in this bug?
cc'ing brendan, as jst requested sr from him.
Comment on attachment 61570 [details] [diff] [review]
Fixes a bug pointed out by Fabian, the callee's window must be used when calling window.open(), not the callers window.

sr=brendan@mozilla.org, good catch Fabian!

/be
Attachment #61570 - Flags: superreview+
Fix checked in on the trunk.

Judson, I don't have the numbers of the bugs where this has shown up in handy,
but I've seen a number of them go by, some of them were probably incorrectly
marked INVALID, some were given to evangelism (at least bug 113147, probably
others too).

The reson I think we should take this on the embedding branch is that this bug
breaks functionality that dates back to some of the first versions of Netscape
and IE, it breaks commonly done things that has always worked in other browsers,
and it's something that any web developer can do, and is likely to do, on
websites. If we don't fix this, it's very likely that this bug will break new
pages that are not yet written, as well as old pages that we don't know about
yet. We have a fix, it's now on the trunk, lets let it bake on the trunk for a
few days, just to make sure, and then land it on the trunk. This is a small
prise to pay for having yet more (non-broken) sites work in embedding clients.
Will plus for 094 once fix is checked into trunk and tested.
Michael, this fix has already been checked in on the trunk, the fix was checked
in on the trunk on 12/20 so I can't say how much testing it has gotten, but it's
been on the trunk since then. Do we want more testing, or should this be plussed
already?
FYI
works with the latest build 
-> http://bugzilla.mozilla.org/show_bug.cgi?id=113568  also works now.
adding + to edt0.9.4
Keywords: edt0.9.4edt0.9.4+
Fix checked in on the 0.9.4 branch.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Keywords: fixed0.9.4
Resolution: --- → FIXED
*** Bug 118090 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: