| 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 "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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 OpenDevToolsWindow(test_page); | 129 OpenDevToolsWindow(test_page); |
| 130 RunTestFunction(window_, test_name.c_str()); | 130 RunTestFunction(window_, test_name.c_str()); |
| 131 CloseDevToolsWindow(); | 131 CloseDevToolsWindow(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void OpenDevToolsWindow(const std::string& test_page) { | 134 void OpenDevToolsWindow(const std::string& test_page) { |
| 135 ASSERT_TRUE(test_server()->Start()); | 135 ASSERT_TRUE(test_server()->Start()); |
| 136 GURL url = test_server()->GetURL(test_page); | 136 GURL url = test_server()->GetURL(test_page); |
| 137 ui_test_utils::NavigateToURL(browser(), url); | 137 ui_test_utils::NavigateToURL(browser(), url); |
| 138 | 138 |
| 139 ui_test_utils::WindowedNotificationObserver observer( | 139 content::WindowedNotificationObserver observer( |
| 140 content::NOTIFICATION_LOAD_STOP, | 140 content::NOTIFICATION_LOAD_STOP, |
| 141 content::NotificationService::AllSources()); | 141 content::NotificationService::AllSources()); |
| 142 inspected_rvh_ = GetInspectedTab()->GetRenderViewHost(); | 142 inspected_rvh_ = GetInspectedTab()->GetRenderViewHost(); |
| 143 window_ = DevToolsWindow::OpenDevToolsWindow(inspected_rvh_); | 143 window_ = DevToolsWindow::OpenDevToolsWindow(inspected_rvh_); |
| 144 observer.Wait(); | 144 observer.Wait(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 WebContents* GetInspectedTab() { | 147 WebContents* GetInspectedTab() { |
| 148 return chrome::GetWebContentsAt(browser(), 0); | 148 return chrome::GetWebContentsAt(browser(), 0); |
| 149 } | 149 } |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 DevToolsAgentHost* agent_host = | 386 DevToolsAgentHost* agent_host = |
| 387 DevToolsAgentHostRegistry::GetDevToolsAgentHostForWorker( | 387 DevToolsAgentHostRegistry::GetDevToolsAgentHostForWorker( |
| 388 worker_data->worker_process_id, | 388 worker_data->worker_process_id, |
| 389 worker_data->worker_route_id); | 389 worker_data->worker_route_id); |
| 390 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( | 390 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
| 391 agent_host, | 391 agent_host, |
| 392 window_->devtools_client_host()); | 392 window_->devtools_client_host()); |
| 393 RenderViewHost* client_rvh = window_->GetRenderViewHost(); | 393 RenderViewHost* client_rvh = window_->GetRenderViewHost(); |
| 394 WebContents* client_contents = WebContents::FromRenderViewHost(client_rvh); | 394 WebContents* client_contents = WebContents::FromRenderViewHost(client_rvh); |
| 395 if (client_contents->IsLoading()) { | 395 if (client_contents->IsLoading()) { |
| 396 ui_test_utils::WindowedNotificationObserver observer( | 396 content::WindowedNotificationObserver observer( |
| 397 content::NOTIFICATION_LOAD_STOP, | 397 content::NOTIFICATION_LOAD_STOP, |
| 398 content::Source<NavigationController>( | 398 content::Source<NavigationController>( |
| 399 &client_contents->GetController())); | 399 &client_contents->GetController())); |
| 400 observer.Wait(); | 400 observer.Wait(); |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 | 403 |
| 404 void CloseDevToolsWindow() { | 404 void CloseDevToolsWindow() { |
| 405 Browser* browser = window_->browser(); | 405 Browser* browser = window_->browser(); |
| 406 chrome::CloseAllTabs(browser); | 406 chrome::CloseAllTabs(browser); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 #if defined(OS_MACOSX) || defined(OS_LINUX) | 521 #if defined(OS_MACOSX) || defined(OS_LINUX) |
| 522 // http://crbug.com/103539 | 522 // http://crbug.com/103539 |
| 523 #define TestReattachAfterCrash DISABLED_TestReattachAfterCrash | 523 #define TestReattachAfterCrash DISABLED_TestReattachAfterCrash |
| 524 #endif | 524 #endif |
| 525 // Tests that inspector will reattach to inspected page when it is reloaded | 525 // Tests that inspector will reattach to inspected page when it is reloaded |
| 526 // after a crash. See http://crbug.com/101952 | 526 // after a crash. See http://crbug.com/101952 |
| 527 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestReattachAfterCrash) { | 527 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestReattachAfterCrash) { |
| 528 OpenDevToolsWindow(kDebuggerTestPage); | 528 OpenDevToolsWindow(kDebuggerTestPage); |
| 529 | 529 |
| 530 ui_test_utils::CrashTab(GetInspectedTab()); | 530 ui_test_utils::CrashTab(GetInspectedTab()); |
| 531 ui_test_utils::WindowedNotificationObserver observer( | 531 content::WindowedNotificationObserver observer( |
| 532 content::NOTIFICATION_LOAD_STOP, | 532 content::NOTIFICATION_LOAD_STOP, |
| 533 content::Source<NavigationController>( | 533 content::Source<NavigationController>( |
| 534 &chrome::GetActiveWebContents(browser())->GetController())); | 534 &chrome::GetActiveWebContents(browser())->GetController())); |
| 535 chrome::Reload(browser(), CURRENT_TAB); | 535 chrome::Reload(browser(), CURRENT_TAB); |
| 536 observer.Wait(); | 536 observer.Wait(); |
| 537 | 537 |
| 538 RunTestFunction(window_, "testReattachAfterCrash"); | 538 RunTestFunction(window_, "testReattachAfterCrash"); |
| 539 CloseDevToolsWindow(); | 539 CloseDevToolsWindow(); |
| 540 } | 540 } |
| 541 | 541 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 content::CONSOLE_MESSAGE_LEVEL_LOG, | 602 content::CONSOLE_MESSAGE_LEVEL_LOG, |
| 603 "log"); | 603 "log"); |
| 604 devtools_manager->AddMessageToConsole(agent_host, | 604 devtools_manager->AddMessageToConsole(agent_host, |
| 605 content::CONSOLE_MESSAGE_LEVEL_ERROR, | 605 content::CONSOLE_MESSAGE_LEVEL_ERROR, |
| 606 "error"); | 606 "error"); |
| 607 RunTestFunction(window_, "checkLogAndErrorMessages"); | 607 RunTestFunction(window_, "checkLogAndErrorMessages"); |
| 608 CloseDevToolsWindow(); | 608 CloseDevToolsWindow(); |
| 609 } | 609 } |
| 610 | 610 |
| 611 } // namespace | 611 } // namespace |
| OLD | NEW |