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