Commit 60fa9c04 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Fix a few NetErrorAutoReloader browser tests

The disabled tests cover the effect of a WebContents' visibility on
its auto-reload behavior.

It turns out that visibility of WebContents within content_shell
behaves somewhat unexpectedly -- at least on Mac -- resulting
in the WebContents non-deterministically becoming visible during a
navigation, despite being explicitly hidden by test logic prior to
the navigation.

In order to avoid the resulting flakiness, this rearranges the test
logic so that forced visibility changes are imposed *after*
the relevant navigation rather than before it.

Fixed: 1110259
Change-Id: I38ab9d22a225018a8c5a1762cac15af45bf846e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2324163Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#792470}
parent 17e0a8b9
...@@ -495,29 +495,30 @@ IN_PROC_BROWSER_TEST_F(NetErrorAutoReloaderBrowserTest, ...@@ -495,29 +495,30 @@ IN_PROC_BROWSER_TEST_F(NetErrorAutoReloaderBrowserTest,
} }
// Auto-reload is not scheduled when the WebContents are hidden. // Auto-reload is not scheduled when the WebContents are hidden.
// TODO(crbug/1110259): The test is disabled due to flakiness on multiple platforms.
IN_PROC_BROWSER_TEST_F(NetErrorAutoReloaderBrowserTest, IN_PROC_BROWSER_TEST_F(NetErrorAutoReloaderBrowserTest,
DISABLED_NoAutoReloadWhenContentsHidden) { NoAutoReloadWhenContentsHidden) {
shell()->web_contents()->WasHidden();
// This would normally schedule an auto-reload, but we're offline.
NetErrorUrlInterceptor interceptor(GetTestUrl(), net::ERR_CONNECTION_RESET); NetErrorUrlInterceptor interceptor(GetTestUrl(), net::ERR_CONNECTION_RESET);
EXPECT_FALSE(NavigateMainFrame(GetTestUrl())); EXPECT_FALSE(NavigateMainFrame(GetTestUrl()));
EXPECT_EQ(GetDelayForReloadCount(0), GetCurrentAutoReloadDelay());
// Hiding the contents cancels the scheduled auto-reload.
shell()->web_contents()->WasHidden();
EXPECT_EQ(base::nullopt, GetCurrentAutoReloadDelay()); EXPECT_EQ(base::nullopt, GetCurrentAutoReloadDelay());
} }
// If the WebContents becomes visible while sitting at an error page that // If the WebContents becomes visible while sitting at an error page that
// supports auto-reload, a new auto-reload task should be scheduled. // supports auto-reload, a new auto-reload task should be scheduled.
// TODO(crbug/1110259): The test is disabled due to flakiness on multiple platforms.
IN_PROC_BROWSER_TEST_F(NetErrorAutoReloaderBrowserTest, IN_PROC_BROWSER_TEST_F(NetErrorAutoReloaderBrowserTest,
DISABLED_AutoReloadWhenContentsBecomeVisible) { AutoReloadWhenContentsBecomeVisible) {
shell()->web_contents()->WasHidden();
// This would normally schedule an auto-reload, but we're offline.
NetErrorUrlInterceptor interceptor(GetTestUrl(), net::ERR_CONNECTION_RESET); NetErrorUrlInterceptor interceptor(GetTestUrl(), net::ERR_CONNECTION_RESET);
EXPECT_FALSE(NavigateMainFrame(GetTestUrl())); EXPECT_FALSE(NavigateMainFrame(GetTestUrl()));
EXPECT_EQ(GetDelayForReloadCount(0), GetCurrentAutoReloadDelay());
// Hiding the contents cancels the scheduled auto-reload.
shell()->web_contents()->WasHidden();
EXPECT_EQ(base::nullopt, GetCurrentAutoReloadDelay()); EXPECT_EQ(base::nullopt, GetCurrentAutoReloadDelay());
// Becoming visible again reschedules auto-reload.
shell()->web_contents()->WasShown(); shell()->web_contents()->WasShown();
EXPECT_EQ(GetDelayForReloadCount(0), GetCurrentAutoReloadDelay()); EXPECT_EQ(GetDelayForReloadCount(0), GetCurrentAutoReloadDelay());
} }
......
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