New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 738419 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

Cannot close popup window after clearing opener property

Reported by a...@scirra.com, Jun 30 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3145.0 Safari/537.36

Steps to reproduce the problem:
1. Visit this URL: https://www.scirra.com/labs/bugs/windowcloser/
2. Click 'Open cross-origin popup without opener'
3. Click 'Close last popup'

What is the expected behavior?
The popup should be closed. This works in Firefox and Edge.

What went wrong?
The popup is not closed and this error is logged to the console:

Unsafe JavaScript attempt to initiate navigation for frame with URL 'https://downloads.scirra.com/misc/bugs/window.html' from frame with URL 'https://www.scirra.com/labs/bugs/windowcloser/'. The frame attempting navigation is neither same-origin with the target, nor is it the target's parent or opener.

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 61.0.3145.0  Channel: canary
OS Version: 10.0
Flash Version: 

Judging by the error message, Chrome is reading the actual window.opener property, which was cleared. Presumably Firefox and Edge are storing the "real opener" separately, and testing that when checking if the window can be closed.

This is important since the window.opener property has some security implications, hence the introduction of rel=noopener. If 'noopener' is specified when calling window.open(), the method returns null, so the opened window cannot be accessed at all. The workaround is to call window.open() with no location, clear its opener property, and then set its location. However this unnecessarily revokes the right to call close() in Chrome.
 
Components: Blink>JavaScript Blink>HTML
Labels: M-61 OS-Linux OS-Mac
Status: Untriaged (was: Unconfirmed)
Able to reproduce the issue on Windows 7, Mac 10.12.5 & Ubuntu 14.04 using chrome reported version#61.0.3145.0,stable#59.0.3071.115 & Canary#61.0.3148.0 as per the URL provided in comment#0.

Opened popup is not getting closed when we click on 'Close last popup' button.

This is non regression issue observed from M45 builds to latest canary.Hence marking it as 'Untriaged' to get more inputs from dev.
Please find the attached screencast for reference.
Thanks..!!

738419.mp4
557 KB View Download
Cc: mkwst@chromium.org
Components: -Blink>JavaScript Blink>SecurityFeature

Comment 3 by mkwst@chromium.org, Jul 10 2017

From a spec perspective, the third bullet-point in https://html.spec.whatwg.org/#familiar-with seems like the operative check, and I guess the browser behavior depends on how https://html.spec.whatwg.org/#disowned-its-opener is interpreted. If disowning the opener by setting `window.opener = null` doesn't actually clear the "opener browsing context", then the behavior you're asking for is technically correct. I'm not sure that's desirable, however: breaking the opener relationship seems like it has to be a bidirectional change. Otherwise the opened window can't defend itself against malicious behavior by its opener.

Comment 4 by a...@scirra.com, Jul 11 2017

The use case is to open a window with no opener, but still be able to postMessage() to it. If you want a completely isolated window, passing 'noopener' to window.open() clears the opener but the call returns null so you can't postMessage() to it.

We use this in our game development PWA Construct 3 (editor.construct.net). Previewing a game runs cross-origin to the editor to ensure the game is isolated. We also want to clear the window opener, but still be able to postMessage() to initialise the game data.

Comment 5 by tkent@chromium.org, Jul 18 2017

Components: -Blink>HTML Blink>WindowDialog

Comment 6 by mkwst@chromium.org, Aug 1 2017

Labels: -Pri-2 -M-61 OS-Android OS-Chrome Pri-3
Status: Available (was: Untriaged)

Comment 7 by a...@scirra.com, Sep 4 2017

Clearing window.opener also prevents focusing the window. In other words, if a popup window clears its window.opener property to improve security, the parent window loses any ability to control it, which seems unnecessary and makes it harder to use this security feature.

Comment 8 by est...@chromium.org, Nov 10 2017

Labels: Hotlist-EnamelAndFriendsFixIt

Comment 9 by est...@chromium.org, Feb 18 2018

Labels: -Hotlist-EnamelAndFriendsFixIt

Sign in to add a comment