Open
Bug 1350858
Opened 7 years ago
Updated 2 months ago
window.opener returns the wrong browsing context after window.open(url, '_parent')
Categories
(Core :: DOM: Navigation, enhancement, P3)
Core
DOM: Navigation
Tracking
()
NEW
Tracking | Status | |
---|---|---|
firefox55 | --- | affected |
People
(Reporter: zcorpan, Unassigned)
References
Details
(Keywords: dev-doc-needed)
Attachments
(1 file, 1 obsolete file)
See https://github.com/w3c/web-platform-tests/pull/5150 test case /html/browsers/windows/browsing-context-names/browsing-context-choose-parent-003.html > There's also an interesting difference in browser behavior WRT > choose-browsing-context-parent-003.html. > > According to the spec [1]: > >> The opener IDL attribute on the Window object, on getting, must return the >> WindowProxy object of the browsing context **from which the current browsing >> context was created** (its opener browsing context) > > (emphasis mine) > > Safari and Chrome are both steadfastly retaining a browsing context's original > opener, even if another browsing context later opens a different document into > that context/window. FireFox, however, will replace the window.opener of the > _parent context with the window that invokes .open (assuming the opener isn't > disowned, etc.). > > I have two hunches here: Firefox's behavior is the errant one and this is > likely going to affect more than just the named _parent context. But I'm not > 100% certain on the former. > > [1] > https://html.spec.whatwg.org/#navigating-auxiliary-browsing-contexts-in-the-dom So Gecko changes window.opener but other browsers do not, and the spec does not say to do that, as far as I can tell.
Comment 2•7 years ago
|
||
With a quick look it seems we should only SetOpenerWindow if aWindowIsNew in these 2 places to be compliant with spec. http://searchfox.org/mozilla-central/rev/381a7b8f8a78b481336cfa384cb0a5536e217e4a/dom/ipc/ContentChild.cpp#891 http://searchfox.org/mozilla-central/rev/381a7b8f8a78b481336cfa384cb0a5536e217e4a/toolkit/components/windowwatcher/nsWindowWatcher.cpp#2160
Assignee: nobody → sawang
Flags: needinfo?(sawang)
Comment hidden (mozreview-request) |
Updated•7 years ago
|
Keywords: dev-doc-needed
Comment 4•7 years ago
|
||
What does Edge do? This is an extremely long-standing behavior, and I'm pretty worried about compat fallout from changing it, so would like to be _very_ sure that we want to change it before we do so.
Flags: needinfo?(sawang)
Comment 5•7 years ago
|
||
In particular, the description of Chrome's and Safari's behavior in the Github PR is _not_ correct. Simple testcase: <!DOCTYPE html> <input type="button" onclick="alert(opener)" value="check opener"> <input type="button" onclick="window.open(location.href, '_self')" value="do open"> If you load that, cllick "check opener", then click "do open", then click "check opener" you will get null alerted the first time and a non-null thing alerted the second time.
Comment 7•7 years ago
|
||
mozreview-review |
Comment on attachment 8864794 [details] Bug 1350858 - Only allow aOpener to be non-null at the first call to SetOpenerWindow(). https://reviewboard.mozilla.org/r/136474/#review139732 Per comments, this doesn't give us behavior compatible with Blink or WebKit or ourselves and may well not be web-compatible...
Attachment #8864794 -
Flags: review?(bzbarsky) → review-
Comment 8•7 years ago
|
||
(In reply to Boris Zbarsky [:bz] (still a bit busy) (if a patch has no decent message, automatic r-) from comment #4) > What does Edge do? > > This is an extremely long-standing behavior, and I'm pretty worried about > compat fallout from changing it, so would like to be _very_ sure that we > want to change it before we do so. Followed your explanation on https://github.com/whatwg/html/issues/2636 now I understand the behaviors are still confusing and unclear across different browsers. Until there's a conclusion in the spec issue we probably shouldn't make any change here.
Flags: needinfo?(sawang)
Updated•7 years ago
|
Assignee: sawang → nobody
Updated•7 years ago
|
Priority: -- → P3
Updated•3 years ago
|
Component: DOM: Core & HTML → DOM: Navigation
Updated•2 years ago
|
Severity: normal → S3
Comment hidden (spam) |
Updated•2 months ago
|
Attachment #9384723 -
Attachment is obsolete: true
You need to log in
before you can comment on or make changes to this bug.
Description
•