| OLD | NEW |
| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 command_line->AppendSwitchPath( | 104 command_line->AppendSwitchPath( |
| 105 switches::kExtraPluginDir, | 105 switches::kExtraPluginDir, |
| 106 app_dir.Append(FILE_PATH_LITERAL("plugins"))); | 106 app_dir.Append(FILE_PATH_LITERAL("plugins"))); |
| 107 #endif | 107 #endif |
| 108 } | 108 } |
| 109 | 109 |
| 110 void PrerenderTestURL(const std::string& html_file, | 110 void PrerenderTestURL(const std::string& html_file, |
| 111 FinalStatus expected_final_status, | 111 FinalStatus expected_final_status, |
| 112 int total_navigations) { | 112 int total_navigations) { |
| 113 ASSERT_TRUE(test_server()->Start()); | 113 ASSERT_TRUE(test_server()->Start()); |
| 114 | |
| 115 std::string src_path = "files/prerender/prerender_loader.html?"; | 114 std::string src_path = "files/prerender/prerender_loader.html?"; |
| 116 src_path.append(html_file); | 115 src_path.append(html_file); |
| 117 std::string dest_path = "files/prerender/"; | 116 std::string dest_path = "files/prerender/"; |
| 118 dest_path.append(html_file); | 117 dest_path.append(html_file); |
| 119 | 118 |
| 120 GURL src_url = test_server()->GetURL(src_path); | 119 GURL src_url = test_server()->GetURL(src_path); |
| 121 dest_url_ = test_server()->GetURL(dest_path); | 120 dest_url_ = test_server()->GetURL(dest_path); |
| 122 | 121 |
| 123 Profile* profile = browser()->GetSelectedTabContents()->profile(); | 122 Profile* profile = browser()->GetSelectedTabContents()->profile(); |
| 124 PrerenderManager* prerender_manager = profile->GetPrerenderManager(); | 123 PrerenderManager* prerender_manager = profile->GetPrerenderManager(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 FINAL_STATUS_AUTH_NEEDED, 1); | 238 FINAL_STATUS_AUTH_NEEDED, 1); |
| 240 } | 239 } |
| 241 | 240 |
| 242 // Checks that redirects work with prerendering. | 241 // Checks that redirects work with prerendering. |
| 243 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderRedirect) { | 242 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderRedirect) { |
| 244 PrerenderTestURL("prerender_redirect.html", | 243 PrerenderTestURL("prerender_redirect.html", |
| 245 FINAL_STATUS_USED, 2); | 244 FINAL_STATUS_USED, 2); |
| 246 NavigateToDestURL(); | 245 NavigateToDestURL(); |
| 247 } | 246 } |
| 248 | 247 |
| 248 // Prerenders a page that contains an automatic download triggered through an |
| 249 // iframe. This should not prerender successfully. |
| 250 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadIFrame) { |
| 251 PrerenderTestURL("prerender_download_iframe.html", |
| 252 FINAL_STATUS_DOWNLOAD, 1); |
| 253 } |
| 254 |
| 255 // Prerenders a page that contains an automatic download triggered through |
| 256 // Javascript changing the window.location. This should not prerender |
| 257 // successfully. |
| 258 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadLocation) { |
| 259 PrerenderTestURL("prerender_download_location.html", |
| 260 FINAL_STATUS_DOWNLOAD, 2); |
| 261 } |
| 262 |
| 263 // Prerenders a page that contains an automatic download triggered through a |
| 264 // <meta http-equiv="refresh"> tag. This should not prerender successfully. |
| 265 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadRefresh) { |
| 266 PrerenderTestURL("prerender_download_refresh.html", |
| 267 FINAL_STATUS_DOWNLOAD, 2); |
| 268 } |
| 269 |
| 249 // Checks that popups on a prerendered page cause cancellation. | 270 // Checks that popups on a prerendered page cause cancellation. |
| 250 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) { | 271 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) { |
| 251 PrerenderTestURL("prerender_popup.html", | 272 PrerenderTestURL("prerender_popup.html", |
| 252 FINAL_STATUS_CREATE_NEW_WINDOW, 1); | 273 FINAL_STATUS_CREATE_NEW_WINDOW, 1); |
| 253 } | 274 } |
| 254 | 275 |
| 255 } // namespace prerender | 276 } // namespace prerender |
| OLD | NEW |