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 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 #include "chrome/common/chrome_switches.h" | 60 #include "chrome/common/chrome_switches.h" |
61 #include "chrome/common/extensions/extension_constants.h" | 61 #include "chrome/common/extensions/extension_constants.h" |
62 #include "chrome/common/extensions/manifest_handlers/mime_types_handler.h" | 62 #include "chrome/common/extensions/manifest_handlers/mime_types_handler.h" |
63 #include "chrome/common/pref_names.h" | 63 #include "chrome/common/pref_names.h" |
64 #include "chrome/test/base/in_process_browser_test.h" | 64 #include "chrome/test/base/in_process_browser_test.h" |
65 #include "chrome/test/base/test_switches.h" | 65 #include "chrome/test/base/test_switches.h" |
66 #include "chrome/test/base/ui_test_utils.h" | 66 #include "chrome/test/base/ui_test_utils.h" |
67 #include "chrome/test/base/uma_histogram_helper.h" | 67 #include "chrome/test/base/uma_histogram_helper.h" |
68 #include "content/public/browser/browser_message_filter.h" | 68 #include "content/public/browser/browser_message_filter.h" |
69 #include "content/public/browser/devtools_agent_host.h" | 69 #include "content/public/browser/devtools_agent_host.h" |
70 #include "content/public/browser/devtools_client_host.h" | |
71 #include "content/public/browser/devtools_manager.h" | |
72 #include "content/public/browser/navigation_controller.h" | 70 #include "content/public/browser/navigation_controller.h" |
73 #include "content/public/browser/navigation_entry.h" | 71 #include "content/public/browser/navigation_entry.h" |
74 #include "content/public/browser/notification_service.h" | 72 #include "content/public/browser/notification_service.h" |
75 #include "content/public/browser/render_frame_host.h" | 73 #include "content/public/browser/render_frame_host.h" |
76 #include "content/public/browser/render_process_host.h" | 74 #include "content/public/browser/render_process_host.h" |
77 #include "content/public/browser/render_view_host.h" | 75 #include "content/public/browser/render_view_host.h" |
78 #include "content/public/browser/site_instance.h" | 76 #include "content/public/browser/site_instance.h" |
79 #include "content/public/browser/web_contents.h" | 77 #include "content/public/browser/web_contents.h" |
80 #include "content/public/browser/web_contents_observer.h" | 78 #include "content/public/browser/web_contents_observer.h" |
81 #include "content/public/common/url_constants.h" | 79 #include "content/public/common/url_constants.h" |
(...skipping 11 matching lines...) Expand all Loading... |
93 #include "net/url_request/url_request_context.h" | 91 #include "net/url_request/url_request_context.h" |
94 #include "net/url_request/url_request_context_getter.h" | 92 #include "net/url_request/url_request_context_getter.h" |
95 #include "net/url_request/url_request_filter.h" | 93 #include "net/url_request/url_request_filter.h" |
96 #include "net/url_request/url_request_interceptor.h" | 94 #include "net/url_request/url_request_interceptor.h" |
97 #include "net/url_request/url_request_job.h" | 95 #include "net/url_request/url_request_job.h" |
98 #include "ui/base/l10n/l10n_util.h" | 96 #include "ui/base/l10n/l10n_util.h" |
99 #include "url/gurl.h" | 97 #include "url/gurl.h" |
100 | 98 |
101 using content::BrowserThread; | 99 using content::BrowserThread; |
102 using content::DevToolsAgentHost; | 100 using content::DevToolsAgentHost; |
103 using content::DevToolsClientHost; | |
104 using content::DevToolsManager; | |
105 using content::NavigationController; | 101 using content::NavigationController; |
106 using content::OpenURLParams; | 102 using content::OpenURLParams; |
107 using content::Referrer; | 103 using content::Referrer; |
108 using content::RenderFrameHost; | 104 using content::RenderFrameHost; |
109 using content::RenderViewHost; | 105 using content::RenderViewHost; |
110 using content::RenderWidgetHost; | 106 using content::RenderWidgetHost; |
111 using content::TestNavigationObserver; | 107 using content::TestNavigationObserver; |
112 using content::WebContents; | 108 using content::WebContents; |
113 using content::WebContentsObserver; | 109 using content::WebContentsObserver; |
114 using task_manager::browsertest_util::WaitForTaskManagerRows; | 110 using task_manager::browsertest_util::WaitForTaskManagerRows; |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 | 735 |
740 FakeSafeBrowsingService* most_recent_service() const { | 736 FakeSafeBrowsingService* most_recent_service() const { |
741 return most_recent_service_; | 737 return most_recent_service_; |
742 } | 738 } |
743 | 739 |
744 private: | 740 private: |
745 FakeSafeBrowsingService* most_recent_service_; | 741 FakeSafeBrowsingService* most_recent_service_; |
746 }; | 742 }; |
747 #endif | 743 #endif |
748 | 744 |
749 class FakeDevToolsClientHost : public DevToolsClientHost { | 745 class FakeDevToolsClient : public DevToolsAgentHost::Client { |
750 public: | 746 public: |
751 FakeDevToolsClientHost() {} | 747 FakeDevToolsClient() {} |
752 virtual ~FakeDevToolsClientHost() {} | 748 virtual ~FakeDevToolsClient() {} |
753 virtual void InspectedContentsClosing() OVERRIDE {} | 749 virtual void SendMessageFromAgentHost( |
754 virtual void DispatchOnInspectorFrontend(const std::string& msg) OVERRIDE {} | 750 DevToolsAgentHost* agent_host, const std::string& message) OVERRIDE {} |
755 virtual void ReplacedWithAnotherClient() OVERRIDE {} | 751 virtual void AgentHostDetached( |
| 752 DevToolsAgentHost* agent_host, |
| 753 DevToolsAgentHost::DetachReason reason) OVERRIDE {} |
756 }; | 754 }; |
757 | 755 |
758 class RestorePrerenderMode { | 756 class RestorePrerenderMode { |
759 public: | 757 public: |
760 RestorePrerenderMode() : prev_mode_(PrerenderManager::GetMode()) { | 758 RestorePrerenderMode() : prev_mode_(PrerenderManager::GetMode()) { |
761 } | 759 } |
762 | 760 |
763 ~RestorePrerenderMode() { PrerenderManager::SetMode(prev_mode_); } | 761 ~RestorePrerenderMode() { PrerenderManager::SetMode(prev_mode_); } |
764 private: | 762 private: |
765 PrerenderManager::PrerenderManagerMode prev_mode_; | 763 PrerenderManager::PrerenderManagerMode prev_mode_; |
(...skipping 2524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3290 OpenDestURLViaClickNewBackgroundTab(); | 3288 OpenDestURLViaClickNewBackgroundTab(); |
3291 } | 3289 } |
3292 | 3290 |
3293 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 3291 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
3294 NavigateToPrerenderedPageWhenDevToolsAttached) { | 3292 NavigateToPrerenderedPageWhenDevToolsAttached) { |
3295 DisableJavascriptCalls(); | 3293 DisableJavascriptCalls(); |
3296 WebContents* web_contents = | 3294 WebContents* web_contents = |
3297 current_browser()->tab_strip_model()->GetActiveWebContents(); | 3295 current_browser()->tab_strip_model()->GetActiveWebContents(); |
3298 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetOrCreateFor( | 3296 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetOrCreateFor( |
3299 web_contents->GetRenderViewHost())); | 3297 web_contents->GetRenderViewHost())); |
3300 DevToolsManager* manager = DevToolsManager::GetInstance(); | 3298 FakeDevToolsClient client; |
3301 FakeDevToolsClientHost client_host; | 3299 agent->AttachClient(&client); |
3302 manager->RegisterDevToolsClientHostFor(agent.get(), &client_host); | |
3303 const char* url = "files/prerender/prerender_page.html"; | 3300 const char* url = "files/prerender/prerender_page.html"; |
3304 PrerenderTestURL(url, FINAL_STATUS_DEVTOOLS_ATTACHED, 1); | 3301 PrerenderTestURL(url, FINAL_STATUS_DEVTOOLS_ATTACHED, 1); |
3305 NavigateToURLWithDisposition(url, CURRENT_TAB, false); | 3302 NavigateToURLWithDisposition(url, CURRENT_TAB, false); |
3306 manager->ClientHostClosing(&client_host); | 3303 agent->DetachClient(); |
3307 } | 3304 } |
3308 | 3305 |
3309 // Validate that the sessionStorage namespace remains the same when swapping | 3306 // Validate that the sessionStorage namespace remains the same when swapping |
3310 // in a prerendered page. | 3307 // in a prerendered page. |
3311 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSessionStorage) { | 3308 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSessionStorage) { |
3312 set_loader_path("files/prerender/prerender_loader_with_session_storage.html"); | 3309 set_loader_path("files/prerender/prerender_loader_with_session_storage.html"); |
3313 PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), | 3310 PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), |
3314 FINAL_STATUS_USED, | 3311 FINAL_STATUS_USED, |
3315 1); | 3312 1); |
3316 NavigateToDestURL(); | 3313 NavigateToDestURL(); |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4419 | 4416 |
4420 // Navigate to the URL entered. | 4417 // Navigate to the URL entered. |
4421 omnibox_view->model()->AcceptInput(CURRENT_TAB, false); | 4418 omnibox_view->model()->AcceptInput(CURRENT_TAB, false); |
4422 | 4419 |
4423 // Prerender should be running, but abandoned. | 4420 // Prerender should be running, but abandoned. |
4424 EXPECT_TRUE( | 4421 EXPECT_TRUE( |
4425 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting()); | 4422 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting()); |
4426 } | 4423 } |
4427 | 4424 |
4428 } // namespace prerender | 4425 } // namespace prerender |
OLD | NEW |