| 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/cancelable_callback.h" | 6 #include "base/cancelable_callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.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 "chrome/browser/debugger/devtools_window.h" | 13 #include "chrome/browser/debugger/devtools_window.h" |
| 14 #include "chrome/browser/extensions/extension_host.h" | 14 #include "chrome/browser/extensions/extension_host.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/unpacked_installer.h" | 16 #include "chrome/browser/extensions/unpacked_installer.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
| 23 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
| 24 #include "content/browser/debugger/devtools_client_host.h" | |
| 25 #include "content/browser/debugger/devtools_manager.h" | |
| 26 #include "content/browser/debugger/worker_devtools_manager.h" | |
| 27 #include "content/browser/renderer_host/render_view_host.h" | 24 #include "content/browser/renderer_host/render_view_host.h" |
| 28 #include "content/browser/tab_contents/tab_contents.h" | 25 #include "content/browser/tab_contents/tab_contents.h" |
| 29 #include "content/browser/worker_host/worker_process_host.h" | 26 #include "content/browser/worker_host/worker_process_host.h" |
| 30 #include "content/browser/worker_host/worker_service.h" | 27 #include "content/browser/worker_host/worker_service.h" |
| 31 #include "content/browser/worker_host/worker_service_observer.h" | 28 #include "content/browser/worker_host/worker_service_observer.h" |
| 29 #include "content/public/browser/devtools_agent_host_registry.h" |
| 30 #include "content/public/browser/devtools_client_host.h" |
| 31 #include "content/public/browser/devtools_manager.h" |
| 32 #include "content/public/browser/content_browser_client.h" | 32 #include "content/public/browser/content_browser_client.h" |
| 33 #include "content/public/browser/notification_registrar.h" | 33 #include "content/public/browser/notification_registrar.h" |
| 34 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
| 35 #include "net/test/test_server.h" | 35 #include "net/test/test_server.h" |
| 36 | 36 |
| 37 using content::BrowserThread; | 37 using content::BrowserThread; |
| 38 using content::DevToolsManager; |
| 39 using content::DevToolsAgentHost; |
| 40 using content::DevToolsAgentHostRegistry; |
| 38 | 41 |
| 39 namespace { | 42 namespace { |
| 40 | 43 |
| 41 // Used to block until a dev tools client window's browser is closed. | 44 // Used to block until a dev tools client window's browser is closed. |
| 42 class BrowserClosedObserver : public content::NotificationObserver { | 45 class BrowserClosedObserver : public content::NotificationObserver { |
| 43 public: | 46 public: |
| 44 explicit BrowserClosedObserver(Browser* browser) { | 47 explicit BrowserClosedObserver(Browser* browser) { |
| 45 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, | 48 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
| 46 content::Source<Browser>(browser)); | 49 content::Source<Browser>(browser)); |
| 47 ui_test_utils::RunMessageLoop(); | 50 ui_test_utils::RunMessageLoop(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 141 |
| 139 TabContents* GetInspectedTab() { | 142 TabContents* GetInspectedTab() { |
| 140 return browser()->GetTabContentsAt(0); | 143 return browser()->GetTabContentsAt(0); |
| 141 } | 144 } |
| 142 | 145 |
| 143 void CloseDevToolsWindow() { | 146 void CloseDevToolsWindow() { |
| 144 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 147 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
| 145 // UnregisterDevToolsClientHostFor may destroy window_ so store the browser | 148 // UnregisterDevToolsClientHostFor may destroy window_ so store the browser |
| 146 // first. | 149 // first. |
| 147 Browser* browser = window_->browser(); | 150 Browser* browser = window_->browser(); |
| 148 devtools_manager->UnregisterDevToolsClientHostFor(inspected_rvh_); | 151 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( |
| 152 inspected_rvh_); |
| 153 devtools_manager->UnregisterDevToolsClientHostFor(agent); |
| 149 | 154 |
| 150 // Wait only when DevToolsWindow has a browser. For docked DevTools, this | 155 // Wait only when DevToolsWindow has a browser. For docked DevTools, this |
| 151 // is NULL and we skip the wait. | 156 // is NULL and we skip the wait. |
| 152 if (browser) | 157 if (browser) |
| 153 BrowserClosedObserver close_observer(browser); | 158 BrowserClosedObserver close_observer(browser); |
| 154 } | 159 } |
| 155 | 160 |
| 156 DevToolsWindow* window_; | 161 DevToolsWindow* window_; |
| 157 RenderViewHost* inspected_rvh_; | 162 RenderViewHost* inspected_rvh_; |
| 158 }; | 163 }; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 base::Bind(&WaitForFirstSharedWorkerOnIOThread, worker_data)); | 385 base::Bind(&WaitForFirstSharedWorkerOnIOThread, worker_data)); |
| 381 ui_test_utils::RunMessageLoop(); | 386 ui_test_utils::RunMessageLoop(); |
| 382 return worker_data; | 387 return worker_data; |
| 383 } | 388 } |
| 384 | 389 |
| 385 void OpenDevToolsWindowForSharedWorker(WorkerData* worker_data) { | 390 void OpenDevToolsWindowForSharedWorker(WorkerData* worker_data) { |
| 386 Profile* profile = browser()->profile(); | 391 Profile* profile = browser()->profile(); |
| 387 window_ = DevToolsWindow::CreateDevToolsWindowForWorker(profile); | 392 window_ = DevToolsWindow::CreateDevToolsWindowForWorker(profile); |
| 388 window_->Show(DEVTOOLS_TOGGLE_ACTION_NONE); | 393 window_->Show(DEVTOOLS_TOGGLE_ACTION_NONE); |
| 389 DevToolsAgentHost* agent_host = | 394 DevToolsAgentHost* agent_host = |
| 390 WorkerDevToolsManager::GetDevToolsAgentHostForWorker( | 395 DevToolsAgentHostRegistry::GetDevToolsAgentHostForWorker( |
| 391 worker_data->worker_process_id, | 396 worker_data->worker_process_id, |
| 392 worker_data->worker_route_id); | 397 worker_data->worker_route_id); |
| 393 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( | 398 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
| 394 agent_host, | 399 agent_host, |
| 395 window_); | 400 window_->devtools_client_host()); |
| 396 RenderViewHost* client_rvh = window_->GetRenderViewHost(); | 401 RenderViewHost* client_rvh = window_->GetRenderViewHost(); |
| 397 TabContents* client_contents = client_rvh->delegate()->GetAsTabContents(); | 402 TabContents* client_contents = client_rvh->delegate()->GetAsTabContents(); |
| 398 if (client_contents->IsLoading()) { | 403 if (client_contents->IsLoading()) { |
| 399 ui_test_utils::WindowedNotificationObserver observer( | 404 ui_test_utils::WindowedNotificationObserver observer( |
| 400 content::NOTIFICATION_LOAD_STOP, | 405 content::NOTIFICATION_LOAD_STOP, |
| 401 content::Source<NavigationController>( | 406 content::Source<NavigationController>( |
| 402 &client_contents->controller())); | 407 &client_contents->controller())); |
| 403 observer.Wait(); | 408 observer.Wait(); |
| 404 } | 409 } |
| 405 } | 410 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 | 555 |
| 551 // Reload page to restart the worker. | 556 // Reload page to restart the worker. |
| 552 ui_test_utils::NavigateToURL(browser(), url); | 557 ui_test_utils::NavigateToURL(browser(), url); |
| 553 | 558 |
| 554 // Wait until worker script is paused on the debugger statement. | 559 // Wait until worker script is paused on the debugger statement. |
| 555 RunTestFuntion(window_, "testPauseInSharedWorkerInitialization"); | 560 RunTestFuntion(window_, "testPauseInSharedWorkerInitialization"); |
| 556 CloseDevToolsWindow(); | 561 CloseDevToolsWindow(); |
| 557 } | 562 } |
| 558 | 563 |
| 559 } // namespace | 564 } // namespace |
| OLD | NEW |