Commit a79e01b5 authored by François Doray's avatar François Doray Committed by Commit Bot

Re-enable TabManagerTest.DiscardTabsWithMinimizedAndOccludedWindows.

The crash stack on the bug is in non-TabManager code. Let's see if
the test passes when re-enabled.

This CL also:
- Splits the test in 2 tests to avoid timing out (local tests show
  that we can time out when having too many navigations in the same
  test).
- On ChromeOS, allows discarding of the active tab in the last focused
  browser window if that window is not visible. Previously, the active
  tab in the last focused browser window was not discardable, even if
  the window was not visible.

Bug: 772839
Change-Id: I18552a16361c8beb4d48409227b727a40cc40ec7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1972570
Commit-Queue: Chris Hamilton <chrisha@chromium.org>
Auto-Submit: François Doray <fdoray@chromium.org>
Reviewed-by: default avatarChris Hamilton <chrisha@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728572}
parent c14545e9
......@@ -1043,6 +1043,15 @@ void TabLifecycleUnitSource::TabLifecycleUnit::DidStartLoading() {
void TabLifecycleUnitSource::TabLifecycleUnit::OnVisibilityChanged(
content::Visibility visibility) {
// Ensure that the tab is not considered focused when not visible.
//
// TabLifeycleUnitSource calls SetFocused(false) when focus changes to another
// tab. The code below is also required to cover the case where the focused
// tab is hidden but no other tab is focused, which can happen when the
// focused window is minimized or occluded.
if (visibility != content::Visibility::VISIBLE)
SetFocused(false);
OnLifecycleUnitVisibilityChanged(visibility);
}
......
......@@ -1490,71 +1490,66 @@ Browser* CreateBrowserWithTabs(int num_tabs) {
} // namespace
// Flaky on Linux. Times out on Windows and Mac debug builds.
// http://crbug.com/772839.
#if defined(OS_LINUX) || \
((defined(OS_WIN) || defined(OS_MACOSX)) && !defined(NDEBUG))
#define MAYBE_DiscardTabsWithMinimizedAndOccludedWindows \
DISABLED_DiscardTabsWithMinimizedAndOccludedWindows
#else
#define MAYBE_DiscardTabsWithMinimizedAndOccludedWindows \
DiscardTabsWithMinimizedAndOccludedWindows
#endif
IN_PROC_BROWSER_TEST_F(TabManagerTest,
MAYBE_DiscardTabsWithMinimizedAndOccludedWindows) {
// Covered by |browser2|.
Browser* browser1 = browser();
EnsureTabsInBrowser(browser1, 2);
browser1->window()->SetBounds(gfx::Rect(10, 10, 10, 10));
// Covers |browser1|.
Browser* browser2 = CreateBrowserWithTabs(2);
EXPECT_NE(browser1, browser2);
browser2->window()->SetBounds(gfx::Rect(0, 0, 100, 100));
// Active browser.
Browser* browser3 = CreateBrowserWithTabs(2);
EXPECT_NE(browser1, browser3);
EXPECT_NE(browser2, browser3);
browser3->window()->SetBounds(gfx::Rect(110, 0, 100, 100));
IN_PROC_BROWSER_TEST_F(TabManagerTest, DiscardTabsWithMinimizedWindow) {
// Minimized browser.
Browser* browser4 = CreateBrowserWithTabs(2);
browser4->window()->Minimize();
EXPECT_NE(browser1, browser4);
EXPECT_NE(browser2, browser4);
EXPECT_NE(browser3, browser4);
EnsureTabsInBrowser(browser(), 2);
browser()->window()->Minimize();
// Other browser that will be last active. This browser exists because the
// last active tab cannot be discarded on
// Advance time so everything is urgent discardable.
test_clock_.Advance(kBackgroundUrgentProtectionTime);
for (int i = 0; i < 8; ++i)
tab_manager()->DiscardTab(LifecycleUnitDiscardReason::PROACTIVE);
for (int i = 0; i < 2; ++i)
tab_manager()->DiscardTab(LifecycleUnitDiscardReason::URGENT);
base::RunLoop().RunUntilIdle();
// On ChromeOS, active tabs are discarded if their window is non-visible. On
// other platforms, they are never discarded.
#if defined(OS_CHROMEOS)
EXPECT_TRUE(IsTabDiscarded(browser1->tab_strip_model()->GetWebContentsAt(0)));
EXPECT_FALSE(
IsTabDiscarded(browser2->tab_strip_model()->GetWebContentsAt(0)));
EXPECT_FALSE(
IsTabDiscarded(browser3->tab_strip_model()->GetWebContentsAt(0)));
EXPECT_TRUE(IsTabDiscarded(browser4->tab_strip_model()->GetWebContentsAt(0)));
EXPECT_TRUE(
IsTabDiscarded(browser()->tab_strip_model()->GetWebContentsAt(0)));
#else
EXPECT_FALSE(
IsTabDiscarded(browser1->tab_strip_model()->GetWebContentsAt(0)));
EXPECT_FALSE(
IsTabDiscarded(browser2->tab_strip_model()->GetWebContentsAt(0)));
EXPECT_FALSE(
IsTabDiscarded(browser3->tab_strip_model()->GetWebContentsAt(0)));
IsTabDiscarded(browser()->tab_strip_model()->GetWebContentsAt(0)));
#endif
// Non-active tabs can be discarded on all platforms.
EXPECT_TRUE(
IsTabDiscarded(browser()->tab_strip_model()->GetWebContentsAt(1)));
}
IN_PROC_BROWSER_TEST_F(TabManagerTest, DiscardTabsWithOccludedWindow) {
// Occluded browser.
EnsureTabsInBrowser(browser(), 2);
browser()->window()->SetBounds(gfx::Rect(10, 10, 10, 10));
// Other browser that covers the occluded browser.
Browser* other_browser = CreateBrowserWithTabs(1);
EXPECT_NE(other_browser, browser());
other_browser->window()->SetBounds(gfx::Rect(0, 0, 100, 100));
// Advance time so everything is urgent discardable.
test_clock_.Advance(kBackgroundUrgentProtectionTime);
for (int i = 0; i < 3; ++i)
tab_manager()->DiscardTab(LifecycleUnitDiscardReason::URGENT);
base::RunLoop().RunUntilIdle();
// On ChromeOS, active tabs are discarded if their window is non-visible. On
// other platforms, they are never discarded.
#if defined(OS_CHROMEOS)
EXPECT_TRUE(
IsTabDiscarded(browser()->tab_strip_model()->GetWebContentsAt(0)));
#else
EXPECT_FALSE(
IsTabDiscarded(browser4->tab_strip_model()->GetWebContentsAt(0)));
IsTabDiscarded(browser()->tab_strip_model()->GetWebContentsAt(0)));
#endif
// Non-active tabs can be discarded on all platforms.
EXPECT_TRUE(IsTabDiscarded(browser1->tab_strip_model()->GetWebContentsAt(1)));
EXPECT_TRUE(IsTabDiscarded(browser2->tab_strip_model()->GetWebContentsAt(1)));
EXPECT_TRUE(IsTabDiscarded(browser3->tab_strip_model()->GetWebContentsAt(1)));
EXPECT_TRUE(IsTabDiscarded(browser4->tab_strip_model()->GetWebContentsAt(1)));
EXPECT_TRUE(
IsTabDiscarded(browser()->tab_strip_model()->GetWebContentsAt(1)));
}
IN_PROC_BROWSER_TEST_F(TabManagerTest, UnfreezeTabOnNavigationEvent) {
......
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