OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/debugger/devtools_window.h" | 12 #include "chrome/browser/debugger/devtools_window.h" |
13 #include "chrome/browser/extensions/extension_host.h" | 13 #include "chrome/browser/extensions/extension_host.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/unpacked_installer.h" | 15 #include "chrome/browser/extensions/unpacked_installer.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
23 #include "content/browser/debugger/devtools_client_host.h" | |
24 #include "content/browser/debugger/devtools_manager.h" | |
25 #include "content/browser/debugger/worker_devtools_manager.h" | |
26 #include "content/browser/renderer_host/render_view_host.h" | 23 #include "content/browser/renderer_host/render_view_host.h" |
27 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
28 #include "content/browser/worker_host/worker_process_host.h" | 25 #include "content/browser/worker_host/worker_process_host.h" |
29 #include "content/browser/worker_host/worker_service.h" | 26 #include "content/browser/worker_host/worker_service.h" |
30 #include "content/browser/worker_host/worker_service_observer.h" | 27 #include "content/browser/worker_host/worker_service_observer.h" |
| 28 #include "content/public/browser/devtools/devtools_agent_host_registry.h" |
| 29 #include "content/public/browser/devtools/devtools_client_host.h" |
| 30 #include "content/public/browser/devtools/devtools_manager.h" |
31 #include "content/public/browser/content_browser_client.h" | 31 #include "content/public/browser/content_browser_client.h" |
32 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
34 #include "net/test/test_server.h" | 34 #include "net/test/test_server.h" |
35 | 35 |
36 using content::BrowserThread; | 36 using content::BrowserThread; |
| 37 using content::DevToolsAgentHost; |
| 38 using content::DevToolsAgentHostRegistry; |
37 | 39 |
38 namespace { | 40 namespace { |
39 | 41 |
40 // Used to block until a dev tools client window's browser is closed. | 42 // Used to block until a dev tools client window's browser is closed. |
41 class BrowserClosedObserver : public content::NotificationObserver { | 43 class BrowserClosedObserver : public content::NotificationObserver { |
42 public: | 44 public: |
43 explicit BrowserClosedObserver(Browser* browser) { | 45 explicit BrowserClosedObserver(Browser* browser) { |
44 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, | 46 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
45 content::Source<Browser>(browser)); | 47 content::Source<Browser>(browser)); |
46 ui_test_utils::RunMessageLoop(); | 48 ui_test_utils::RunMessageLoop(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 inspected_rvh_ = GetInspectedTab()->render_view_host(); | 135 inspected_rvh_ = GetInspectedTab()->render_view_host(); |
134 window_ = DevToolsWindow::OpenDevToolsWindow(inspected_rvh_); | 136 window_ = DevToolsWindow::OpenDevToolsWindow(inspected_rvh_); |
135 observer.Wait(); | 137 observer.Wait(); |
136 } | 138 } |
137 | 139 |
138 TabContents* GetInspectedTab() { | 140 TabContents* GetInspectedTab() { |
139 return browser()->GetTabContentsAt(0); | 141 return browser()->GetTabContentsAt(0); |
140 } | 142 } |
141 | 143 |
142 void CloseDevToolsWindow() { | 144 void CloseDevToolsWindow() { |
143 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 145 content::DevToolsManager* devtools_manager = |
| 146 content::DevToolsManager::GetInstance(); |
144 // UnregisterDevToolsClientHostFor may destroy window_ so store the browser | 147 // UnregisterDevToolsClientHostFor may destroy window_ so store the browser |
145 // first. | 148 // first. |
146 Browser* browser = window_->browser(); | 149 Browser* browser = window_->browser(); |
147 devtools_manager->UnregisterDevToolsClientHostFor(inspected_rvh_); | 150 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( |
| 151 inspected_rvh_); |
| 152 devtools_manager->UnregisterDevToolsClientHostFor(agent); |
148 | 153 |
149 // Wait only when DevToolsWindow has a browser. For docked DevTools, this | 154 // Wait only when DevToolsWindow has a browser. For docked DevTools, this |
150 // is NULL and we skip the wait. | 155 // is NULL and we skip the wait. |
151 if (browser) | 156 if (browser) |
152 BrowserClosedObserver close_observer(browser); | 157 BrowserClosedObserver close_observer(browser); |
153 } | 158 } |
154 | 159 |
155 DevToolsWindow* window_; | 160 DevToolsWindow* window_; |
156 RenderViewHost* inspected_rvh_; | 161 RenderViewHost* inspected_rvh_; |
157 }; | 162 }; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 base::Bind(&WaitForFirstSharedWorkerOnIOThread, worker_data)); | 405 base::Bind(&WaitForFirstSharedWorkerOnIOThread, worker_data)); |
401 ui_test_utils::RunMessageLoop(); | 406 ui_test_utils::RunMessageLoop(); |
402 return worker_data; | 407 return worker_data; |
403 } | 408 } |
404 | 409 |
405 void OpenDevToolsWindowForSharedWorker(WorkerData* worker_data) { | 410 void OpenDevToolsWindowForSharedWorker(WorkerData* worker_data) { |
406 Profile* profile = browser()->profile(); | 411 Profile* profile = browser()->profile(); |
407 window_ = DevToolsWindow::CreateDevToolsWindowForWorker(profile); | 412 window_ = DevToolsWindow::CreateDevToolsWindowForWorker(profile); |
408 window_->Show(DEVTOOLS_TOGGLE_ACTION_NONE); | 413 window_->Show(DEVTOOLS_TOGGLE_ACTION_NONE); |
409 DevToolsAgentHost* agent_host = | 414 DevToolsAgentHost* agent_host = |
410 WorkerDevToolsManager::GetDevToolsAgentHostForWorker( | 415 DevToolsAgentHostRegistry::GetDevToolsAgentHostForWorker( |
411 worker_data->worker_process_id, | 416 worker_data->worker_process_id, |
412 worker_data->worker_route_id); | 417 worker_data->worker_route_id); |
413 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( | 418 content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
414 agent_host, | 419 agent_host, |
415 window_); | 420 window_); |
416 RenderViewHost* client_rvh = window_->GetRenderViewHost(); | 421 RenderViewHost* client_rvh = window_->GetRenderViewHost(); |
417 TabContents* client_contents = client_rvh->delegate()->GetAsTabContents(); | 422 TabContents* client_contents = client_rvh->delegate()->GetAsTabContents(); |
418 if (client_contents->IsLoading()) { | 423 if (client_contents->IsLoading()) { |
419 ui_test_utils::WindowedNotificationObserver observer( | 424 ui_test_utils::WindowedNotificationObserver observer( |
420 content::NOTIFICATION_LOAD_STOP, | 425 content::NOTIFICATION_LOAD_STOP, |
421 content::Source<NavigationController>( | 426 content::Source<NavigationController>( |
422 &client_contents->controller())); | 427 &client_contents->controller())); |
423 observer.Wait(); | 428 observer.Wait(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 | 575 |
571 // Reload page to restart the worker. | 576 // Reload page to restart the worker. |
572 ui_test_utils::NavigateToURL(browser(), url); | 577 ui_test_utils::NavigateToURL(browser(), url); |
573 | 578 |
574 // Wait until worker script is paused on the debugger statement. | 579 // Wait until worker script is paused on the debugger statement. |
575 RunTestFuntion(window_, "testPauseInSharedWorkerInitialization"); | 580 RunTestFuntion(window_, "testPauseInSharedWorkerInitialization"); |
576 CloseDevToolsWindow(); | 581 CloseDevToolsWindow(); |
577 } | 582 } |
578 | 583 |
579 } // namespace | 584 } // namespace |
OLD | NEW |