diff options
| -rw-r--r-- | chrome/browser/ui/fullscreen_controller.cc | 7 | ||||
| -rw-r--r-- | chrome/browser/ui/fullscreen_controller_browsertest.cc | 57 | ||||
| -rw-r--r-- | chrome/test/functional/PYAUTO_TESTS | 2 |
3 files changed, 62 insertions, 4 deletions
diff --git a/chrome/browser/ui/fullscreen_controller.cc b/chrome/browser/ui/fullscreen_controller.cc index 7702c65..9136131 100644 --- a/chrome/browser/ui/fullscreen_controller.cc +++ b/chrome/browser/ui/fullscreen_controller.cc @@ -246,7 +246,9 @@ void FullscreenController::LostMouseLock() { } void FullscreenController::OnTabClosing(WebContents* web_contents) { - if (IsFullscreenForTabOrPending(web_contents)) { + const TabContents* contents = TabContents::FromWebContents(web_contents); + if (contents && + (contents == fullscreened_tab_ || contents == mouse_lock_tab_)) { ExitTabFullscreenOrMouseLockIfNecessary(); // The call to exit fullscreen may result in asynchronous notification of // fullscreen state change (e.g., on Linux). We don't want to rely on it @@ -258,7 +260,8 @@ void FullscreenController::OnTabClosing(WebContents* web_contents) { } void FullscreenController::OnTabDeactivated(TabContents* contents) { - if (contents == fullscreened_tab_) + if (contents && + (contents == fullscreened_tab_ || contents == mouse_lock_tab_)) ExitTabFullscreenOrMouseLockIfNecessary(); } diff --git a/chrome/browser/ui/fullscreen_controller_browsertest.cc b/chrome/browser/ui/fullscreen_controller_browsertest.cc index fef1e51..20ea3c0 100644 --- a/chrome/browser/ui/fullscreen_controller_browsertest.cc +++ b/chrome/browser/ui/fullscreen_controller_browsertest.cc @@ -13,6 +13,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/url_constants.h" +#include "content/public/test/test_navigation_observer.h" #if defined(OS_MACOSX) #include "base/mac/mac_util.h" #endif @@ -331,3 +332,59 @@ IN_PROC_BROWSER_TEST_F( } #endif +IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, + PendingMouseLockExitsOnTabSwitch) { + AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL), + content::PAGE_TRANSITION_TYPED); + WebContents* tab2 = browser()->GetActiveWebContents(); + AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL), + content::PAGE_TRANSITION_TYPED); + WebContents* tab1 = browser()->GetActiveWebContents(); + + // Request mouse lock. Bubble is displayed. + RequestToLockMouse(tab1, true, false); + ASSERT_TRUE(IsFullscreenBubbleDisplayed()); + + // Activate current tab. Mouse lock bubble remains. + browser()->ActivateTabAt(0, true); + ASSERT_TRUE(IsFullscreenBubbleDisplayed()); + + // Activate tab2. Mouse lock bubble clears. + { + MouseLockNotificationObserver mouse_lock_observer; + browser()->ActivateTabAt(1, true); + mouse_lock_observer.Wait(); + } + ASSERT_FALSE(IsFullscreenBubbleDisplayed()); + + // Now, test that closing an unrelated tab does not disturb a request. + + // Request mouse lock. Bubble is displayed. + RequestToLockMouse(tab2, true, false); + ASSERT_TRUE(IsFullscreenBubbleDisplayed()); + + // Close tab1. Mouse lock bubble remains. + browser()->CloseTabContents(tab1); + ASSERT_TRUE(IsFullscreenBubbleDisplayed()); +} + +IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, + PendingMouseLockExitsOnTabClose) { + // Add more tabs. + AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL), + content::PAGE_TRANSITION_TYPED); + AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL), + content::PAGE_TRANSITION_TYPED); + + // Request mouse lock. Bubble is displayed. + RequestToLockMouse(browser()->GetActiveWebContents(), true, false); + ASSERT_TRUE(IsFullscreenBubbleDisplayed()); + + // Close tab. Bubble is cleared. + { + MouseLockNotificationObserver mouse_lock_observer; + browser()->CloseTab(); + mouse_lock_observer.Wait(); + } + ASSERT_FALSE(IsFullscreenBubbleDisplayed()); +} diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index 54fcd28..5853810 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -91,8 +91,6 @@ '-autofill.AutofillTest.testMergeAggregatedProfilesWithSameAddress', # crbug.com/99475 '-autofill.AutofillTest.testNoDuplicatePhoneNumsInPrefs', - # crbug.com/131702 - '-fullscreen_mouselock.FullscreenMouselockTest.testNoMLBubbleWhenTabLoseFocus', # crbug.com/123396 '-fullscreen_mouselock.FullscreenMouselockTest.testPatternsForFSAndML', # crbug.com/131874 |
