Can't bring to front parent window, when close child.
Reported by
serejkas...@gmail.com,
Oct 12 2017
|
|||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 Steps to reproduce the problem: 1. Open child window using window.open 2. Define in parent window cb, pass it to the child window, assign cb to the window unload event 3. cb should contain window.focus(); 4. Put some app between child and parent windows 5. Close child window What is the expected behavior? Parent window should be in front and focused What went wrong? Parent window don't come in front and didn't have focus Did this work before? N/A Does this work in other browsers? N/A Chrome version: 61.0.3163.100 Channel: stable OS Version: 7 Flash Version: Work perfectly on Mac in same Chrome version
,
Oct 13 2017
Can you please help us with a sample code or jsfiddle example which executes this behavior. This will help us to triage the issue better. Thanks.!
,
Oct 13 2017
You are welcome. Run on local server, or disable web security in chrome. (I guess you know it :) )
,
Oct 13 2017
Thank you for providing more feedback. Adding requester "ranjitkan@chromium.org" to the cc list and removing "Needs-Feedback" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 16 2017
Able to reproduce this issue on Win-10 and Ubuntu 14.04 using chrome reported version #61.0.3163.100 and latest canary #63.0.3239.6. Issue is not seen in OS-Mac. This is a non-regression issue as it is observed from M50 old builds. Hence, marking it as untriaged to get more inputs from dev team. Thanks...!!
,
Oct 23 2017
The blink bits seem to be functioning correctly. I am guessing that the issue is somewhere in the area where OS-specific windows are actually created. Avi, could you help triage?
,
Oct 24 2017
As per everyone, this is not a Mac issue. Investigating.
,
Oct 24 2017
dglazkov: I thought this was WebViewClient::DidFocus() but it doesn't seem to be. Where does the callback out of Blink happen?
,
Oct 24 2017
First, a note about why this works on the Mac. It does so by accident. On the Mac, all windows are owned by a top-level app. If the user closes the window that is the topmost, and they're using that app, the Mac OS will promote the next-down window to be top-most. That is a behavior of the Mac OS, and it happens to match the expectations of the user in this case.
As for all other platforms, this fails due to abuse checks.
If we look at DOMWindow::focus() we see the following code:
bool allow_focus = incumbent_execution_context->IsWindowInteractionAllowed();
if (allow_focus) {
incumbent_execution_context->ConsumeWindowInteraction();
} else {
DCHECK(IsMainThread());
allow_focus =
opener() && (opener() != this) &&
(ToDocument(incumbent_execution_context)->domWindow() == opener());
}
// If we're a top level window, bring the window to the front.
if (GetFrame()->IsMainFrame() && allow_focus)
page->GetChromeClient().Focus();
In this case, the ExecutionContext::IsWindowInteractionAllowed() call returns false; we don't have any window interaction tokens. There is then a second chance, if it's being focused by the window that opened it. In this case, that's backwards, and the window that *it* opened is trying to focus it. So it fails, and the ChromeClient::Focus() call isn't made.
However, even if it *were* made, that turns into a call to RenderViewImpl::DidFocus(), which has *yet another* check for abuse, which is making sure that a user gesture is being processed at the time. And no, the window being closed is not a user gesture.
This case hits just about every anti-abuse mechanism we have for window activation. And as plausible as this case might be that it's not abuse, it's not worth the effort to carve it out from the other cases.
My recommendation is to not use window.open(). Popups are a remnant of the early days of the web, before things like iframes were available. Immediately after popups were introduced, abuse of them became rampant, and it has continued to this day. There are better options available. Use them instead.
|
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by serejkas...@gmail.com
, Oct 12 2017