| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/string16.h" | 6 #include "base/strings/string16.h" |
| 7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
| 8 #include "base/task_scheduler/post_task.h" | 8 #include "base/task_scheduler/post_task.h" |
| 9 #include "chrome/browser/prerender/prerender_handle.h" | 9 #include "chrome/browser/prerender/prerender_handle.h" |
| 10 #include "chrome/browser/prerender/prerender_manager.h" | 10 #include "chrome/browser/prerender/prerender_manager.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 FINAL_STATUS_RENDERER_CRASHED); | 396 FINAL_STATUS_RENDERER_CRASHED); |
| 397 std::unique_ptr<PrerenderHandle> prerender_handle( | 397 std::unique_ptr<PrerenderHandle> prerender_handle( |
| 398 GetPrerenderManager()->AddPrerenderFromExternalRequest( | 398 GetPrerenderManager()->AddPrerenderFromExternalRequest( |
| 399 GURL(content::kChromeUICrashURL), content::Referrer(), | 399 GURL(content::kChromeUICrashURL), content::Referrer(), |
| 400 storage_namespace, gfx::Rect(kSize))); | 400 storage_namespace, gfx::Rect(kSize))); |
| 401 ASSERT_EQ(prerender_handle->contents(), test_prerender->contents()); | 401 ASSERT_EQ(prerender_handle->contents(), test_prerender->contents()); |
| 402 test_prerender->WaitForStop(); | 402 test_prerender->WaitForStop(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 // Checks that the prefetch of png correctly loads the png. | 405 // Checks that the prefetch of png correctly loads the png. |
| 406 // TODO(pasko): Add support for prefetching non-HTML documents and re-enable the | 406 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, Png) { |
| 407 // test. | |
| 408 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, DISABLED_Png) { | |
| 409 RequestCounter counter; | 407 RequestCounter counter; |
| 410 CountRequestFor(kPrefetchPng, &counter); | 408 CountRequestFor(kPrefetchPng, &counter); |
| 411 PrefetchFromFile(kPrefetchPng, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); | 409 PrefetchFromFile(kPrefetchPng, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); |
| 412 counter.WaitForCount(1); | 410 counter.WaitForCount(1); |
| 413 } | 411 } |
| 414 | 412 |
| 415 // Checks that the prefetch of png correctly loads the jpeg. | 413 // Checks that the prefetch of png correctly loads the jpeg. |
| 416 // TODO(pasko): Add support for prefetching non-HTML documents and re-enable the | 414 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, Jpeg) { |
| 417 // test. | |
| 418 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, DISABLED_Jpeg) { | |
| 419 RequestCounter counter; | 415 RequestCounter counter; |
| 420 CountRequestFor(kPrefetchJpeg, &counter); | 416 CountRequestFor(kPrefetchJpeg, &counter); |
| 421 PrefetchFromFile(kPrefetchJpeg, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); | 417 PrefetchFromFile(kPrefetchJpeg, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); |
| 422 counter.WaitForCount(1); | 418 counter.WaitForCount(1); |
| 423 } | 419 } |
| 424 | 420 |
| 425 // Checks that nothing is prefetched from malware sites. | 421 // Checks that nothing is prefetched from malware sites. |
| 426 // TODO(mattcary): disabled as prefetch process teardown is racey with prerender | 422 // TODO(mattcary): disabled as prefetch process teardown is racey with prerender |
| 427 // contents destruction, can fix when prefetch prerenderers are destroyed | 423 // contents destruction, can fix when prefetch prerenderers are destroyed |
| 428 // deterministically. | 424 // deterministically. |
| 429 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, | 425 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, |
| 430 DISABLED_PrerenderSafeBrowsingTopLevel) { | 426 DISABLED_PrerenderSafeBrowsingTopLevel) { |
| 431 GURL url = src_server()->GetURL(MakeAbsolute(kPrefetchPage)); | 427 GURL url = src_server()->GetURL(MakeAbsolute(kPrefetchPage)); |
| 432 GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl( | 428 GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl( |
| 433 url, safe_browsing::SB_THREAT_TYPE_URL_MALWARE); | 429 url, safe_browsing::SB_THREAT_TYPE_URL_MALWARE); |
| 434 // Prefetch resources are blocked, but the prerender is not killed in any | 430 // Prefetch resources are blocked, but the prerender is not killed in any |
| 435 // special way. | 431 // special way. |
| 436 // TODO(mattcary): since the prerender will count itself as loaded even if the | 432 // TODO(mattcary): since the prerender will count itself as loaded even if the |
| 437 // fetch of the main resource fails, the test doesn't actually confirm what we | 433 // fetch of the main resource fails, the test doesn't actually confirm what we |
| 438 // want it to confirm. This may be fixed by planned changes to the prerender | 434 // want it to confirm. This may be fixed by planned changes to the prerender |
| 439 // lifecycle. | 435 // lifecycle. |
| 440 std::unique_ptr<TestPrerender> prerender = | 436 std::unique_ptr<TestPrerender> prerender = |
| 441 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_SAFE_BROWSING); | 437 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_SAFE_BROWSING); |
| 442 } | 438 } |
| 443 | 439 |
| 444 } // namespace prerender | 440 } // namespace prerender |
| OLD | NEW |