Chromium Code Reviews| 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 <deque> | |
| 6 | |
| 5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 6 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 7 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 8 #include "chrome/browser/prerender/prerender_contents.h" | 10 #include "chrome/browser/prerender/prerender_contents.h" |
| 9 #include "chrome/browser/prerender/prerender_manager.h" | 11 #include "chrome/browser/prerender/prerender_manager.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/task_manager/task_manager.h" | 13 #include "chrome/browser/task_manager/task_manager.h" |
| 12 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/test/in_process_browser_test.h" | 18 #include "chrome/test/in_process_browser_test.h" |
| 17 #include "chrome/test/ui_test_utils.h" | 19 #include "chrome/test/ui_test_utils.h" |
| 18 #include "content/browser/tab_contents/tab_contents.h" | 20 #include "content/browser/tab_contents/tab_contents.h" |
| 19 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 20 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
| 21 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 23 | 25 |
| 24 #include <deque> | |
| 25 | |
| 26 // Prerender tests work as follows: | 26 // Prerender tests work as follows: |
| 27 // | 27 // |
| 28 // A page with a prefetch link to the test page is loaded. Once prerendered, | 28 // A page with a prefetch link to the test page is loaded. Once prerendered, |
| 29 // its Javascript function DidPrerenderPass() is called, which returns true if | 29 // its Javascript function DidPrerenderPass() is called, which returns true if |
| 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 |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 642 | 642 |
| 643 // Checks that prerenderers will terminate when an audio tag is encountered. | 643 // Checks that prerenderers will terminate when an audio tag is encountered. |
| 644 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5Audio) { | 644 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5Audio) { |
| 645 PrerenderTestURL("files/prerender/prerender_html5_audio.html", | 645 PrerenderTestURL("files/prerender/prerender_html5_audio.html", |
| 646 FINAL_STATUS_HTML5_MEDIA, | 646 FINAL_STATUS_HTML5_MEDIA, |
| 647 1); | 647 1); |
| 648 } | 648 } |
| 649 | 649 |
| 650 // Checks that prerenderers will terminate when a video tag is encountered. | 650 // Checks that prerenderers will terminate when a video tag is encountered. |
| 651 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5Video) { | 651 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5Video) { |
| 652 // Disable composited video to avoid FINAL_STATUS_COMPOSITING. | |
| 653 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 654 switches::kDisableAcceleratedVideo); | |
| 652 PrerenderTestURL("files/prerender/prerender_html5_video.html", | 655 PrerenderTestURL("files/prerender/prerender_html5_video.html", |
| 653 FINAL_STATUS_HTML5_MEDIA, | 656 FINAL_STATUS_HTML5_MEDIA, |
| 654 1); | 657 1); |
| 655 } | 658 } |
| 656 | 659 |
| 657 // Checks that prerenderers will terminate when a video tag is inserted via | 660 // Checks that prerenderers will terminate when a video tag is inserted via |
| 658 // javascript. | 661 // javascript. |
| 659 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5VideoJs) { | 662 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5VideoJs) { |
| 663 // Disable composited video to avoid FINAL_STATUS_COMPOSITING. | |
| 664 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 665 switches::kDisableAcceleratedVideo); | |
| 660 PrerenderTestURL("files/prerender/prerender_html5_video_script.html", | 666 PrerenderTestURL("files/prerender/prerender_html5_video_script.html", |
| 661 FINAL_STATUS_HTML5_MEDIA, | 667 FINAL_STATUS_HTML5_MEDIA, |
| 662 1); | 668 1); |
| 663 } | 669 } |
| 664 | 670 |
| 671 // Checks that compositing cancels the prerender. | |
| 672 // | |
| 673 // This test is somewhat flaky on the Linux trybots, and always fails on the | |
| 674 // Windows ones, despite passing locally on all 3 platforms without issue. | |
| 675 // It has been suggested this is because some of the trybots are virtualized, | |
| 676 // so lack hardware rendering support. | |
| 677 // TODO(mmenke): Investigate this. | |
|
cbentzel
2011/04/19 17:42:41
Add a bug for this. Feels pretty bad - even if you
mmenke
2011/04/19 20:00:01
Bug filed. I couldn't find a way to do so, but I'
| |
| 678 #if defined(OS_MACOSX) | |
| 679 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCompositing) { | |
| 680 PrerenderTestURL("files/prerender/prerender_compositing.html", | |
| 681 FINAL_STATUS_COMPOSITING, | |
| 682 1); | |
| 683 } | |
| 684 #endif // !defined(OS_MACOSX) | |
| 685 | |
| 686 // Checks that scripts can retrieve the correct window size while preredering. | |
|
cbentzel
2011/04/19 17:42:41
Nit: s/preredering/prerendering
mmenke
2011/04/19 20:00:01
Done.
| |
| 687 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderWindowSize) { | |
| 688 PrerenderTestURL("files/prerender/prerender_size.html", | |
| 689 FINAL_STATUS_USED, | |
| 690 1); | |
| 691 NavigateToDestURL(); | |
| 692 } | |
| 693 | |
| 665 } // namespace prerender | 694 } // namespace prerender |
| OLD | NEW |