Commit 3d41e771 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

If a dialog is shown, drop fullscreen.

BUG=875066, 817809, 792876, 812769, 813815
TEST=included

Change-Id: Ic3d697fa3c4b01f5d7fea77391857177ada660db
Reviewed-on: https://chromium-review.googlesource.com/1185208Reviewed-by: default avatarSidney San Martín <sdy@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586418}
parent f6bedc98
......@@ -2052,6 +2052,13 @@ void Browser::SetWebContentsBlocked(content::WebContents* web_contents,
// TabStripModel.
return;
}
// For security, if the WebContents is in fullscreen, have it drop fullscreen.
// This gives the user the context they need in order to make informed
// decisions.
if (web_contents->IsFullscreenForCurrentTab())
web_contents->ExitFullscreen(true);
tab_strip_model_->SetTabBlocked(index, blocked);
bool browser_active = BrowserList::GetInstance()->GetLastActive() == this;
......
......@@ -2747,3 +2747,26 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TestPopupBounds) {
browser->window()->Close();
}
}
// Makes sure showing dialogs drops fullscreen.
IN_PROC_BROWSER_TEST_F(BrowserTest, DialogsDropFullscreen) {
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
content::WebContentsDelegate* browser_as_wc_delegate =
static_cast<content::WebContentsDelegate*>(browser());
web_modal::WebContentsModalDialogManagerDelegate* browser_as_dialog_delegate =
static_cast<web_modal::WebContentsModalDialogManagerDelegate*>(browser());
// Simulate the tab requesting fullscreen.
browser_as_wc_delegate->EnterFullscreenModeForTab(
tab, GURL(), blink::WebFullscreenOptions());
EXPECT_TRUE(browser_as_wc_delegate->IsFullscreenForTabOrPending(tab));
// The tab gets a modal dialog.
browser_as_dialog_delegate->SetWebContentsBlocked(tab, true);
// The dialog should drop fullscreen.
EXPECT_FALSE(browser_as_wc_delegate->IsFullscreenForTabOrPending(tab));
browser_as_dialog_delegate->SetWebContentsBlocked(tab, false);
}
......@@ -5180,6 +5180,10 @@ void WebContentsImpl::RunBeforeUnloadConfirm(
void WebContentsImpl::RunFileChooser(RenderFrameHost* render_frame_host,
const FileChooserParams& params) {
// Any explicit focusing of another window while this WebContents is in
// fullscreen can be used to confuse the user, so drop fullscreen.
ForSecurityDropFullscreen();
if (delegate_)
delegate_->RunFileChooser(render_frame_host, params);
}
......
......@@ -1024,6 +1024,8 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
DialogsFromJavaScriptEndFullscreen);
FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
DialogsFromJavaScriptEndFullscreenEvenInInnerWC);
FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
FileChooserEndsFullscreen);
FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
PopupsFromJavaScriptEndFullscreen);
FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
......
......@@ -2190,6 +2190,23 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
top_contents->SetJavaScriptDialogManagerForTesting(nullptr);
}
IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, FileChooserEndsFullscreen) {
WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents());
TestWCDelegateForDialogsAndFullscreen test_delegate;
wc->SetDelegate(&test_delegate);
GURL url("about:blank");
EXPECT_TRUE(NavigateToURL(shell(), url));
wc->EnterFullscreenMode(url, blink::WebFullscreenOptions());
EXPECT_TRUE(wc->IsFullscreenForCurrentTab());
wc->RunFileChooser(wc->GetMainFrame(), FileChooserParams());
EXPECT_FALSE(wc->IsFullscreenForCurrentTab());
wc->SetDelegate(nullptr);
wc->SetJavaScriptDialogManagerForTesting(nullptr);
}
IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
PopupsFromJavaScriptEndFullscreen) {
WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment