Chromium Code Reviews| 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 <deque> | 5 #include <deque> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/browsing_data_helper.h" | 14 #include "chrome/browser/browsing_data_helper.h" |
| 15 #include "chrome/browser/browsing_data_remover.h" | 15 #include "chrome/browser/browsing_data_remover.h" |
| 16 #include "chrome/browser/content_settings/host_content_settings_map.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 17 #include "chrome/browser/favicon/favicon_tab_helper.h" | 17 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/prerender/prerender_contents.h" | 19 #include "chrome/browser/prerender/prerender_contents.h" |
| 20 #include "chrome/browser/prerender/prerender_handle.h" | |
| 20 #include "chrome/browser/prerender/prerender_link_manager.h" | 21 #include "chrome/browser/prerender/prerender_link_manager.h" |
| 21 #include "chrome/browser/prerender/prerender_link_manager_factory.h" | 22 #include "chrome/browser/prerender/prerender_link_manager_factory.h" |
| 22 #include "chrome/browser/prerender/prerender_manager.h" | 23 #include "chrome/browser/prerender/prerender_manager.h" |
| 23 #include "chrome/browser/prerender/prerender_manager_factory.h" | 24 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 26 #include "chrome/browser/task_manager/task_manager.h" | 27 #include "chrome/browser/task_manager/task_manager.h" |
| 27 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 28 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
| 28 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
| 29 #include "chrome/browser/ui/browser_commands.h" | 30 #include "chrome/browser/ui/browser_commands.h" |
| 30 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
| 31 #include "chrome/browser/ui/browser_tabstrip.h" | 32 #include "chrome/browser/ui/browser_tabstrip.h" |
| 32 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
| 34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 33 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 35 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 34 #include "chrome/common/chrome_notification_types.h" | 36 #include "chrome/common/chrome_notification_types.h" |
| 35 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
| 36 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 37 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 38 #include "chrome/test/base/in_process_browser_test.h" | 40 #include "chrome/test/base/in_process_browser_test.h" |
| 39 #include "chrome/test/base/ui_test_utils.h" | 41 #include "chrome/test/base/ui_test_utils.h" |
| 40 #include "content/public/browser/devtools_agent_host_registry.h" | 42 #include "content/public/browser/devtools_agent_host_registry.h" |
| 41 #include "content/public/browser/devtools_client_host.h" | 43 #include "content/public/browser/devtools_client_host.h" |
| 42 #include "content/public/browser/devtools_manager.h" | 44 #include "content/public/browser/devtools_manager.h" |
| 43 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
| 44 #include "content/public/browser/render_view_host.h" | 46 #include "content/public/browser/render_view_host.h" |
| 45 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
| 46 #include "content/public/common/url_constants.h" | 48 #include "content/public/common/url_constants.h" |
| 49 #include "content/public/test/test_navigation_observer.h" | |
| 47 #include "grit/generated_resources.h" | 50 #include "grit/generated_resources.h" |
| 48 #include "net/base/mock_host_resolver.h" | 51 #include "net/base/mock_host_resolver.h" |
| 49 #include "net/url_request/url_request_context.h" | 52 #include "net/url_request/url_request_context.h" |
| 50 #include "net/url_request/url_request_context_getter.h" | 53 #include "net/url_request/url_request_context_getter.h" |
| 51 #include "ui/base/l10n/l10n_util.h" | 54 #include "ui/base/l10n/l10n_util.h" |
| 52 | 55 |
| 53 using content::BrowserThread; | 56 using content::BrowserThread; |
| 54 using content::DevToolsAgentHost; | 57 using content::DevToolsAgentHost; |
| 55 using content::DevToolsAgentHostRegistry; | 58 using content::DevToolsAgentHostRegistry; |
| 56 using content::DevToolsClientHost; | 59 using content::DevToolsClientHost; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 prerender_manager->CancelAllPrerenders(); | 107 prerender_manager->CancelAllPrerenders(); |
| 105 } | 108 } |
| 106 | 109 |
| 107 // Returns true if and only if the final status is one in which the prerendered | 110 // Returns true if and only if the final status is one in which the prerendered |
| 108 // page should prerender correctly. The page still may not be used. | 111 // page should prerender correctly. The page still may not be used. |
| 109 bool ShouldRenderPrerenderedPageCorrectly(FinalStatus status) { | 112 bool ShouldRenderPrerenderedPageCorrectly(FinalStatus status) { |
| 110 switch (status) { | 113 switch (status) { |
| 111 case FINAL_STATUS_USED: | 114 case FINAL_STATUS_USED: |
| 112 case FINAL_STATUS_WINDOW_OPENER: | 115 case FINAL_STATUS_WINDOW_OPENER: |
| 113 case FINAL_STATUS_APP_TERMINATING: | 116 case FINAL_STATUS_APP_TERMINATING: |
| 114 case FINAL_STATUS_FRAGMENT_MISMATCH: | |
| 115 case FINAL_STATUS_CACHE_OR_HISTORY_CLEARED: | 117 case FINAL_STATUS_CACHE_OR_HISTORY_CLEARED: |
| 116 // We'll crash the renderer after it's loaded. | 118 // We'll crash the renderer after it's loaded. |
| 117 case FINAL_STATUS_RENDERER_CRASHED: | 119 case FINAL_STATUS_RENDERER_CRASHED: |
| 118 case FINAL_STATUS_CANCELLED: | 120 case FINAL_STATUS_CANCELLED: |
| 119 case FINAL_STATUS_DEVTOOLS_ATTACHED: | 121 case FINAL_STATUS_DEVTOOLS_ATTACHED: |
| 120 case FINAL_STATUS_SESSION_STORAGE_NAMESPACE_MISMATCH: | |
| 121 return true; | 122 return true; |
| 122 default: | 123 default: |
| 123 return false; | 124 return false; |
| 124 } | 125 } |
| 125 } | 126 } |
| 126 | 127 |
| 127 // PrerenderContents that stops the UI message loop on DidStopLoading(). | 128 // PrerenderContents that stops the UI message loop on DidStopLoading(). |
| 128 class TestPrerenderContents : public PrerenderContents { | 129 class TestPrerenderContents : public PrerenderContents { |
| 129 public: | 130 public: |
| 130 TestPrerenderContents( | 131 TestPrerenderContents( |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 | 221 |
| 221 virtual void DidStopLoading() OVERRIDE { | 222 virtual void DidStopLoading() OVERRIDE { |
| 222 PrerenderContents::DidStopLoading(); | 223 PrerenderContents::DidStopLoading(); |
| 223 ++number_of_loads_; | 224 ++number_of_loads_; |
| 224 if (ShouldRenderPrerenderedPageCorrectly(expected_final_status_) && | 225 if (ShouldRenderPrerenderedPageCorrectly(expected_final_status_) && |
| 225 number_of_loads_ == expected_number_of_loads_) { | 226 number_of_loads_ == expected_number_of_loads_) { |
| 226 MessageLoopForUI::current()->Quit(); | 227 MessageLoopForUI::current()->Quit(); |
| 227 } | 228 } |
| 228 } | 229 } |
| 229 | 230 |
| 230 virtual void AddPendingPrerender(const GURL& url, | 231 virtual void AddPendingPrerender( |
| 231 const content::Referrer& referrer, | 232 base::WeakPtr<PrerenderHandle> weak_prerender_handle, |
| 232 const gfx::Size& size) OVERRIDE { | 233 const GURL& url, |
| 233 PrerenderContents::AddPendingPrerender(url, referrer, size); | 234 const content::Referrer& referrer, |
| 235 const gfx::Size& size) OVERRIDE { | |
| 236 PrerenderContents::AddPendingPrerender( | |
| 237 weak_prerender_handle, url, referrer, size); | |
| 234 if (expected_pending_prerenders_ > 0 && | 238 if (expected_pending_prerenders_ > 0 && |
| 235 pending_prerender_list()->size() == expected_pending_prerenders_) { | 239 pending_prerenders().size() == expected_pending_prerenders_) { |
| 236 MessageLoop::current()->Quit(); | 240 MessageLoop::current()->Quit(); |
| 237 } | 241 } |
| 238 } | 242 } |
| 239 | 243 |
| 240 virtual WebContents* CreateWebContents( | 244 virtual WebContents* CreateWebContents( |
| 241 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE { | 245 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE { |
| 242 WebContents* web_contents = PrerenderContents::CreateWebContents( | 246 WebContents* web_contents = PrerenderContents::CreateWebContents( |
| 243 session_storage_namespace); | 247 session_storage_namespace); |
| 244 string16 ready_title = ASCIIToUTF16(kReadyTitle); | 248 string16 ready_title = ASCIIToUTF16(kReadyTitle); |
| 245 if (prerender_should_wait_for_ready_title_) | 249 if (prerender_should_wait_for_ready_title_) |
| 246 ready_title_watcher_.reset(new ui_test_utils::TitleWatcher( | 250 ready_title_watcher_.reset(new ui_test_utils::TitleWatcher( |
| 247 web_contents, ready_title)); | 251 web_contents, ready_title)); |
| 248 return web_contents; | 252 return web_contents; |
| 249 } | 253 } |
| 250 | 254 |
| 251 void WaitForPrerenderToHaveReadyTitleIfRequired() { | 255 void WaitForPrerenderToHaveReadyTitleIfRequired() { |
| 252 if (ready_title_watcher_.get()) { | 256 if (ready_title_watcher_.get()) { |
| 253 string16 ready_title = ASCIIToUTF16(kReadyTitle); | 257 string16 ready_title = ASCIIToUTF16(kReadyTitle); |
| 254 ASSERT_EQ(ready_title, ready_title_watcher_->WaitAndGetTitle()); | 258 ASSERT_EQ(ready_title, ready_title_watcher_->WaitAndGetTitle()); |
| 255 } | 259 } |
| 256 } | 260 } |
| 257 | 261 |
| 258 // Waits until the prerender has |expected_pending_prerenders| pending | 262 // Waits until the prerender has |expected_pending_prerenders| pending |
| 259 // prerenders. | 263 // prerenders. |
| 260 void WaitForPendingPrerenders(size_t expected_pending_prerenders) { | 264 void WaitForPendingPrerenders(size_t expected_pending_prerenders) { |
| 261 if (pending_prerender_list()->size() < expected_pending_prerenders) { | 265 if (pending_prerenders().size() < expected_pending_prerenders) { |
| 262 expected_pending_prerenders_ = expected_pending_prerenders; | 266 expected_pending_prerenders_ = expected_pending_prerenders; |
| 263 ui_test_utils::RunMessageLoop(); | 267 ui_test_utils::RunMessageLoop(); |
| 264 expected_pending_prerenders_ = 0; | 268 expected_pending_prerenders_ = 0; |
| 265 } | 269 } |
| 266 | 270 |
| 267 EXPECT_EQ(expected_pending_prerenders, pending_prerender_list()->size()); | 271 EXPECT_EQ(expected_pending_prerenders, pending_prerenders().size()); |
| 272 } | |
| 273 | |
| 274 bool UrlIsPending(const GURL& url) const { | |
| 275 for (std::vector<PendingPrerenderInfo>::const_iterator | |
| 276 it = pending_prerenders().begin(), | |
| 277 end = pending_prerenders().end(); | |
| 278 it != end; | |
| 279 ++it) { | |
| 280 if (it->url == url && it->weak_prerender_handle) { | |
| 281 EXPECT_TRUE(IsPendingEntry(*it->weak_prerender_handle)); | |
| 282 EXPECT_TRUE(it->weak_prerender_handle->IsPending()); | |
| 283 return true; | |
| 284 } | |
| 285 } | |
| 286 return false; | |
| 268 } | 287 } |
| 269 | 288 |
| 270 // For tests that open the prerender in a new background tab, the RenderView | 289 // For tests that open the prerender in a new background tab, the RenderView |
| 271 // will not have been made visible when the PrerenderContents is destroyed | 290 // will not have been made visible when the PrerenderContents is destroyed |
| 272 // even though it is used. | 291 // even though it is used. |
| 273 void set_should_be_shown(bool value) { should_be_shown_ = value; } | 292 void set_should_be_shown(bool value) { should_be_shown_ = value; } |
| 274 | 293 |
| 275 int number_of_loads() const { return number_of_loads_; } | 294 int number_of_loads() const { return number_of_loads_; } |
| 276 | 295 |
| 296 FinalStatus expected_final_status() const { return expected_final_status_; } | |
| 297 | |
| 298 bool WillQuitMessageLoopOnDestruction() const { | |
|
mmenke
2012/07/13 14:49:10
nit: quit_message_loop_on_destruction()
gavinp
2012/07/13 16:42:43
Done, though I avoided that as I felt the Will hel
| |
| 299 return quit_message_loop_on_destruction_; | |
| 300 } | |
| 301 | |
| 277 private: | 302 private: |
| 278 virtual void OnRenderViewHostCreated( | 303 virtual void OnRenderViewHostCreated( |
| 279 RenderViewHost* new_render_view_host) OVERRIDE { | 304 RenderViewHost* new_render_view_host) OVERRIDE { |
| 280 // Used to make sure the RenderViewHost is hidden and, if used, | 305 // Used to make sure the RenderViewHost is hidden and, if used, |
| 281 // subsequently shown. | 306 // subsequently shown. |
| 282 notification_registrar().Add( | 307 notification_registrar().Add( |
| 283 this, | 308 this, |
| 284 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, | 309 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, |
| 285 content::Source<RenderWidgetHost>(new_render_view_host)); | 310 content::Source<RenderWidgetHost>(new_render_view_host)); |
| 286 | 311 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 #endif | 508 #endif |
| 484 use_https_src_server_(false), | 509 use_https_src_server_(false), |
| 485 call_javascript_(true), | 510 call_javascript_(true), |
| 486 loader_path_("files/prerender/prerender_loader.html"), | 511 loader_path_("files/prerender/prerender_loader.html"), |
| 487 explicitly_set_browser_(NULL) { | 512 explicitly_set_browser_(NULL) { |
| 488 EnableDOMAutomation(); | 513 EnableDOMAutomation(); |
| 489 } | 514 } |
| 490 | 515 |
| 491 virtual ~PrerenderBrowserTest() {} | 516 virtual ~PrerenderBrowserTest() {} |
| 492 | 517 |
| 518 content::SessionStorageNamespace* GetSessionStorageNamespace() const { | |
| 519 TabContents* tab_contents = | |
| 520 current_browser()->tab_strip_model()->GetActiveTabContents(); | |
| 521 if (!tab_contents) | |
| 522 return NULL; | |
| 523 return tab_contents->web_contents()->GetRenderViewHost()-> | |
| 524 GetSessionStorageNamespace(); | |
| 525 } | |
| 526 | |
| 493 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 527 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 494 #if defined(ENABLE_SAFE_BROWSING) | 528 #if defined(ENABLE_SAFE_BROWSING) |
| 495 SafeBrowsingService::RegisterFactory(safe_browsing_factory_.get()); | 529 SafeBrowsingService::RegisterFactory(safe_browsing_factory_.get()); |
| 496 #endif | 530 #endif |
| 497 } | 531 } |
| 498 | 532 |
| 499 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 533 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 500 command_line->AppendSwitchASCII(switches::kPrerenderMode, | 534 command_line->AppendSwitchASCII(switches::kPrerenderMode, |
| 501 switches::kPrerenderModeSwitchValueEnabled); | 535 switches::kPrerenderModeSwitchValueEnabled); |
| 502 #if defined(OS_MACOSX) | 536 #if defined(OS_MACOSX) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 &js_result)); | 730 &js_result)); |
| 697 EXPECT_TRUE(js_result); | 731 EXPECT_TRUE(js_result); |
| 698 } | 732 } |
| 699 | 733 |
| 700 void NavigateToURL(const std::string& dest_html_file) const { | 734 void NavigateToURL(const std::string& dest_html_file) const { |
| 701 GURL dest_url = test_server()->GetURL(dest_html_file); | 735 GURL dest_url = test_server()->GetURL(dest_html_file); |
| 702 NavigateToURLImpl(dest_url, CURRENT_TAB); | 736 NavigateToURLImpl(dest_url, CURRENT_TAB); |
| 703 } | 737 } |
| 704 | 738 |
| 705 bool UrlIsInPrerenderManager(const std::string& html_file) const { | 739 bool UrlIsInPrerenderManager(const std::string& html_file) const { |
| 706 GURL dest_url = test_server()->GetURL(html_file); | 740 return UrlIsInPrerenderManager(test_server()->GetURL(html_file)); |
| 707 return (GetPrerenderManager()->FindEntry(dest_url) != NULL); | |
| 708 } | 741 } |
| 709 | 742 |
| 710 bool UrlIsInPrerenderManager(const GURL& url) { | 743 bool UrlIsInPrerenderManager(const GURL& url) const { |
| 711 return (GetPrerenderManager()->FindEntry(url) != NULL); | 744 return GetPrerenderManager()->FindPrerenderData( |
| 745 url, GetSessionStorageNamespace()) != NULL; | |
| 712 } | 746 } |
| 713 | 747 |
| 714 bool UrlIsPendingInPrerenderManager(const std::string& html_file) const { | 748 // This only checks to see if the URL is pending in our TestPrerenderContents. |
| 749 bool UrlIsPending(const std::string& html_file) const { | |
| 750 TestPrerenderContents* test_prerender_contents = GetPrerenderContents(); | |
| 751 if (!test_prerender_contents) | |
| 752 return false; | |
| 715 GURL dest_url = test_server()->GetURL(html_file); | 753 GURL dest_url = test_server()->GetURL(html_file); |
| 716 return GetPrerenderManager()->IsPendingEntry(dest_url); | 754 return test_prerender_contents->UrlIsPending(dest_url); |
| 717 } | 755 } |
| 718 | 756 |
| 719 void set_use_https_src(bool use_https_src_server) { | 757 void set_use_https_src(bool use_https_src_server) { |
| 720 use_https_src_server_ = use_https_src_server; | 758 use_https_src_server_ = use_https_src_server; |
| 721 } | 759 } |
| 722 | 760 |
| 723 void DisableJavascriptCalls() { | 761 void DisableJavascriptCalls() { |
| 724 call_javascript_ = false; | 762 call_javascript_ = false; |
| 725 } | 763 } |
| 726 | 764 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 757 return static_cast<int>(history_list->GetSize()); | 795 return static_cast<int>(history_list->GetSize()); |
| 758 } | 796 } |
| 759 | 797 |
| 760 #if defined(ENABLE_SAFE_BROWSING) | 798 #if defined(ENABLE_SAFE_BROWSING) |
| 761 FakeSafeBrowsingService* GetSafeBrowsingService() { | 799 FakeSafeBrowsingService* GetSafeBrowsingService() { |
| 762 return safe_browsing_factory_->most_recent_service(); | 800 return safe_browsing_factory_->most_recent_service(); |
| 763 } | 801 } |
| 764 #endif | 802 #endif |
| 765 | 803 |
| 766 TestPrerenderContents* GetPrerenderContents() const { | 804 TestPrerenderContents* GetPrerenderContents() const { |
| 805 PrerenderManager::PrerenderData* prerender_data = | |
| 806 GetPrerenderManager()->FindPrerenderData( | |
| 807 dest_url_, GetSessionStorageNamespace()); | |
| 767 return static_cast<TestPrerenderContents*>( | 808 return static_cast<TestPrerenderContents*>( |
| 768 GetPrerenderManager()->FindEntry(dest_url_)); | 809 prerender_data ? prerender_data->contents() : NULL); |
| 769 } | 810 } |
| 770 | 811 |
| 771 void set_loader_path(const std::string& path) { | 812 void set_loader_path(const std::string& path) { |
| 772 loader_path_ = path; | 813 loader_path_ = path; |
| 773 } | 814 } |
| 774 | 815 |
| 775 void set_loader_query_and_fragment(const std::string& query_and_fragment) { | 816 void set_loader_query_and_fragment(const std::string& query_and_fragment) { |
| 776 loader_query_and_fragment_ = query_and_fragment; | 817 loader_query_and_fragment_ = query_and_fragment; |
| 777 } | 818 } |
| 778 | 819 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 843 ASSERT_TRUE(prerender_contents_factory_ == NULL); | 884 ASSERT_TRUE(prerender_contents_factory_ == NULL); |
| 844 prerender_contents_factory_ = | 885 prerender_contents_factory_ = |
| 845 new WaitForLoadPrerenderContentsFactory( | 886 new WaitForLoadPrerenderContentsFactory( |
| 846 expected_number_of_loads, | 887 expected_number_of_loads, |
| 847 expected_final_status_queue, | 888 expected_final_status_queue, |
| 848 prerender_should_wait_for_ready_title); | 889 prerender_should_wait_for_ready_title); |
| 849 prerender_manager->SetPrerenderContentsFactory( | 890 prerender_manager->SetPrerenderContentsFactory( |
| 850 prerender_contents_factory_); | 891 prerender_contents_factory_); |
| 851 FinalStatus expected_final_status = expected_final_status_queue.front(); | 892 FinalStatus expected_final_status = expected_final_status_queue.front(); |
| 852 | 893 |
| 894 // We construct this launch_nav_observer so that we can be certain our | |
|
mmenke
2012/07/13 14:49:10
nit: "this WindowedNotificationObserver" or "laun
gavinp
2012/07/13 16:42:43
Done.
| |
| 895 // loader page has finished loading before continuing. This prevents | |
| 896 // ambiguous NOTIFICATION_LOAD_STOP events from making tests flaky. | |
| 897 WebContents* web_contents = chrome::GetActiveWebContents(current_browser()); | |
| 898 ui_test_utils::WindowedNotificationObserver loader_nav_observer( | |
| 899 content::NOTIFICATION_LOAD_STOP, | |
| 900 content::Source<NavigationController>( | |
| 901 &web_contents->GetController())); | |
| 902 | |
| 853 // ui_test_utils::NavigateToURL uses its own observer and message loop. | 903 // ui_test_utils::NavigateToURL uses its own observer and message loop. |
| 854 // Since the test needs to wait until the prerendered page has stopped | 904 // Since the test needs to wait until the prerendered page has stopped |
| 855 // loading, rather than the page directly navigated to, need to | 905 // loading, rather than the page directly navigated to, need to |
| 856 // handle browser navigation directly. | 906 // handle browser navigation directly. |
| 857 current_browser()->OpenURL(OpenURLParams( | 907 current_browser()->OpenURL(OpenURLParams( |
| 858 loader_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, | 908 loader_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, |
| 859 false)); | 909 false)); |
| 860 | 910 |
| 861 ui_test_utils::RunMessageLoop(); | 911 ui_test_utils::RunMessageLoop(); |
| 912 loader_nav_observer.Wait(); | |
|
mmenke
2012/07/13 14:49:10
Suggest a comment that this must be after the ui_t
gavinp
2012/07/13 16:42:43
Added. But is that really true? The prerender is o
mmenke
2012/07/13 17:01:29
The problem isn't that we could get its message, i
| |
| 862 | 913 |
| 863 TestPrerenderContents* prerender_contents = GetPrerenderContents(); | 914 TestPrerenderContents* prerender_contents = GetPrerenderContents(); |
| 864 | 915 |
| 865 if (ShouldRenderPrerenderedPageCorrectly(expected_final_status)) { | 916 if (ShouldRenderPrerenderedPageCorrectly(expected_final_status)) { |
| 866 ASSERT_TRUE(prerender_contents != NULL); | 917 ASSERT_TRUE(prerender_contents != NULL); |
| 867 EXPECT_EQ(FINAL_STATUS_MAX, prerender_contents->final_status()); | 918 EXPECT_EQ(FINAL_STATUS_MAX, prerender_contents->final_status()); |
| 868 | 919 |
| 869 if (call_javascript_ && expected_number_of_loads > 0) { | 920 if (call_javascript_ && expected_number_of_loads > 0) { |
| 870 // Wait for the prerendered page to change title to signal it is ready | 921 // Wait for the prerendered page to change title to signal it is ready |
| 871 // if required. | 922 // if required. |
| 872 prerender_contents->WaitForPrerenderToHaveReadyTitleIfRequired(); | 923 prerender_contents->WaitForPrerenderToHaveReadyTitleIfRequired(); |
| 873 | 924 |
| 874 // Check if page behaves as expected while in prerendered state. | 925 // Check if page behaves as expected while in prerendered state. |
| 875 bool prerender_test_result = false; | 926 bool prerender_test_result = false; |
| 876 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 927 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 877 prerender_contents->GetRenderViewHostMutable(), L"", | 928 prerender_contents->GetRenderViewHostMutable(), L"", |
| 878 L"window.domAutomationController.send(DidPrerenderPass())", | 929 L"window.domAutomationController.send(DidPrerenderPass())", |
| 879 &prerender_test_result)); | 930 &prerender_test_result)); |
| 880 EXPECT_TRUE(prerender_test_result); | 931 EXPECT_TRUE(prerender_test_result); |
| 881 } | 932 } |
| 882 } else { | 933 } else { |
| 883 // In the failure case, we should have removed |dest_url_| from the | 934 // In the failure case, we should have removed |dest_url_| from the |
| 884 // prerender_manager. We ignore dummy PrerenderContents (as indicated | 935 // prerender_manager. We ignore dummy PrerenderContents (as indicated |
| 885 // by not having started). | 936 // by not having started), and PrerenderContents that are expected to |
| 937 // be left in the manager until the test finishes. | |
| 886 EXPECT_TRUE(prerender_contents == NULL || | 938 EXPECT_TRUE(prerender_contents == NULL || |
| 887 !prerender_contents->prerendering_has_started()); | 939 !prerender_contents->prerendering_has_started()); |
| 888 } | 940 } |
| 889 } | 941 } |
| 890 | 942 |
| 891 void NavigateToURLImpl(const GURL& dest_url, | 943 void NavigateToURLImpl(const GURL& dest_url, |
| 892 WindowOpenDisposition disposition) const { | 944 WindowOpenDisposition disposition) const { |
| 893 ASSERT_TRUE(GetPrerenderManager() != NULL); | 945 ASSERT_TRUE(GetPrerenderManager() != NULL); |
| 894 // Make sure in navigating we have a URL to use in the PrerenderManager. | 946 // Make sure in navigating we have a URL to use in the PrerenderManager. |
| 895 ASSERT_TRUE(GetPrerenderContents() != NULL); | 947 ASSERT_TRUE(GetPrerenderContents() != NULL); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 942 // Opens the prerendered page using javascript functions in the | 994 // Opens the prerendered page using javascript functions in the |
| 943 // loader page. |javascript_function_name| should be a 0 argument function | 995 // loader page. |javascript_function_name| should be a 0 argument function |
| 944 // which is invoked. | 996 // which is invoked. |
| 945 void OpenDestURLWithJSImpl(const std::string& javascript_function_name) | 997 void OpenDestURLWithJSImpl(const std::string& javascript_function_name) |
| 946 const { | 998 const { |
| 947 TestPrerenderContents* prerender_contents = GetPrerenderContents(); | 999 TestPrerenderContents* prerender_contents = GetPrerenderContents(); |
| 948 ASSERT_TRUE(prerender_contents != NULL); | 1000 ASSERT_TRUE(prerender_contents != NULL); |
| 949 | 1001 |
| 950 RenderViewHost* render_view_host = | 1002 RenderViewHost* render_view_host = |
| 951 chrome::GetActiveWebContents(current_browser())->GetRenderViewHost(); | 1003 chrome::GetActiveWebContents(current_browser())->GetRenderViewHost(); |
| 952 render_view_host->ExecuteJavascriptInWebFrame( | |
| 953 string16(), | |
| 954 ASCIIToUTF16(javascript_function_name)); | |
| 955 | 1004 |
| 956 // Run message loop until the prerender contents is destroyed. | 1005 if (prerender_contents->WillQuitMessageLoopOnDestruction()) { |
| 957 ui_test_utils::RunMessageLoop(); | 1006 render_view_host->ExecuteJavascriptInWebFrame( |
| 1007 string16(), ASCIIToUTF16(javascript_function_name)); | |
| 1008 // Run message loop until the prerender contents is destroyed. | |
| 1009 ui_test_utils::RunMessageLoop(); | |
| 1010 } else { | |
| 1011 // We don't expect to pick up a running prerender, so instead | |
| 1012 // observe one navigation. | |
| 1013 content::TestNavigationObserver observer( | |
| 1014 content::NotificationService::AllSources(), NULL, 1); | |
| 1015 render_view_host->ExecuteJavascriptInWebFrame( | |
| 1016 string16(), ASCIIToUTF16(javascript_function_name)); | |
|
mmenke
2012/07/13 14:49:10
nit: I was wrong about creating the observer firs
gavinp
2012/07/13 16:42:43
Done.
| |
| 1017 base::RunLoop run_loop; | |
| 1018 observer.WaitForObservation( | |
| 1019 base::Bind(&ui_test_utils::RunThisRunLoop, | |
| 1020 base::Unretained(&run_loop)), | |
| 1021 ui_test_utils::GetQuitTaskForRunLoop(&run_loop)); | |
| 1022 } | |
| 958 } | 1023 } |
| 959 | 1024 |
| 960 WaitForLoadPrerenderContentsFactory* prerender_contents_factory_; | 1025 WaitForLoadPrerenderContentsFactory* prerender_contents_factory_; |
| 961 #if defined(ENABLE_SAFE_BROWSING) | 1026 #if defined(ENABLE_SAFE_BROWSING) |
| 962 scoped_ptr<TestSafeBrowsingServiceFactory> safe_browsing_factory_; | 1027 scoped_ptr<TestSafeBrowsingServiceFactory> safe_browsing_factory_; |
| 963 #endif | 1028 #endif |
| 964 GURL dest_url_; | 1029 GURL dest_url_; |
| 965 bool use_https_src_server_; | 1030 bool use_https_src_server_; |
| 966 bool call_javascript_; | 1031 bool call_javascript_; |
| 967 std::string loader_path_; | 1032 std::string loader_path_; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1430 std::deque<FinalStatus> expected_final_status_queue; | 1495 std::deque<FinalStatus> expected_final_status_queue; |
| 1431 expected_final_status_queue.push_back(FINAL_STATUS_USED); | 1496 expected_final_status_queue.push_back(FINAL_STATUS_USED); |
| 1432 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); | 1497 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); |
| 1433 | 1498 |
| 1434 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); | 1499 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); |
| 1435 ASSERT_TRUE(GetPrerenderContents()); | 1500 ASSERT_TRUE(GetPrerenderContents()); |
| 1436 GetPrerenderContents()->WaitForPendingPrerenders(1u); | 1501 GetPrerenderContents()->WaitForPendingPrerenders(1u); |
| 1437 | 1502 |
| 1438 // Next url should be in pending list but not an active entry. | 1503 // Next url should be in pending list but not an active entry. |
| 1439 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); | 1504 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); |
| 1440 EXPECT_TRUE(UrlIsPendingInPrerenderManager(kHtmlFileB)); | 1505 EXPECT_TRUE(UrlIsPending(kHtmlFileB)); |
| 1441 | 1506 |
| 1442 NavigateToDestURL(); | 1507 NavigateToDestURL(); |
| 1443 | 1508 |
| 1444 // Make sure the PrerenderContents for the next url is now in the manager | 1509 // Make sure the PrerenderContents for the next url is now in the manager |
| 1445 // and not pending. | 1510 // and not pending. |
| 1446 EXPECT_TRUE(UrlIsInPrerenderManager(kHtmlFileB)); | 1511 EXPECT_TRUE(UrlIsInPrerenderManager(kHtmlFileB)); |
| 1447 EXPECT_FALSE(UrlIsPendingInPrerenderManager(kHtmlFileB)); | 1512 EXPECT_FALSE(UrlIsPending(kHtmlFileB)); |
| 1448 } | 1513 } |
| 1449 | 1514 |
| 1450 // Checks that we don't prerender in an infinite loop and multiple links are | 1515 // Checks that we don't prerender in an infinite loop and multiple links are |
| 1451 // handled correctly. | 1516 // handled correctly. |
| 1452 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderInfiniteLoopMultiple) { | 1517 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderInfiniteLoopMultiple) { |
| 1453 const char* const kHtmlFileA = | 1518 const char* const kHtmlFileA = |
| 1454 "files/prerender/prerender_infinite_a_multiple.html"; | 1519 "files/prerender/prerender_infinite_a_multiple.html"; |
| 1455 const char* const kHtmlFileB = | 1520 const char* const kHtmlFileB = |
| 1456 "files/prerender/prerender_infinite_b_multiple.html"; | 1521 "files/prerender/prerender_infinite_b_multiple.html"; |
| 1457 const char* const kHtmlFileC = | 1522 const char* const kHtmlFileC = |
| 1458 "files/prerender/prerender_infinite_c_multiple.html"; | 1523 "files/prerender/prerender_infinite_c_multiple.html"; |
| 1459 | 1524 |
| 1460 // We need to set the final status to expect here before starting any | 1525 // We need to set the final status to expect here before starting any |
| 1461 // prerenders. We set them on a queue so whichever we see first is expected to | 1526 // prerenders. We set them on a queue so whichever we see first is expected to |
| 1462 // be evicted, and the second should stick around until we exit. | 1527 // be evicted, and the second should stick around until we exit. |
| 1463 std::deque<FinalStatus> expected_final_status_queue; | 1528 std::deque<FinalStatus> expected_final_status_queue; |
| 1464 expected_final_status_queue.push_back(FINAL_STATUS_USED); | 1529 expected_final_status_queue.push_back(FINAL_STATUS_USED); |
| 1465 expected_final_status_queue.push_back(FINAL_STATUS_EVICTED); | 1530 expected_final_status_queue.push_back(FINAL_STATUS_EVICTED); |
| 1466 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); | 1531 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); |
| 1467 | 1532 |
| 1468 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); | 1533 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); |
| 1469 ASSERT_TRUE(GetPrerenderContents()); | 1534 ASSERT_TRUE(GetPrerenderContents()); |
| 1470 GetPrerenderContents()->WaitForPendingPrerenders(2u); | 1535 GetPrerenderContents()->WaitForPendingPrerenders(2u); |
| 1471 | 1536 |
| 1472 // Next url should be in pending list but not an active entry. | 1537 // Next url should be in pending list but not an active entry. |
| 1473 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); | 1538 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); |
| 1474 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileC)); | 1539 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileC)); |
| 1475 EXPECT_TRUE(UrlIsPendingInPrerenderManager(kHtmlFileB)); | 1540 EXPECT_TRUE(UrlIsPending(kHtmlFileB)); |
| 1476 EXPECT_TRUE(UrlIsPendingInPrerenderManager(kHtmlFileC)); | 1541 EXPECT_TRUE(UrlIsPending(kHtmlFileC)); |
| 1477 | 1542 |
| 1478 NavigateToDestURL(); | 1543 NavigateToDestURL(); |
| 1479 | 1544 |
| 1480 // Make sure the PrerenderContents for the next urls are now in the manager | 1545 // Make sure the PrerenderContents for the next urls are now in the manager |
| 1481 // and not pending. One and only one of the URLs (the last seen) should be the | 1546 // and not pending. One and only one of the URLs (the last seen) should be the |
| 1482 // active entry. | 1547 // active entry. |
| 1483 bool url_b_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileB); | 1548 bool url_b_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileB); |
| 1484 bool url_c_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileC); | 1549 bool url_c_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileC); |
| 1485 EXPECT_TRUE((url_b_is_active_prerender || url_c_is_active_prerender) && | 1550 EXPECT_TRUE((url_b_is_active_prerender || url_c_is_active_prerender) && |
| 1486 !(url_b_is_active_prerender && url_c_is_active_prerender)); | 1551 !(url_b_is_active_prerender && url_c_is_active_prerender)); |
| 1487 EXPECT_FALSE(UrlIsPendingInPrerenderManager(kHtmlFileB)); | 1552 EXPECT_FALSE(UrlIsPending(kHtmlFileB)); |
| 1488 EXPECT_FALSE(UrlIsPendingInPrerenderManager(kHtmlFileC)); | 1553 EXPECT_FALSE(UrlIsPending(kHtmlFileC)); |
| 1489 } | 1554 } |
| 1490 | 1555 |
| 1491 // See crbug.com/131836. | 1556 // See crbug.com/131836. |
| 1492 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderTaskManager) { | 1557 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderTaskManager) { |
| 1493 // Show the task manager. This populates the model. | 1558 // Show the task manager. This populates the model. |
| 1494 current_browser()->window()->ShowTaskManager(); | 1559 current_browser()->window()->ShowTaskManager(); |
| 1495 // Wait for the model of task manager to start. | 1560 // Wait for the model of task manager to start. |
| 1496 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 1561 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
| 1497 | 1562 |
| 1498 // Start with two resources. | 1563 // Start with two resources. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1631 std::string()); | 1696 std::string()); |
| 1632 ui_test_utils::RunMessageLoop(); | 1697 ui_test_utils::RunMessageLoop(); |
| 1633 } | 1698 } |
| 1634 | 1699 |
| 1635 // Checks that we correctly use a prerendered page when navigating to a | 1700 // Checks that we correctly use a prerendered page when navigating to a |
| 1636 // fragment. | 1701 // fragment. |
| 1637 // DISABLED: http://crbug.com/84154 | 1702 // DISABLED: http://crbug.com/84154 |
| 1638 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1703 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 1639 DISABLED_PrerenderPageNavigateFragment) { | 1704 DISABLED_PrerenderPageNavigateFragment) { |
| 1640 PrerenderTestURL("files/prerender/prerender_fragment.html", | 1705 PrerenderTestURL("files/prerender/prerender_fragment.html", |
| 1641 FINAL_STATUS_FRAGMENT_MISMATCH, | 1706 FINAL_STATUS_APP_TERMINATING, |
| 1642 1); | 1707 1); |
| 1643 NavigateToURL("files/prerender/prerender_fragment.html#fragment"); | 1708 NavigateToURL("files/prerender/prerender_fragment.html#fragment"); |
| 1644 } | 1709 } |
| 1645 | 1710 |
| 1646 // Checks that we correctly use a prerendered page when we prerender a fragment | 1711 // Checks that we correctly use a prerendered page when we prerender a fragment |
| 1647 // but navigate to the main page. | 1712 // but navigate to the main page. |
| 1648 // http://crbug.com/83901 | 1713 // http://crbug.com/83901 |
| 1649 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1714 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 1650 DISABLED_PrerenderFragmentNavigatePage) { | 1715 DISABLED_PrerenderFragmentNavigatePage) { |
| 1651 PrerenderTestURL("files/prerender/prerender_fragment.html#fragment", | 1716 PrerenderTestURL("files/prerender/prerender_fragment.html#fragment", |
| 1652 FINAL_STATUS_FRAGMENT_MISMATCH, | 1717 FINAL_STATUS_APP_TERMINATING, |
| 1653 1); | 1718 1); |
| 1654 NavigateToURL("files/prerender/prerender_fragment.html"); | 1719 NavigateToURL("files/prerender/prerender_fragment.html"); |
| 1655 } | 1720 } |
| 1656 | 1721 |
| 1657 // Checks that we correctly use a prerendered page when we prerender a fragment | 1722 // Checks that we correctly use a prerendered page when we prerender a fragment |
| 1658 // but navigate to a different fragment on the same page. | 1723 // but navigate to a different fragment on the same page. |
| 1659 // DISABLED: http://crbug.com/84154 | 1724 // DISABLED: http://crbug.com/84154 |
| 1660 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1725 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 1661 DISABLED_PrerenderFragmentNavigateFragment) { | 1726 DISABLED_PrerenderFragmentNavigateFragment) { |
| 1662 PrerenderTestURL("files/prerender/prerender_fragment.html#other_fragment", | 1727 PrerenderTestURL("files/prerender/prerender_fragment.html#other_fragment", |
| 1663 FINAL_STATUS_FRAGMENT_MISMATCH, | 1728 FINAL_STATUS_APP_TERMINATING, |
| 1664 1); | 1729 1); |
| 1665 NavigateToURL("files/prerender/prerender_fragment.html#fragment"); | 1730 NavigateToURL("files/prerender/prerender_fragment.html#fragment"); |
| 1666 } | 1731 } |
| 1667 | 1732 |
| 1668 // Checks that we correctly use a prerendered page when the page uses a client | 1733 // Checks that we correctly use a prerendered page when the page uses a client |
| 1669 // redirect to refresh from a fragment on the same page. | 1734 // redirect to refresh from a fragment on the same page. |
| 1670 // http://crbug.com/83901 | 1735 // http://crbug.com/83901 |
| 1671 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1736 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 1672 DISABLED_PrerenderClientRedirectFromFragment) { | 1737 DISABLED_PrerenderClientRedirectFromFragment) { |
| 1673 PrerenderTestURL( | 1738 PrerenderTestURL( |
| 1674 CreateClientRedirect("files/prerender/prerender_fragment.html#fragment"), | 1739 CreateClientRedirect("files/prerender/prerender_fragment.html#fragment"), |
| 1675 FINAL_STATUS_FRAGMENT_MISMATCH, | 1740 FINAL_STATUS_APP_TERMINATING, |
| 1676 2); | 1741 2); |
| 1677 NavigateToURL("files/prerender/prerender_fragment.html"); | 1742 NavigateToURL("files/prerender/prerender_fragment.html"); |
| 1678 } | 1743 } |
| 1679 | 1744 |
| 1680 // Checks that we correctly use a prerendered page when the page uses a client | 1745 // Checks that we correctly use a prerendered page when the page uses a client |
| 1681 // redirect to refresh to a fragment on the same page. | 1746 // redirect to refresh to a fragment on the same page. |
| 1682 // DISABLED: http://crbug.com/84154 | 1747 // DISABLED: http://crbug.com/84154 |
| 1683 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1748 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 1684 DISABLED_PrerenderClientRedirectToFragment) { | 1749 DISABLED_PrerenderClientRedirectToFragment) { |
| 1685 PrerenderTestURL( | 1750 PrerenderTestURL( |
| 1686 CreateClientRedirect("files/prerender/prerender_fragment.html"), | 1751 CreateClientRedirect("files/prerender/prerender_fragment.html"), |
| 1687 FINAL_STATUS_FRAGMENT_MISMATCH, | 1752 FINAL_STATUS_APP_TERMINATING, |
| 1688 2); | 1753 2); |
| 1689 NavigateToURL("files/prerender/prerender_fragment.html#fragment"); | 1754 NavigateToURL("files/prerender/prerender_fragment.html#fragment"); |
| 1690 } | 1755 } |
| 1691 | 1756 |
| 1692 // Checks that we correctly use a prerendered page when the page uses JS to set | 1757 // Checks that we correctly use a prerendered page when the page uses JS to set |
| 1693 // the window.location.hash to a fragment on the same page. | 1758 // the window.location.hash to a fragment on the same page. |
| 1694 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1759 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 1695 PrerenderPageChangeFragmentLocationHash) { | 1760 PrerenderPageChangeFragmentLocationHash) { |
| 1696 PrerenderTestURL("files/prerender/prerender_fragment_location_hash.html", | 1761 PrerenderTestURL("files/prerender/prerender_fragment_location_hash.html", |
| 1697 FINAL_STATUS_USED, | 1762 FINAL_STATUS_USED, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1839 PrerenderTestURL("files/prerender/prerender_print.html", | 1904 PrerenderTestURL("files/prerender/prerender_print.html", |
| 1840 FINAL_STATUS_WINDOW_PRINT, | 1905 FINAL_STATUS_WINDOW_PRINT, |
| 1841 1); | 1906 1); |
| 1842 } | 1907 } |
| 1843 | 1908 |
| 1844 // Checks that if a page is opened in a new window by javascript and both the | 1909 // Checks that if a page is opened in a new window by javascript and both the |
| 1845 // pages are in the same domain, the prerendered page is not used. | 1910 // pages are in the same domain, the prerendered page is not used. |
| 1846 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1911 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 1847 PrerenderSameDomainWindowOpenerWindowOpen) { | 1912 PrerenderSameDomainWindowOpenerWindowOpen) { |
| 1848 PrerenderTestURL("files/prerender/prerender_page.html", | 1913 PrerenderTestURL("files/prerender/prerender_page.html", |
| 1849 FINAL_STATUS_WINDOW_OPENER, | 1914 FINAL_STATUS_APP_TERMINATING, |
| 1850 1); | 1915 1); |
| 1851 OpenDestURLViaWindowOpen(); | 1916 OpenDestURLViaWindowOpen(); |
| 1852 } | 1917 } |
| 1853 | 1918 |
| 1854 // Checks that if a page is opened due to click on a href with target="_blank" | 1919 // Checks that if a page is opened due to click on a href with target="_blank" |
| 1855 // and both pages are in the same domain the prerendered page is not used. | 1920 // and both pages are in the same domain the prerendered page is not used. |
| 1856 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1921 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 1857 PrerenderSameDomainWindowOpenerClickTarget) { | 1922 PrerenderSameDomainWindowOpenerClickTarget) { |
| 1858 PrerenderTestURL("files/prerender/prerender_page.html", | 1923 PrerenderTestURL("files/prerender/prerender_page.html", |
| 1859 FINAL_STATUS_WINDOW_OPENER, | 1924 FINAL_STATUS_APP_TERMINATING, |
| 1860 1); | 1925 1); |
| 1861 OpenDestURLViaClickTarget(); | 1926 OpenDestURLViaClickTarget(); |
| 1862 } | 1927 } |
| 1863 | 1928 |
| 1864 // Checks that a top-level page which would normally request an SSL client | 1929 // Checks that a top-level page which would normally request an SSL client |
| 1865 // certificate will never be seen since it's an https top-level resource. | 1930 // certificate will never be seen since it's an https top-level resource. |
| 1866 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLClientCertTopLevel) { | 1931 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLClientCertTopLevel) { |
| 1867 net::TestServer::HTTPSOptions https_options; | 1932 net::TestServer::HTTPSOptions https_options; |
| 1868 https_options.request_client_certificate = true; | 1933 https_options.request_client_certificate = true; |
| 1869 net::TestServer https_server(https_options, | 1934 net::TestServer https_server(https_options, |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2132 PrerenderTestURL("files/prerender/prerender_page_with_link.html", | 2197 PrerenderTestURL("files/prerender/prerender_page_with_link.html", |
| 2133 FINAL_STATUS_USED, | 2198 FINAL_STATUS_USED, |
| 2134 1); | 2199 1); |
| 2135 OpenDestURLViaClick(); | 2200 OpenDestURLViaClick(); |
| 2136 NavigateToNextPageAfterPrerender(); | 2201 NavigateToNextPageAfterPrerender(); |
| 2137 GoBackToPrerender(); | 2202 GoBackToPrerender(); |
| 2138 } | 2203 } |
| 2139 | 2204 |
| 2140 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClickNewWindow) { | 2205 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClickNewWindow) { |
| 2141 PrerenderTestURL("files/prerender/prerender_page_with_link.html", | 2206 PrerenderTestURL("files/prerender/prerender_page_with_link.html", |
| 2142 FINAL_STATUS_SESSION_STORAGE_NAMESPACE_MISMATCH, | 2207 FINAL_STATUS_APP_TERMINATING, |
| 2143 1); | 2208 1); |
| 2144 OpenDestURLViaClickNewWindow(); | 2209 OpenDestURLViaClickNewWindow(); |
| 2145 } | 2210 } |
| 2146 | 2211 |
| 2147 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClickNewForegroundTab) { | 2212 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClickNewForegroundTab) { |
| 2148 PrerenderTestURL("files/prerender/prerender_page_with_link.html", | 2213 PrerenderTestURL("files/prerender/prerender_page_with_link.html", |
| 2149 FINAL_STATUS_SESSION_STORAGE_NAMESPACE_MISMATCH, | 2214 FINAL_STATUS_APP_TERMINATING, |
| 2150 1); | 2215 1); |
| 2151 OpenDestURLViaClickNewForegroundTab(); | 2216 OpenDestURLViaClickNewForegroundTab(); |
| 2152 } | 2217 } |
| 2153 | 2218 |
| 2154 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClickNewBackgroundTab) { | 2219 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClickNewBackgroundTab) { |
| 2155 PrerenderTestURL("files/prerender/prerender_page_with_link.html", | 2220 PrerenderTestURL("files/prerender/prerender_page_with_link.html", |
| 2156 FINAL_STATUS_SESSION_STORAGE_NAMESPACE_MISMATCH, | 2221 FINAL_STATUS_APP_TERMINATING, |
| 2157 1); | 2222 1); |
| 2158 OpenDestURLViaClickNewBackgroundTab(); | 2223 OpenDestURLViaClickNewBackgroundTab(); |
| 2159 } | 2224 } |
| 2160 | 2225 |
| 2161 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2226 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 2162 NavigateToPrerenderedPageWhenDevToolsAttached) { | 2227 NavigateToPrerenderedPageWhenDevToolsAttached) { |
| 2163 DisableJavascriptCalls(); | 2228 DisableJavascriptCalls(); |
| 2164 WebContents* web_contents = chrome::GetActiveWebContents(current_browser()); | 2229 WebContents* web_contents = chrome::GetActiveWebContents(current_browser()); |
| 2165 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( | 2230 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( |
| 2166 web_contents->GetRenderViewHost()); | 2231 web_contents->GetRenderViewHost()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2251 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLReferrerPolicy) { | 2316 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLReferrerPolicy) { |
| 2252 set_use_https_src(true); | 2317 set_use_https_src(true); |
| 2253 set_loader_path("files/prerender/prerender_loader_with_referrer_policy.html"); | 2318 set_loader_path("files/prerender/prerender_loader_with_referrer_policy.html"); |
| 2254 PrerenderTestURL("files/prerender/prerender_referrer_policy.html", | 2319 PrerenderTestURL("files/prerender/prerender_referrer_policy.html", |
| 2255 FINAL_STATUS_USED, | 2320 FINAL_STATUS_USED, |
| 2256 1); | 2321 1); |
| 2257 NavigateToDestURL(); | 2322 NavigateToDestURL(); |
| 2258 } | 2323 } |
| 2259 | 2324 |
| 2260 } // namespace prerender | 2325 } // namespace prerender |
| OLD | NEW |