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

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

Issue 6824054: PrerenderContents uses RESOURCE_RECEIVED_REDIRECT notification. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 8 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 "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/prerender/prerender_contents.h" 8 #include "chrome/browser/prerender/prerender_contents.h"
9 #include "chrome/browser/prerender/prerender_manager.h" 9 #include "chrome/browser/prerender/prerender_manager.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 19 matching lines...) Expand all
30 // the page behaves as expected when prerendered. 30 // the page behaves as expected when prerendered.
31 // 31 //
32 // The prerendered page is then displayed on a tab. The Javascript function 32 // The prerendered page is then displayed on a tab. The Javascript function
33 // DidDisplayPass() is called, and returns true if the page behaved as it 33 // DidDisplayPass() is called, and returns true if the page behaved as it
34 // should while being displayed. 34 // should while being displayed.
35 35
36 namespace prerender { 36 namespace prerender {
37 37
38 namespace { 38 namespace {
39 39
40 bool CreateRedirect(const std::string& dest_url, std::string* redirect_path) { 40 std::string CreateClientRedirect(const std::string& dest_url) {
41 std::vector<net::TestServer::StringPair> replacement_text; 41 const char* const kClientRedirectBase = "client-redirect?";
42 replacement_text.push_back(make_pair("REPLACE_WITH_URL", dest_url)); 42 return kClientRedirectBase + dest_url;
43 return net::TestServer::GetFilePathWithReplacements( 43 }
44 "prerender_redirect.html", 44
45 replacement_text, 45 std::string CreateServerRedirect(const std::string& dest_url) {
46 redirect_path); 46 const char* const kServerRedirectBase = "server-redirect?";
47 return kServerRedirectBase + dest_url;
47 } 48 }
48 49
49 // PrerenderContents that stops the UI message loop on DidStopLoading(). 50 // PrerenderContents that stops the UI message loop on DidStopLoading().
50 class TestPrerenderContents : public PrerenderContents { 51 class TestPrerenderContents : public PrerenderContents {
51 public: 52 public:
52 TestPrerenderContents( 53 TestPrerenderContents(
53 PrerenderManager* prerender_manager, Profile* profile, const GURL& url, 54 PrerenderManager* prerender_manager, Profile* profile, const GURL& url,
54 const std::vector<GURL>& alias_urls, 55 const std::vector<GURL>& alias_urls,
55 const GURL& referrer, 56 const GURL& referrer,
56 int number_of_loads, 57 int number_of_loads,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Check if page behaved as expected when actually displayed. 174 // Check if page behaved as expected when actually displayed.
174 bool display_test_result = false; 175 bool display_test_result = false;
175 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 176 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
176 browser()->GetSelectedTabContents()->render_view_host(), L"", 177 browser()->GetSelectedTabContents()->render_view_host(), L"",
177 L"window.domAutomationController.send(DidDisplayPass())", 178 L"window.domAutomationController.send(DidDisplayPass())",
178 &display_test_result)); 179 &display_test_result));
179 EXPECT_TRUE(display_test_result); 180 EXPECT_TRUE(display_test_result);
180 } 181 }
181 182
182 bool UrlIsInPrerenderManager(const std::string& html_file) { 183 bool UrlIsInPrerenderManager(const std::string& html_file) {
183 GURL dest_url = UrlForHtmlFile(html_file); 184 GURL dest_url = test_server()->GetURL(html_file);
184
185 return (prerender_manager()->FindEntry(dest_url) != NULL); 185 return (prerender_manager()->FindEntry(dest_url) != NULL);
186 } 186 }
187 187
188 bool UrlIsInPrerenderManager(const GURL& url) {
189 return (prerender_manager()->FindEntry(url) != NULL);
190 }
191
188 bool UrlIsPendingInPrerenderManager(const std::string& html_file) { 192 bool UrlIsPendingInPrerenderManager(const std::string& html_file) {
189 GURL dest_url = UrlForHtmlFile(html_file); 193 GURL dest_url = test_server()->GetURL(html_file);
190
191 return (prerender_manager()->FindPendingEntry(dest_url) != NULL); 194 return (prerender_manager()->FindPendingEntry(dest_url) != NULL);
192 } 195 }
193 196
194 void set_use_https_src(bool use_https_src_server) { 197 void set_use_https_src(bool use_https_src_server) {
195 use_https_src_server_ = use_https_src_server; 198 use_https_src_server_ = use_https_src_server;
196 } 199 }
197 200
198 TaskManagerModel* model() const { 201 TaskManagerModel* model() const {
199 return TaskManager::GetInstance()->model(); 202 return TaskManager::GetInstance()->model();
200 } 203 }
201 204
205 void set_dest_url(const GURL& dest_url) { dest_url_ = dest_url; }
206
202 private: 207 private:
203 void PrerenderTestURLImpl( 208 void PrerenderTestURLImpl(
204 const std::string& html_file, 209 const std::string& html_file,
205 const std::deque<FinalStatus>& expected_final_status_queue, 210 const std::deque<FinalStatus>& expected_final_status_queue,
206 int total_navigations) { 211 int total_navigations) {
207 ASSERT_TRUE(test_server()->Start()); 212 ASSERT_TRUE(test_server()->Start());
208 dest_url_ = UrlForHtmlFile(html_file); 213 dest_url_ = test_server()->GetURL(html_file);
209 214
210 std::vector<net::TestServer::StringPair> replacement_text; 215 std::vector<net::TestServer::StringPair> replacement_text;
211 replacement_text.push_back( 216 replacement_text.push_back(
212 make_pair("REPLACE_WITH_PREFETCH_URL", dest_url_.spec())); 217 make_pair("REPLACE_WITH_PREFETCH_URL", dest_url_.spec()));
213 std::string replacement_path; 218 std::string replacement_path;
214 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements( 219 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements(
215 "files/prerender/prerender_loader.html", 220 "files/prerender/prerender_loader.html",
216 replacement_text, 221 replacement_text,
217 &replacement_path)); 222 &replacement_path));
218 223
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 break; 276 break;
272 } 277 }
273 } 278 }
274 279
275 PrerenderManager* prerender_manager() const { 280 PrerenderManager* prerender_manager() const {
276 Profile* profile = browser()->GetSelectedTabContents()->profile(); 281 Profile* profile = browser()->GetSelectedTabContents()->profile();
277 PrerenderManager* prerender_manager = profile->GetPrerenderManager(); 282 PrerenderManager* prerender_manager = profile->GetPrerenderManager();
278 return prerender_manager; 283 return prerender_manager;
279 } 284 }
280 285
281 // Non-const as test_server()->GetURL() is not const
282 GURL UrlForHtmlFile(const std::string& html_file) {
283 std::string dest_path = "files/prerender/";
284 dest_path.append(html_file);
285 return test_server()->GetURL(dest_path);
286 }
287
288 WaitForLoadPrerenderContentsFactory* prc_factory_; 286 WaitForLoadPrerenderContentsFactory* prc_factory_;
289 GURL dest_url_; 287 GURL dest_url_;
290 bool use_https_src_server_; 288 bool use_https_src_server_;
291 }; 289 };
292 290
293 // Checks that a page is correctly prerendered in the case of a 291 // Checks that a page is correctly prerendered in the case of a
294 // <link rel=prefetch> tag and then loaded into a tab in response to a 292 // <link rel=prefetch> tag and then loaded into a tab in response to a
295 // navigation. 293 // navigation.
296 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { 294 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) {
297 PrerenderTestURL("prerender_page.html", FINAL_STATUS_USED, 1); 295 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
298 NavigateToDestURL(); 296 NavigateToDestURL();
299 } 297 }
300 298
301 // Checks that the prerendering of a page is canceled correctly when a 299 // Checks that the prerendering of a page is canceled correctly when a
302 // Javascript alert is called. 300 // Javascript alert is called.
303 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderAlertBeforeOnload) { 301 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderAlertBeforeOnload) {
304 PrerenderTestURL("prerender_alert_before_onload.html", 302 PrerenderTestURL("files/prerender/prerender_alert_before_onload.html",
305 FINAL_STATUS_JAVASCRIPT_ALERT, 1); 303 FINAL_STATUS_JAVASCRIPT_ALERT,
304 1);
306 } 305 }
307 306
308 // Checks that the prerendering of a page is canceled correctly when a 307 // Checks that the prerendering of a page is canceled correctly when a
309 // Javascript alert is called. 308 // Javascript alert is called.
310 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderAlertAfterOnload) { 309 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderAlertAfterOnload) {
311 PrerenderTestURL("prerender_alert_after_onload.html", 310 PrerenderTestURL("files/prerender/prerender_alert_after_onload.html",
312 FINAL_STATUS_JAVASCRIPT_ALERT, 1); 311 FINAL_STATUS_JAVASCRIPT_ALERT,
312 1);
313 } 313 }
314 314
315 // Checks that plugins are not loaded while a page is being preloaded, but 315 // Checks that plugins are not loaded while a page is being preloaded, but
316 // are loaded when the page is displayed. 316 // are loaded when the page is displayed.
317 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDelayLoadPlugin) { 317 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDelayLoadPlugin) {
318 PrerenderTestURL("plugin_delay_load.html", FINAL_STATUS_USED, 1); 318 PrerenderTestURL("files/prerender/plugin_delay_load.html",
319 FINAL_STATUS_USED,
320 1);
319 NavigateToDestURL(); 321 NavigateToDestURL();
320 } 322 }
321 323
322 // Checks that plugins in an iframe are not loaded while a page is 324 // Checks that plugins in an iframe are not loaded while a page is
323 // being preloaded, but are loaded when the page is displayed. 325 // being preloaded, but are loaded when the page is displayed.
324 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderIframeDelayLoadPlugin) { 326 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderIframeDelayLoadPlugin) {
325 PrerenderTestURL("prerender_iframe_plugin_delay_load.html", 327 PrerenderTestURL("files/prerender/prerender_iframe_plugin_delay_load.html",
326 FINAL_STATUS_USED, 1); 328 FINAL_STATUS_USED,
329 1);
327 NavigateToDestURL(); 330 NavigateToDestURL();
328 } 331 }
329 332
330 // Renders a page that contains a prerender link to a page that contains an 333 // Renders a page that contains a prerender link to a page that contains an
331 // iframe with a source that requires http authentication. This should not 334 // iframe with a source that requires http authentication. This should not
332 // prerender successfully. 335 // prerender successfully.
333 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHttpAuthentication) { 336 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHttpAuthentication) {
334 PrerenderTestURL("prerender_http_auth_container.html", 337 PrerenderTestURL("files/prerender/prerender_http_auth_container.html",
335 FINAL_STATUS_AUTH_NEEDED, 1); 338 FINAL_STATUS_AUTH_NEEDED,
339 1);
336 } 340 }
337 341
338 // Checks that HTML redirects work with prerendering - specifically, checks the 342 // Checks that client-issued redirects work with prerendering.
339 // page is used and plugins aren't loaded. 343 // This version navigates to the page which issues the redirection, rather
340 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderRedirect) { 344 // than the final destination page.
345 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
346 PrerenderClientRedirectNavigateToFirst) {
347 PrerenderTestURL(
348 CreateClientRedirect("files/prerender/prerender_page.html"),
349 FINAL_STATUS_USED,
350 2);
351 NavigateToDestURL();
352 }
353
354 // Checks that client-issued redirects work with prerendering.
355 // This version navigates to the final destination page, rather than the
356 // page which does the redirection.
357 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
358 PrerenderClientRedirectNavigateToSecond) {
359 PrerenderTestURL(
360 CreateClientRedirect("files/prerender/prerender_page.html"),
361 FINAL_STATUS_USED,
362 2);
363 set_dest_url(test_server()->GetURL("files/prerender/prerender_page.html"));
364 NavigateToDestURL();
365 }
366
367 // Checks that client-issued redirects to an https page will cancel prerenders.
368 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClientRedirectToHttps) {
369 net::TestServer https_server(net::TestServer::TYPE_HTTPS,
370 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
371 ASSERT_TRUE(https_server.Start());
372 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html");
373 PrerenderTestURL(CreateClientRedirect(https_url.spec()),
374 FINAL_STATUS_HTTPS,
375 1);
376 }
377
378 // Checks that client-issued redirects within an iframe in a prerendered
379 // page will not count as an "alias" for the prerendered page.
380 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClientRedirectInIframe) {
381 std::string redirect_path = CreateClientRedirect(
382 "/files/prerender/prerender_embedded_content.html");
383 std::vector<net::TestServer::StringPair> replacement_text;
384 replacement_text.push_back(
385 std::make_pair("REPLACE_WITH_URL", "/" + redirect_path));
386 std::string replacement_path;
387 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements(
388 "files/prerender/prerender_with_iframe.html",
389 replacement_text,
390 &replacement_path));
391 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1);
392 EXPECT_FALSE(UrlIsInPrerenderManager(
393 "files/prerender/prerender_embedded_content.html"));
394 NavigateToDestURL();
395 }
396
397 // Checks that client-issued redirects within an iframe in a prerendered
398 // page to an https page will not cancel the prerender, nor will it
399 // count as an "alias" for the prerendered page.
400 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
401 PrerenderClientRedirectToHttpsInIframe) {
402 net::TestServer https_server(net::TestServer::TYPE_HTTPS,
403 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
404 ASSERT_TRUE(https_server.Start());
405 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html");
406 std::string redirect_path = CreateClientRedirect(https_url.spec());
407 std::vector<net::TestServer::StringPair> replacement_text;
408 replacement_text.push_back(
409 std::make_pair("REPLACE_WITH_URL", "/" + redirect_path));
410 std::string replacement_path;
411 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements(
412 "files/prerender/prerender_with_iframe.html",
413 replacement_text,
414 &replacement_path));
415 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1);
416 EXPECT_FALSE(UrlIsInPrerenderManager(https_url));
417 NavigateToDestURL();
418 }
419
420 // Checks that server-issued redirects work with prerendering.
421 // This version navigates to the page which issues the redirection, rather
422 // than the final destination page.
423 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
424 PrerenderServerRedirectNavigateToFirst) {
425 PrerenderTestURL(
426 CreateServerRedirect("files/prerender/prerender_page.html"),
427 FINAL_STATUS_USED,
428 1);
429 NavigateToDestURL();
430 }
431
432 // Checks that server-issued redirects work with prerendering.
433 // This version navigates to the final destination page, rather than the
434 // page which does the redirection.
435 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
436 PrerenderServerRedirectNavigateToSecond) {
341 std::string redirect_path; 437 std::string redirect_path;
342 ASSERT_TRUE(CreateRedirect("prerender_page.html", &redirect_path)); 438 PrerenderTestURL(
343 PrerenderTestURL(redirect_path, FINAL_STATUS_USED, 2); 439 CreateServerRedirect("files/prerender/prerender_page.html"),
440 FINAL_STATUS_USED,
441 1);
442 set_dest_url(test_server()->GetURL("files/prerender/prerender_page.html"));
443 NavigateToDestURL();
444 }
445
446 // TODO(cbentzel): Add server-redirect-to-https test. http://crbug.com/79182
447
448 // Checks that server-issued redirects within an iframe in a prerendered
449 // page will not count as an "alias" for the prerendered page.
450 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderServerRedirectInIframe) {
451 std::string redirect_path = CreateServerRedirect(
452 "/files/prerender/prerender_embedded_content.html");
453 std::vector<net::TestServer::StringPair> replacement_text;
454 replacement_text.push_back(
455 std::make_pair("REPLACE_WITH_URL", "/" + redirect_path));
456 std::string replacement_path;
457 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements(
458 "files/prerender/prerender_with_iframe.html",
459 replacement_text,
460 &replacement_path));
461 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1);
462 EXPECT_FALSE(UrlIsInPrerenderManager(
463 "files/prerender/prerender_embedded_content.html"));
464 NavigateToDestURL();
465 }
466
467 // Checks that server-issued redirects within an iframe in a prerendered
468 // page to an https page will not cancel the prerender, nor will it
469 // count as an "alias" for the prerendered page.
470 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
471 PrerenderServerRedirectToHttpsInIframe) {
472 net::TestServer https_server(net::TestServer::TYPE_HTTPS,
473 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
474 ASSERT_TRUE(https_server.Start());
475 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html");
476 std::string redirect_path = CreateServerRedirect(https_url.spec());
477 std::vector<net::TestServer::StringPair> replacement_text;
478 replacement_text.push_back(
479 std::make_pair("REPLACE_WITH_URL", "/" + redirect_path));
480 std::string replacement_path;
481 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements(
482 "files/prerender/prerender_with_iframe.html",
483 replacement_text,
484 &replacement_path));
485 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1);
486 EXPECT_FALSE(UrlIsInPrerenderManager(https_url));
344 NavigateToDestURL(); 487 NavigateToDestURL();
345 } 488 }
346 489
347 // Prerenders a page that contains an automatic download triggered through an 490 // Prerenders a page that contains an automatic download triggered through an
348 // iframe. This should not prerender successfully. 491 // iframe. This should not prerender successfully.
349 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadIFrame) { 492 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadIFrame) {
350 PrerenderTestURL("prerender_download_iframe.html", FINAL_STATUS_DOWNLOAD, 1); 493 PrerenderTestURL("files/prerender/prerender_download_iframe.html",
494 FINAL_STATUS_DOWNLOAD,
495 1);
351 } 496 }
352 497
353 // Prerenders a page that contains an automatic download triggered through 498 // Prerenders a page that contains an automatic download triggered through
354 // Javascript changing the window.location. This should not prerender 499 // Javascript changing the window.location. This should not prerender
355 // successfully. 500 // successfully.
356 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadLocation) { 501 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadLocation) {
357 std::string redirect_path; 502 PrerenderTestURL(CreateClientRedirect("files/download-test1.lib"),
358 ASSERT_TRUE(CreateRedirect("../download-test1.lib", &redirect_path)); 503 FINAL_STATUS_DOWNLOAD,
359 PrerenderTestURL(redirect_path, FINAL_STATUS_DOWNLOAD, 1); 504 1);
360 } 505 }
361 506
362 // Prerenders a page that contains an automatic download triggered through a 507 // Prerenders a page that contains an automatic download triggered through a
363 // <meta http-equiv="refresh"> tag. This should not prerender successfully. 508 // client-issued redirect. This should not prerender successfully.
364 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadRefresh) { 509 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadClientRedirect) {
365 PrerenderTestURL("prerender_download_refresh.html", FINAL_STATUS_DOWNLOAD, 1); 510 PrerenderTestURL("files/prerender/prerender_download_refresh.html",
511 FINAL_STATUS_DOWNLOAD,
512 1);
366 } 513 }
367 514
368 // Checks that the referrer is set when prerendering. 515 // Checks that the referrer is set when prerendering.
369 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReferrer) { 516 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReferrer) {
370 PrerenderTestURL("prerender_referrer.html", FINAL_STATUS_USED, 1); 517 PrerenderTestURL("files/prerender/prerender_referrer.html",
518 FINAL_STATUS_USED,
519 1);
371 NavigateToDestURL(); 520 NavigateToDestURL();
372 } 521 }
373 522
374 // Checks that the referrer is not set when prerendering and the source page is 523 // Checks that the referrer is not set when prerendering and the source page is
375 // HTTPS. 524 // HTTPS.
376 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNoSSLReferrer) { 525 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNoSSLReferrer) {
377 set_use_https_src(true); 526 set_use_https_src(true);
378 PrerenderTestURL("prerender_no_referrer.html", FINAL_STATUS_USED, 1); 527 PrerenderTestURL("files/prerender/prerender_no_referrer.html",
528 FINAL_STATUS_USED,
529 1);
379 NavigateToDestURL(); 530 NavigateToDestURL();
380 } 531 }
381 532
382 // Checks that popups on a prerendered page cause cancellation. 533 // Checks that popups on a prerendered page cause cancellation.
383 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) { 534 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) {
384 PrerenderTestURL("prerender_popup.html", FINAL_STATUS_CREATE_NEW_WINDOW, 1); 535 PrerenderTestURL("files/prerender/prerender_popup.html",
536 FINAL_STATUS_CREATE_NEW_WINDOW,
537 1);
385 } 538 }
386 539
387 // Test that page-based redirects to https will cancel prerenders. 540
388 // Disabled, http://crbug.com/73580
389 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderRedirectToHttps) {
390 net::TestServer https_server(net::TestServer::TYPE_HTTPS,
391 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
392 ASSERT_TRUE(https_server.Start());
393 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html");
394 std::string redirect_path;
395 ASSERT_TRUE(CreateRedirect(https_url.spec(), &redirect_path));
396 PrerenderTestURL(redirect_path, FINAL_STATUS_HTTPS, 1);
397 }
398 541
399 // Checks that renderers using excessive memory will be terminated. 542 // Checks that renderers using excessive memory will be terminated.
400 // Disabled, http://crbug.com/77870. 543 // Disabled, http://crbug.com/77870.
401 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 544 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
402 DISABLED_PrerenderExcessiveMemory) { 545 DISABLED_PrerenderExcessiveMemory) {
403 PrerenderTestURL("prerender_excessive_memory.html", 546 PrerenderTestURL("files/prerender/prerender_excessive_memory.html",
404 FINAL_STATUS_MEMORY_LIMIT_EXCEEDED, 1); 547 FINAL_STATUS_MEMORY_LIMIT_EXCEEDED,
548 1);
405 } 549 }
406 550
407 // Checks that we don't prerender in an infinite loop. 551 // Checks that we don't prerender in an infinite loop.
408 // Disabled, http://crbug.com/77870. 552 // Disabled, http://crbug.com/77870.
409 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderInfiniteLoop) { 553 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderInfiniteLoop) {
410 const char* const kHtmlFileA = "prerender_infinite_a.html"; 554 const char* const kHtmlFileA = "prerender_infinite_a.html";
411 const char* const kHtmlFileB = "prerender_infinite_b.html"; 555 const char* const kHtmlFileB = "prerender_infinite_b.html";
412 556
413 std::deque<FinalStatus> expected_final_status_queue; 557 std::deque<FinalStatus> expected_final_status_queue;
414 expected_final_status_queue.push_back(FINAL_STATUS_USED); 558 expected_final_status_queue.push_back(FINAL_STATUS_USED);
415 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); 559 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING);
416 560
417 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); 561 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1);
418 562
419 // Next url should be in pending list but not an active entry. 563 // Next url should be in pending list but not an active entry.
420 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); 564 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB));
421 EXPECT_TRUE(UrlIsPendingInPrerenderManager(kHtmlFileB)); 565 EXPECT_TRUE(UrlIsPendingInPrerenderManager(kHtmlFileB));
422 566
423 NavigateToDestURL(); 567 NavigateToDestURL();
424 568
425 // Make sure the PrerenderContents for the next url is now in the manager 569 // Make sure the PrerenderContents for the next url is now in the manager
426 // and not pending. 570 // and not pending.
427 EXPECT_TRUE(UrlIsInPrerenderManager(kHtmlFileB)); 571 EXPECT_TRUE(UrlIsInPrerenderManager(kHtmlFileB));
428 EXPECT_FALSE(UrlIsPendingInPrerenderManager(kHtmlFileB)); 572 EXPECT_FALSE(UrlIsPendingInPrerenderManager(kHtmlFileB));
429 } 573 }
430 574
431 // Checks that we don't prerender in an infinite loop and multiple links are 575 // Checks that we don't prerender in an infinite loop and multiple links are
432 // handled correctly. 576 // handled correctly.
433 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, FLAKY_PrerenderInfiniteLoopMultiple ) { 577 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
434 const char* const kHtmlFileA = "prerender_infinite_a_multiple.html"; 578 FLAKY_PrerenderInfiniteLoopMultiple) {
435 const char* const kHtmlFileB = "prerender_infinite_b_multiple.html"; 579 const char* const kHtmlFileA =
436 const char* const kHtmlFileC = "prerender_infinite_c_multiple.html"; 580 "files/prerender/prerender_infinite_a_multiple.html";
581 const char* const kHtmlFileB =
582 "files/prerender/prerender_infinite_b_multiple.html";
583 const char* const kHtmlFileC =
584 "files/prerender/prerender_infinite_c_multiple.html";
437 585
438 // We need to set the final status to expect here before starting any 586 // We need to set the final status to expect here before starting any
439 // prerenders. We set them on a queue so whichever we see first is expected to 587 // prerenders. We set them on a queue so whichever we see first is expected to
440 // be evicted, and the second should stick around until we exit. 588 // be evicted, and the second should stick around until we exit.
441 std::deque<FinalStatus> expected_final_status_queue; 589 std::deque<FinalStatus> expected_final_status_queue;
442 expected_final_status_queue.push_back(FINAL_STATUS_USED); 590 expected_final_status_queue.push_back(FINAL_STATUS_USED);
443 expected_final_status_queue.push_back(FINAL_STATUS_EVICTED); 591 expected_final_status_queue.push_back(FINAL_STATUS_EVICTED);
444 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); 592 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING);
445 593
446 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); 594 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1);
(...skipping 16 matching lines...) Expand all
463 EXPECT_FALSE(UrlIsPendingInPrerenderManager(kHtmlFileB)); 611 EXPECT_FALSE(UrlIsPendingInPrerenderManager(kHtmlFileB));
464 EXPECT_FALSE(UrlIsPendingInPrerenderManager(kHtmlFileC)); 612 EXPECT_FALSE(UrlIsPendingInPrerenderManager(kHtmlFileC));
465 } 613 }
466 614
467 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, TaskManager) { 615 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, TaskManager) {
468 // Show the task manager. This populates the model. 616 // Show the task manager. This populates the model.
469 browser()->window()->ShowTaskManager(); 617 browser()->window()->ShowTaskManager();
470 618
471 // Start with two resources. 619 // Start with two resources.
472 EXPECT_EQ(2, model()->ResourceCount()); 620 EXPECT_EQ(2, model()->ResourceCount());
473 PrerenderTestURL("prerender_page.html", FINAL_STATUS_USED, 1); 621 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
474 622
475 // The prerender makes three. 623 // The prerender makes three.
476 EXPECT_EQ(3, model()->ResourceCount()); 624 EXPECT_EQ(3, model()->ResourceCount());
477 625
478 // It shouldn't have a TabContents associated with it. 626 // It shouldn't have a TabContents associated with it.
479 ASSERT_TRUE(model()->GetResourceTabContents(1) == NULL); 627 ASSERT_TRUE(model()->GetResourceTabContents(1) == NULL);
480 628
481 // The prefix should be "Prerender:" 629 // The prefix should be "Prerender:"
482 string16 prefix = 630 string16 prefix =
483 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX, 631 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX,
484 string16()); 632 string16());
485 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(1), prefix, true)); 633 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(1), prefix, true));
486 634
487 NavigateToDestURL(); 635 NavigateToDestURL();
488 636
489 // Prerender task should be killed and removed from the Task Manager. 637 // Prerender task should be killed and removed from the Task Manager.
490 EXPECT_EQ(2, model()->ResourceCount()); 638 EXPECT_EQ(2, model()->ResourceCount());
491 } 639 }
492 640
493 // Checks that prerenderers will terminate when an audio tag is encountered. 641 // Checks that prerenderers will terminate when an audio tag is encountered.
494 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5Audio) { 642 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5Audio) {
495 PrerenderTestURL("prerender_html5_audio.html", FINAL_STATUS_HTML5_MEDIA, 1); 643 PrerenderTestURL("files/prerender/prerender_html5_audio.html",
644 FINAL_STATUS_HTML5_MEDIA,
645 1);
496 } 646 }
497 647
498 // Checks that prerenderers will terminate when a video tag is encountered. 648 // Checks that prerenderers will terminate when a video tag is encountered.
499 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5Video) { 649 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5Video) {
500 PrerenderTestURL("prerender_html5_video.html", FINAL_STATUS_HTML5_MEDIA, 1); 650 PrerenderTestURL("files/prerender/prerender_html5_video.html",
651 FINAL_STATUS_HTML5_MEDIA,
652 1);
501 } 653 }
502 654
503 // Checks that prerenderers will terminate when a video tag is inserted via 655 // Checks that prerenderers will terminate when a video tag is inserted via
504 // javascript. 656 // javascript.
505 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5VideoJs) { 657 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5VideoJs) {
506 PrerenderTestURL("prerender_html5_video_script.html", 658 PrerenderTestURL("files/prerender/prerender_html5_video_script.html",
507 FINAL_STATUS_HTML5_MEDIA, 1); 659 FINAL_STATUS_HTML5_MEDIA,
660 1);
508 } 661 }
509 662
510 } // namespace prerender 663 } // 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