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

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
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_contents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 std::string src_path = "files/prerender/prerender_loader.html?";
118 src_path.append(html_file);
119 std::string dest_path = "files/prerender/"; 117 std::string dest_path = "files/prerender/";
120 dest_path.append(html_file); 118 dest_path.append(html_file);
119 dest_url_ = test_server()->GetURL(dest_path);
121 120
122 GURL src_url = test_server()->GetURL(src_path); 121 std::vector<net::TestServer::StringPair> replacement_text;
123 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);
124 130
125 Profile* profile = browser()->GetSelectedTabContents()->profile(); 131 Profile* profile = browser()->GetSelectedTabContents()->profile();
126 PrerenderManager* prerender_manager = profile->GetPrerenderManager(); 132 PrerenderManager* prerender_manager = profile->GetPrerenderManager();
127 ASSERT_TRUE(prerender_manager); 133 ASSERT_TRUE(prerender_manager);
128 134
129 // 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
130 // stopped loading or was cancelled. 136 // stopped loading or was cancelled.
131 prerender_manager->SetPrerenderContentsFactory( 137 prerender_manager->SetPrerenderContentsFactory(
132 new WaitForLoadPrerenderContentsFactory(expected_final_status)); 138 new WaitForLoadPrerenderContentsFactory(expected_final_status));
133 139
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 FINAL_STATUS_USED, 1); 290 FINAL_STATUS_USED, 1);
285 NavigateToDestURL(); 291 NavigateToDestURL();
286 } 292 }
287 293
288 // Checks that popups on a prerendered page cause cancellation. 294 // Checks that popups on a prerendered page cause cancellation.
289 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) { 295 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) {
290 PrerenderTestURL("prerender_popup.html", 296 PrerenderTestURL("prerender_popup.html",
291 FINAL_STATUS_CREATE_NEW_WINDOW, 1); 297 FINAL_STATUS_CREATE_NEW_WINDOW, 1);
292 } 298 }
293 299
300 // Test that page-based redirects to https will cancel prerenders.
301 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderRedirectToHttps) {
302 net::TestServer https_server(net::TestServer::TYPE_HTTPS,
303 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
304 ASSERT_TRUE(https_server.Start());
305 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html");
306 std::vector<net::TestServer::StringPair> replacement_text;
307 replacement_text.push_back(
308 make_pair("REPLACE_WITH_HTTPS_URL", https_url.spec()));
309 std::string redirect_path;
310 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements(
311 "prerender_redirect_to_https.html",
312 replacement_text,
313 &redirect_path));
314 PrerenderTestURL(redirect_path,
315 FINAL_STATUS_HTTPS,
316 2);
317 }
318
294 } // namespace prerender 319 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698