Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4706)

Unified Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 49003011: Handle should_replace_current_entry in prerender. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prerender/prerender_browsertest.cc
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index 7239181c9037cdbaa5a1ca74ec0cd72a95a5a4f5..6e7783413d5f44d81efd4dc61952ef203e070c7d 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -54,6 +54,8 @@
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_client_host.h"
#include "content/public/browser/devtools_manager.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
@@ -100,9 +102,11 @@ namespace prerender {
namespace {
+const char* kBlankURL = "about:blank";
mmenke 2013/12/12 15:52:12 Should probable just use content::kAboutBlankURL (
davidben 2013/12/12 16:58:47 Done.
+
// Constants used in the test HTML files.
-static const char* kReadyTitle = "READY";
-static const char* kPassTitle = "PASS";
+const char* kReadyTitle = "READY";
+const char* kPassTitle = "PASS";
std::string CreateClientRedirect(const std::string& dest_url) {
const char* const kClientRedirectBase = "client-redirect?";
@@ -829,7 +833,7 @@ class PrerenderBrowserTest : virtual public InProcessBrowserTest {
void NavigateToDestURLInNewTab() const {
// First, open a new tab.
current_browser()->OpenURL(
- content::OpenURLParams(GURL("chrome://blank"), Referrer(),
+ content::OpenURLParams(GURL(kBlankURL), Referrer(),
Charlie Reis 2013/12/12 02:46:38 This looks like an improvement to me, though it's
davidben 2013/12/12 16:58:47 It gives me ERR_INVALID_URL. But when I tried asse
Charlie Reis 2013/12/12 17:30:35 That could be FilterURL rewriting an illegal URL a
davidben 2013/12/13 01:00:39 (Turns out I'm actually confused and this function
NEW_FOREGROUND_TAB,
content::PAGE_TRANSITION_TYPED, false));
// Next, navigate to the destination URL. The swap-in will not succeed,
@@ -3348,4 +3352,23 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageNewTab) {
NavigateToDestURLInNewTab();
}
+// Checks that prerenders honor |should_replace_current_entry|.
+IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReplaceCurrentEntry) {
+ PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
+
+ content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB,
+ content::PAGE_TRANSITION_TYPED, false);
+ params.should_replace_current_entry = true;
+ NavigateToURLWithParams(params, false);
+
+ WebContents* web_contents =
+ current_browser()->tab_strip_model()->GetActiveWebContents();
+ const NavigationController& controller = web_contents->GetController();
+ // First entry is about:blank, second is prerender_page.html.
+ EXPECT_TRUE(controller.GetPendingEntry() == NULL);
+ EXPECT_EQ(2, controller.GetEntryCount());
+ EXPECT_EQ(GURL(kBlankURL), controller.GetEntryAtIndex(0)->GetURL());
+ EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL());
+}
+
} // namespace prerender
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698