| 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 return worker_data; | 500 return worker_data; |
| 501 } | 501 } |
| 502 | 502 |
| 503 void OpenDevToolsWindowForSharedWorker(WorkerData* worker_data) { | 503 void OpenDevToolsWindowForSharedWorker(WorkerData* worker_data) { |
| 504 Profile* profile = browser()->profile(); | 504 Profile* profile = browser()->profile(); |
| 505 scoped_refptr<DevToolsAgentHost> agent_host( | 505 scoped_refptr<DevToolsAgentHost> agent_host( |
| 506 DevToolsAgentHost::GetForWorker( | 506 DevToolsAgentHost::GetForWorker( |
| 507 worker_data->worker_process_id, | 507 worker_data->worker_process_id, |
| 508 worker_data->worker_route_id)); | 508 worker_data->worker_route_id)); |
| 509 window_ = DevToolsWindowTesting::OpenDevToolsWindowForWorkerSync( | 509 window_ = DevToolsWindowTesting::OpenDevToolsWindowForWorkerSync( |
| 510 profile, agent_host); | 510 profile, agent_host.get()); |
| 511 } | 511 } |
| 512 | 512 |
| 513 void CloseDevToolsWindow() { | 513 void CloseDevToolsWindow() { |
| 514 DevToolsWindowTesting::CloseDevToolsWindowSync(window_); | 514 DevToolsWindowTesting::CloseDevToolsWindowSync(window_); |
| 515 } | 515 } |
| 516 | 516 |
| 517 DevToolsWindow* window_; | 517 DevToolsWindow* window_; |
| 518 }; | 518 }; |
| 519 | 519 |
| 520 // Tests that BeforeUnload event gets called on docked devtools if | 520 // Tests that BeforeUnload event gets called on docked devtools if |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 | 874 |
| 875 class DevToolsAgentHostTest : public InProcessBrowserTest {}; | 875 class DevToolsAgentHostTest : public InProcessBrowserTest {}; |
| 876 | 876 |
| 877 // Tests DevToolsAgentHost retention by its target. | 877 // Tests DevToolsAgentHost retention by its target. |
| 878 IN_PROC_BROWSER_TEST_F(DevToolsAgentHostTest, TestAgentHostReleased) { | 878 IN_PROC_BROWSER_TEST_F(DevToolsAgentHostTest, TestAgentHostReleased) { |
| 879 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 879 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 880 WebContents* web_contents = browser()->tab_strip_model()->GetWebContentsAt(0); | 880 WebContents* web_contents = browser()->tab_strip_model()->GetWebContentsAt(0); |
| 881 DevToolsAgentHost* agent_raw = | 881 DevToolsAgentHost* agent_raw = |
| 882 DevToolsAgentHost::GetOrCreateFor(web_contents).get(); | 882 DevToolsAgentHost::GetOrCreateFor(web_contents).get(); |
| 883 const std::string agent_id = agent_raw->GetId(); | 883 const std::string agent_id = agent_raw->GetId(); |
| 884 ASSERT_EQ(agent_raw, DevToolsAgentHost::GetForId(agent_id)) << | 884 ASSERT_EQ(agent_raw, DevToolsAgentHost::GetForId(agent_id).get()) |
| 885 "DevToolsAgentHost cannot be found by id"; | 885 << "DevToolsAgentHost cannot be found by id"; |
| 886 browser()->tab_strip_model()-> | 886 browser()->tab_strip_model()-> |
| 887 CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); | 887 CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); |
| 888 ASSERT_FALSE(DevToolsAgentHost::GetForId(agent_id).get()) | 888 ASSERT_FALSE(DevToolsAgentHost::GetForId(agent_id).get()) |
| 889 << "DevToolsAgentHost is not released when the tab is closed"; | 889 << "DevToolsAgentHost is not released when the tab is closed"; |
| 890 } | 890 } |
| 891 | 891 |
| 892 class RemoteDebuggingTest: public ExtensionApiTest { | 892 class RemoteDebuggingTest: public ExtensionApiTest { |
| 893 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 893 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 894 ExtensionApiTest::SetUpCommandLine(command_line); | 894 ExtensionApiTest::SetUpCommandLine(command_line); |
| 895 command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort, "9222"); | 895 command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort, "9222"); |
| 896 | 896 |
| 897 // Override the extension root path. | 897 // Override the extension root path. |
| 898 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); | 898 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); |
| 899 test_data_dir_ = test_data_dir_.AppendASCII("devtools"); | 899 test_data_dir_ = test_data_dir_.AppendASCII("devtools"); |
| 900 } | 900 } |
| 901 }; | 901 }; |
| 902 | 902 |
| 903 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, RemoteDebugger) { | 903 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, RemoteDebugger) { |
| 904 #if defined(OS_WIN) && defined(USE_ASH) | 904 #if defined(OS_WIN) && defined(USE_ASH) |
| 905 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 905 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 906 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 906 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 907 return; | 907 return; |
| 908 #endif | 908 #endif |
| 909 | 909 |
| 910 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; | 910 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; |
| 911 } | 911 } |
| OLD | NEW |