Commit 2fbd9e64 authored by Scott Violet's avatar Scott Violet Committed by Chromium LUCI CQ

weblayer: avoid calling FullscreenDelegate in certain scenarios

While the typical case is EnterFullscreenModeForTab is not called
multiple times in a row, there may be some corner cases with oopif
that result in it being called consecutively. This ensure the
delegate is only notified once.

BUG=1142101
TEST=FullscreenBrowserTest.DelegateNotCalledMoreThanOnce

Change-Id: Ifa094e53b714f78fe61a0d5dd46a33f08c436e30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2630726
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843788}
parent 7874264c
......@@ -92,4 +92,34 @@ IN_PROC_BROWSER_TEST_F(FullscreenBrowserTest, NoExitForBackgroundTab) {
tab->SetFullscreenDelegate(nullptr);
}
IN_PROC_BROWSER_TEST_F(FullscreenBrowserTest, DelegateNotCalledMoreThanOnce) {
EXPECT_TRUE(embedded_test_server()->Start());
// The tab needs to be made active as fullscreen requests for inactive tabs
// are ignored.
TabImpl* tab = static_cast<TabImpl*>(shell()->tab());
tab->GetBrowser()->SetActiveTab(tab);
FullscreenDelegateImpl fullscreen_delegate;
tab->SetFullscreenDelegate(&fullscreen_delegate);
static_cast<content::WebContentsDelegate*>(tab)->EnterFullscreenModeForTab(
nullptr, blink::mojom::FullscreenOptions());
EXPECT_TRUE(static_cast<content::WebContentsDelegate*>(tab)
->IsFullscreenForTabOrPending(nullptr));
EXPECT_TRUE(fullscreen_delegate.got_enter());
EXPECT_FALSE(fullscreen_delegate.got_exit());
fullscreen_delegate.ResetState();
// Simulate another enter. As the tab is already fullscreen the delegate
// should not be notified again.
static_cast<content::WebContentsDelegate*>(tab)->EnterFullscreenModeForTab(
nullptr, blink::mojom::FullscreenOptions());
EXPECT_TRUE(static_cast<content::WebContentsDelegate*>(tab)
->IsFullscreenForTabOrPending(nullptr));
EXPECT_FALSE(fullscreen_delegate.got_enter());
EXPECT_FALSE(fullscreen_delegate.got_exit());
tab->SetFullscreenDelegate(nullptr);
}
} // namespace weblayer
......@@ -1092,6 +1092,12 @@ void TabImpl::EnterFullscreenModeForTab(
content::RenderFrameHost* requesting_frame,
const blink::mojom::FullscreenOptions& options) {
// TODO: support |options|.
if (is_fullscreen_) {
// Typically EnterFullscreenModeForTab() should not be called consecutively,
// but there may be corner cases with oopif that lead to multiple
// consecutive calls. Avoid notifying the delegate in this case.
return;
}
is_fullscreen_ = true;
if (!IsActive()) {
// Process the request the tab is made active.
......
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