Commit 084581b6 authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

Fix flaky back-forward cache tests.

After a navigation, if the old page do NOT enter the back-forward cache,
it starts pending deletion. This is asynchronous, so tests shouldn't
make the assumption it is deleted immediately.

Bug: 1014799, 1013802
Change-Id: I446117f58970280ea5445b57469e6e6c7c37ea5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865343Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706878}
parent a86070ad
......@@ -491,18 +491,17 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, BackForwardCacheFlush) {
// 3) Flush A.
web_contents()->GetController().GetBackForwardCache().Flush();
EXPECT_TRUE(delete_observer_rfh_a.deleted());
EXPECT_TRUE(delete_observer_rfh_a.deleted()); // Flush is synchronous.
EXPECT_FALSE(delete_observer_rfh_b.deleted());
// 4) Go back to a new A.
web_contents()->GetController().GoBack();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
EXPECT_TRUE(delete_observer_rfh_a.deleted());
EXPECT_FALSE(delete_observer_rfh_b.deleted());
// 5) Flush B.
web_contents()->GetController().GetBackForwardCache().Flush();
EXPECT_TRUE(delete_observer_rfh_b.deleted());
EXPECT_TRUE(delete_observer_rfh_b.deleted()); // Flush is synchronous.
}
// Check the visible URL in the omnibox is properly updated when restoring a
......@@ -1887,7 +1886,7 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
// rfh_a should have been deleted, and page A navigated to normally.
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
EXPECT_TRUE(delete_observer_rfh_a.deleted());
delete_observer_rfh_a.WaitUntilDeleted();
RenderFrameHostImpl* rfh_a2 = current_frame_host();
EXPECT_NE(rfh_a2, rfh_b);
EXPECT_EQ(rfh_a2->GetLastCommittedURL(), url_a);
......@@ -1927,7 +1926,7 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
// The cached RenderFrameHost should be destroyed (not kept in the cache).
crash_observer.Wait();
EXPECT_TRUE(delete_observer_rfh_a.deleted());
delete_observer_rfh_a.WaitUntilDeleted();
// rfh_b should still be the current frame.
EXPECT_EQ(current_frame_host(), rfh_b);
......@@ -2038,7 +2037,7 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, FetchWhileStoring) {
// 3) Go back to A.
web_contents()->GetController().GoBack();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
EXPECT_TRUE(delete_observer_rfh_a.deleted());
delete_observer_rfh_a.WaitUntilDeleted();
}
// Only HTTP/HTTPS main document can enter the BackForwardCache.
......@@ -2477,7 +2476,7 @@ IN_PROC_BROWSER_TEST_F(
// 2) Navigate to B.
EXPECT_TRUE(NavigateToURL(shell(), url_b));
EXPECT_TRUE(delete_observer_rfh_a.deleted());
delete_observer_rfh_a.WaitUntilDeleted();
// 3) Go back to A.
web_contents()->GetController().GoBack();
......@@ -2504,7 +2503,7 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
// 2) Navigate to B.
EXPECT_TRUE(NavigateToURL(shell(), url_b));
EXPECT_TRUE(delete_observer_rfh_a.deleted());
delete_observer_rfh_a.WaitUntilDeleted();
// This should not die
BackForwardCache::DisableForRenderFrameHost(
......@@ -2517,15 +2516,8 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
ExpectEvictedIsEmpty(FROM_HERE);
}
#if defined(OS_LINUX) || defined(OS_WIN)
// Flaky. https://crbug.com/1013802
#define MAYBE_DisableBackForwardCacheIframe \
DISABLED_DisableBackForwardCacheIframe
#else
#define MAYBE_DisableBackForwardCacheIframe DisableBackForwardCacheIframe
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
MAYBE_DisableBackForwardCacheIframe) {
DisableBackForwardCacheIframe) {
ASSERT_TRUE(embedded_test_server()->Start());
GURL url_a(embedded_test_server()->GetURL(
"a.com", "/cross_site_iframe_factory.html?a(b)"));
......@@ -2541,10 +2533,10 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
BackForwardCache::DisableForRenderFrameHost(
rfh_b, "DisabledByBackForwardCacheBrowserTest");
// 2) Navigate to C. A and B are immediately deleted.
// 2) Navigate to C. A and B are deleted.
EXPECT_TRUE(NavigateToURL(shell(), url_c));
EXPECT_TRUE(delete_observer_rfh_a.deleted());
EXPECT_TRUE(delete_observer_rfh_b.deleted());
delete_observer_rfh_a.WaitUntilDeleted();
delete_observer_rfh_b.WaitUntilDeleted();
// 3) Go back to A.
web_contents()->GetController().GoBack();
......
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