Commit 841efc17 authored by mattcary's avatar mattcary Committed by Commit bot

Prerender: avoid race condition with canceling prerender in test.

The test which started flaking started two prerenderers, the second which canceled the first. ChromeOS in particular exposed a race condition where the first prerender would complete before the second had a chance to cancel it. This in retrospect obvious situation exists elsewhere and has an easy fix in a HangingFirstRequestInterceptor which stalls the first prerender indefinitely, causing it to be reliably canceled by the second.

BUG=679090

TBR=droger

Review-Url: https://codereview.chromium.org/2616383002
Cr-Commit-Position: refs/heads/master@{#442918}
parent 9dddc3fa
......@@ -3294,10 +3294,16 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, FirstContentfulPaintTimingReuse) {
base::SimpleTestTickClock* clock = OverridePrerenderManagerTimeTicks();
GURL url = embedded_test_server()->GetURL("/prerender/prerender_page.html");
base::RunLoop hanging_request_waiter;
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&CreateHangingFirstRequestInterceptorOnIO,
url, GetTestPath("prerender_page.html"),
hanging_request_waiter.QuitClosure()));
// As this load will be canceled, it is not waited for, and hence no
// javascript is executed.
DisableJavascriptCalls();
PrerenderTestURL(url, FINAL_STATUS_CANCELLED, 0);
hanging_request_waiter.Run();
// This prerender cancels and reuses the first.
clock->Advance(base::TimeDelta::FromSeconds(1));
......
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