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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 6523062: Cancel prerender if any of the visited URLs are https. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "chrome/browser/prerender/prerender_contents.h" 7 #include "chrome/browser/prerender/prerender_contents.h"
8 #include "chrome/browser/prerender/prerender_manager.h" 8 #include "chrome/browser/prerender/prerender_manager.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/tab_contents/tab_contents.h" 10 #include "chrome/browser/tab_contents/tab_contents.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 command_line->AppendSwitchPath( 107 command_line->AppendSwitchPath(
108 switches::kExtraPluginDir, 108 switches::kExtraPluginDir,
109 app_dir.Append(FILE_PATH_LITERAL("plugins"))); 109 app_dir.Append(FILE_PATH_LITERAL("plugins")));
110 #endif 110 #endif
111 } 111 }
112 112
113 void PrerenderTestURL(const std::string& html_file, 113 void PrerenderTestURL(const std::string& html_file,
114 FinalStatus expected_final_status, 114 FinalStatus expected_final_status,
115 int total_navigations) { 115 int total_navigations) {
116 ASSERT_TRUE(test_server()->Start()); 116 ASSERT_TRUE(test_server()->Start());
117
118 std::string src_path = "files/prerender/prerender_loader.html?";
119 src_path.append(html_file);
120 std::string dest_path = "files/prerender/"; 117 std::string dest_path = "files/prerender/";
121 dest_path.append(html_file); 118 dest_path.append(html_file);
119 dest_url_ = test_server()->GetURL(dest_path);
122 120
123 GURL src_url = test_server()->GetURL(src_path); 121 std::vector<net::TestServer::StringPair> replacement_text;
124 dest_url_ = test_server()->GetURL(dest_path); 122 replacement_text.push_back(
123 make_pair("REPLACE_WITH_PREFETCH_URL", dest_url_.spec()));
124 std::string replacement_path;
125 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements(
126 "files/prerender/prerender_loader.html",
127 replacement_text,
128 &replacement_path));
129 GURL src_url = test_server()->GetURL(replacement_path);
125 130
126 Profile* profile = browser()->GetSelectedTabContents()->profile(); 131 Profile* profile = browser()->GetSelectedTabContents()->profile();
127 PrerenderManager* prerender_manager = profile->GetPrerenderManager(); 132 PrerenderManager* prerender_manager = profile->GetPrerenderManager();
128 ASSERT_TRUE(prerender_manager); 133 ASSERT_TRUE(prerender_manager);
129 134
130 // This is needed to exit the event loop once the prerendered page has 135 // This is needed to exit the event loop once the prerendered page has
131 // stopped loading or was cancelled. 136 // stopped loading or was cancelled.
132 prerender_manager->SetPrerenderContentsFactory( 137 prerender_manager->SetPrerenderContentsFactory(
133 new WaitForLoadPrerenderContentsFactory(expected_final_status)); 138 new WaitForLoadPrerenderContentsFactory(expected_final_status));
134 139
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 FINAL_STATUS_USED, 1); 260 FINAL_STATUS_USED, 1);
256 NavigateToDestURL(); 261 NavigateToDestURL();
257 } 262 }
258 263
259 // Checks that popups on a prerendered page cause cancellation. 264 // Checks that popups on a prerendered page cause cancellation.
260 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) { 265 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) {
261 PrerenderTestURL("prerender_popup.html", 266 PrerenderTestURL("prerender_popup.html",
262 FINAL_STATUS_CREATE_NEW_WINDOW, 1); 267 FINAL_STATUS_CREATE_NEW_WINDOW, 1);
263 } 268 }
264 269
270 // Test that page-based redirects to https will cancel prerenders.
271 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderRedirectToHttps) {
272 net::TestServer https_server(net::TestServer::TYPE_HTTPS,
273 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
274 ASSERT_TRUE(https_server.Start());
275 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html");
276 std::vector<net::TestServer::StringPair> replacement_text;
277 replacement_text.push_back(
278 make_pair("REPLACE_WITH_HTTPS_URL", https_url.spec()));
279 std::string redirect_path;
280 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements(
281 "prerender_redirect_to_https.html",
282 replacement_text,
283 &redirect_path));
284 PrerenderTestURL(redirect_path,
285 FINAL_STATUS_HTTPS,
286 2);
287 }
288
265 } // namespace prerender 289 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_contents.h » ('j') | chrome/browser/prerender/prerender_contents.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698