Commit 5bad6d7e authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Fix a bug in delayed fullscreen operation

This CL fixes a bug in FullscreenManager that handles a pending
fullscreen operation getting active when the tab becomes
user-interactive.

Also added a test that passes when the patch is applied.

Bug: 510282
Change-Id: Id328cc3bd1421de51503bc30a6b4dc5bd91a2c5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2298784
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788898}
parent a024d5e4
......@@ -231,13 +231,16 @@ public class FullscreenHtmlApiHandler implements ActivityStateListener, WindowFo
@Override
public void onDidFinishNavigation(Tab tab, NavigationHandle navigation) {
if (navigation.isInMainFrame() && !navigation.isSameDocument()) {
if (tab == mTab) exitPersistentFullscreenMode();
if (tab == modelSelector.getCurrentTab()) exitPersistentFullscreenMode();
}
}
@Override
public void onInteractabilityChanged(Tab tab, boolean interactable) {
if (!interactable || tab != mTab) return;
// Compare |tab| with |TabModelSelector#getCurrentTab()| which is a safer
// indicator for the active tab than |mTab|, since the invocation order of
// ActivityTabTabObserver and TabModelSelectorTabObserver is not explicitly defined.
if (!interactable || tab != modelSelector.getCurrentTab()) return;
Runnable enterFullscreen = getEnterFullscreenRunnable(tab);
if (enterFullscreen != null) enterFullscreen.run();
}
......
......@@ -44,6 +44,7 @@ import org.chromium.chrome.browser.tab.TabTestUtils;
import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.FullscreenTestUtils;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.content_public.browser.GestureListenerManager;
......@@ -159,6 +160,37 @@ public class FullscreenManagerTest {
tab, false, mActivityTestRule.getActivity());
}
@Test
@MediumTest
@Feature({"Fullscreen"})
public void testDelayedPersistentFullscreen() {
mActivityTestRule.startMainActivityWithURL(LONG_HTML_TEST_PAGE);
Tab tab = mActivityTestRule.getActivity().getActivityTab();
TabWebContentsDelegateAndroid delegate = TabTestUtils.getTabWebContentsDelegate(tab);
FullscreenTestUtils.waitForFullscreenFlag(tab, false, mActivityTestRule.getActivity());
FullscreenTestUtils.waitForPersistentFullscreen(delegate, false);
// Open a new tab, which puts the tab to test background.
ChromeTabUtils.newTabFromMenu(
InstrumentationRegistry.getInstrumentation(), mActivityTestRule.getActivity());
// Having the background tab enter fullscreen should be delayed until it comes foreground.
FullscreenTestUtils.togglePersistentFullscreen(delegate, true);
Assert.assertFalse(getPersistentFullscreenMode());
// Put the tab foreground and assert the fullscreen was entered.
ChromeTabUtils.switchTabInCurrentTabModel(mActivityTestRule.getActivity(), tab.getId());
Assert.assertEquals(tab, mActivityTestRule.getActivity().getActivityTab());
Assert.assertTrue(getPersistentFullscreenMode());
}
private boolean getPersistentFullscreenMode() {
return TestThreadUtils.runOnUiThreadBlockingNoException(
mActivityTestRule.getActivity()
.getFullscreenManager()::getPersistentFullscreenMode);
}
@Test
@LargeTest
@Feature({"Fullscreen"})
......
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