diff options
Diffstat (limited to 'chrome/browser/prerender')
-rw-r--r-- | chrome/browser/prerender/prerender_browsertest.cc | 28 | ||||
-rw-r--r-- | chrome/browser/prerender/prerender_contents.cc | 13 | ||||
-rw-r--r-- | chrome/browser/prerender/prerender_final_status.cc | 1 | ||||
-rw-r--r-- | chrome/browser/prerender/prerender_final_status.h | 1 |
4 files changed, 43 insertions, 0 deletions
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index 35b3bff..c9c46912c 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -1687,6 +1687,26 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, NavigateToURL("files/prerender/prerender_page.html"); } +// Checks that redirects with location.replace do not cancel a prerender and +// and swap when navigating to the first page. +IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, + PrerenderLocationReplaceNavigateToFirst) { + PrerenderTestURL("files/prerender/prerender_location_replace.html", + FINAL_STATUS_USED, + 2); + NavigateToDestURL(); +} + +// Checks that redirects with location.replace do not cancel a prerender and +// and swap when navigating to the second. +IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, + PrerenderLocationReplaceNavigateToSecond) { + PrerenderTestURL("files/prerender/prerender_location_replace.html", + FINAL_STATUS_USED, + 2); + NavigateToURL("files/prerender/prerender_page.html"); +} + // Checks that client-issued redirects work with prerendering. // This version navigates to the final destination page, rather than the // page which does the redirection via a mouse click. @@ -3285,4 +3305,12 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, NavigateToURLWithParams(params, false); } +// Checks that the prerendering of a page is canceled correctly when the +// prerendered page tries to make a second navigation entry. +IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNewNavigationEntry) { + PrerenderTestURL("files/prerender/prerender_new_entry.html", + FINAL_STATUS_NEW_NAVIGATION_ENTRY, + 1); +} + } // namespace prerender diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc index 9eb11de..6781ecf 100644 --- a/chrome/browser/prerender/prerender_contents.cc +++ b/chrome/browser/prerender/prerender_contents.cc @@ -586,6 +586,19 @@ void PrerenderContents::DidFinishLoad(int64 frame_id, void PrerenderContents::DidNavigateMainFrame( const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) { + // If the prerender made a second navigation entry, abort the prerender. This + // avoids having to correctly implement a complex history merging case (this + // interacts with location.replace) and correctly synchronize with the + // renderer. The final status may be monitored to see we need to revisit this + // decision. This does not affect client redirects as those do not push new + // history entries. (Calls to location.replace, navigations before onload, and + // <meta http-equiv=refresh> with timeouts under 1 second do not create + // entries in Blink.) + if (prerender_contents_->GetController().GetEntryCount() > 1) { + Destroy(FINAL_STATUS_NEW_NAVIGATION_ENTRY); + return; + } + // Add each redirect as an alias. |params.url| is included in // |params.redirects|. // diff --git a/chrome/browser/prerender/prerender_final_status.cc b/chrome/browser/prerender/prerender_final_status.cc index c84a4ae..ac0526d 100644 --- a/chrome/browser/prerender/prerender_final_status.cc +++ b/chrome/browser/prerender/prerender_final_status.cc @@ -58,6 +58,7 @@ const char* kFinalStatusNames[] = { "Page Being Captured", "Bad Deferred Redirect", "Navigation Uncommitted", + "New Navigation Entry", "Max", }; COMPILE_ASSERT(arraysize(kFinalStatusNames) == FINAL_STATUS_MAX + 1, diff --git a/chrome/browser/prerender/prerender_final_status.h b/chrome/browser/prerender/prerender_final_status.h index 1d702d5..41ab465 100644 --- a/chrome/browser/prerender/prerender_final_status.h +++ b/chrome/browser/prerender/prerender_final_status.h @@ -59,6 +59,7 @@ enum FinalStatus { FINAL_STATUS_PAGE_BEING_CAPTURED = 44, FINAL_STATUS_BAD_DEFERRED_REDIRECT = 45, FINAL_STATUS_NAVIGATION_UNCOMMITTED = 46, + FINAL_STATUS_NEW_NAVIGATION_ENTRY = 47, FINAL_STATUS_MAX, }; |