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