Commit addff580 authored by Yao Xiao's avatar Yao Xiao Committed by Commit Bot

Fix flaky test *NetworkIsolationKeyReusedForBackNavigation*

It's suspected that there could be another request coming to the
completion callback, between the final navigation request and the final
assertion. Checking the URL in the completion callback to make sure we
are checking the cache status of the navigation request.

Bug: 1024033
Change-Id: I200f5c44ba72e6abcff7468f0e037a97cdf4fc53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087736Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Yao Xiao <yaoxia@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747053}
parent 903bad8e
...@@ -531,10 +531,8 @@ using ViewSourceWithSplitCacheEnabledTest = ViewSourceWithSplitCacheTest; ...@@ -531,10 +531,8 @@ using ViewSourceWithSplitCacheEnabledTest = ViewSourceWithSplitCacheTest;
// In the end, the test checks whether the back navigation request resource // In the end, the test checks whether the back navigation request resource
// exists in the cache. |exists_in_cache == true| implies the top_frame_origin // exists in the cache. |exists_in_cache == true| implies the top_frame_origin
// of the network isolation key is a.com (reused). // of the network isolation key is a.com (reused).
//
// Flaky. http://crbug.com/1024033
IN_PROC_BROWSER_TEST_P(ViewSourceWithSplitCacheEnabledTest, IN_PROC_BROWSER_TEST_P(ViewSourceWithSplitCacheEnabledTest,
DISABLED_NetworkIsolationKeyReusedForBackNavigation) { NetworkIsolationKeyReusedForBackNavigation) {
content::SetupCrossSiteRedirector(embedded_test_server()); content::SetupCrossSiteRedirector(embedded_test_server());
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
...@@ -545,10 +543,10 @@ IN_PROC_BROWSER_TEST_P(ViewSourceWithSplitCacheEnabledTest, ...@@ -545,10 +543,10 @@ IN_PROC_BROWSER_TEST_P(ViewSourceWithSplitCacheEnabledTest,
content::WebContents* original_contents = content::WebContents* original_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
std::string subframe_url =
GURL(embedded_test_server()->GetURL("b.com", "/title1.html")).spec();
{ {
// 2. Create a cross-site subframe b.com/title1.html // 2. Create a cross-site subframe b.com/title1.html
std::string subframe_url =
GURL(embedded_test_server()->GetURL("b.com", "/title1.html")).spec();
std::string create_frame_script = base::StringPrintf( std::string create_frame_script = base::StringPrintf(
"let frame = document.createElement('iframe');" "let frame = document.createElement('iframe');"
"frame.src = '%s';" "frame.src = '%s';"
...@@ -578,7 +576,7 @@ IN_PROC_BROWSER_TEST_P(ViewSourceWithSplitCacheEnabledTest, ...@@ -578,7 +576,7 @@ IN_PROC_BROWSER_TEST_P(ViewSourceWithSplitCacheEnabledTest,
ui_test_utils::NavigateToURL( ui_test_utils::NavigateToURL(
browser(), GURL(embedded_test_server()->GetURL("c.com", "/title1.html"))); browser(), GURL(embedded_test_server()->GetURL("c.com", "/title1.html")));
bool exists_in_cache = false; base::RunLoop cache_status_waiter;
content::URLLoaderInterceptor interceptor( content::URLLoaderInterceptor interceptor(
base::BindLambdaForTesting( base::BindLambdaForTesting(
[&](content::URLLoaderInterceptor::RequestParams* params) { [&](content::URLLoaderInterceptor::RequestParams* params) {
...@@ -587,7 +585,10 @@ IN_PROC_BROWSER_TEST_P(ViewSourceWithSplitCacheEnabledTest, ...@@ -587,7 +585,10 @@ IN_PROC_BROWSER_TEST_P(ViewSourceWithSplitCacheEnabledTest,
base::BindLambdaForTesting( base::BindLambdaForTesting(
[&](const GURL& request_url, [&](const GURL& request_url,
const network::URLLoaderCompletionStatus& status) { const network::URLLoaderCompletionStatus& status) {
exists_in_cache = status.exists_in_cache; if (request_url == subframe_url) {
EXPECT_TRUE(status.exists_in_cache);
cache_status_waiter.Quit();
}
}), }),
{}); {});
...@@ -600,7 +601,7 @@ IN_PROC_BROWSER_TEST_P(ViewSourceWithSplitCacheEnabledTest, ...@@ -600,7 +601,7 @@ IN_PROC_BROWSER_TEST_P(ViewSourceWithSplitCacheEnabledTest,
navigation_observer.Wait(); navigation_observer.Wait();
} }
EXPECT_TRUE(exists_in_cache); cache_status_waiter.Run();
} }
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
......
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