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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "chrome/browser/extensions/extension_devtools_browsertest.h" | 7 #include "chrome/browser/extensions/extension_devtools_browsertest.h" |
8 #include "chrome/browser/extensions/extension_error_reporter.h" | 8 #include "chrome/browser/extensions/extension_error_reporter.h" |
9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
10 #include "chrome/browser/extensions/extension_process_manager.h" | 10 #include "chrome/browser/extensions/extension_process_manager.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/extension_tab_util.h" | 12 #include "chrome/browser/extensions/extension_tab_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
| 16 #include "chrome/browser/ui/browser_tabstrip.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
17 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/public/browser/devtools_agent_host_registry.h" | 21 #include "content/public/browser/devtools_agent_host_registry.h" |
21 #include "content/public/browser/devtools_client_host.h" | 22 #include "content/public/browser/devtools_client_host.h" |
22 #include "content/public/browser/devtools_manager.h" | 23 #include "content/public/browser/devtools_manager.h" |
23 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
25 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Get the ExtensionHost that is hosting our background page. | 63 // Get the ExtensionHost that is hosting our background page. |
63 ExtensionProcessManager* manager = | 64 ExtensionProcessManager* manager = |
64 browser()->profile()->GetExtensionProcessManager(); | 65 browser()->profile()->GetExtensionProcessManager(); |
65 ExtensionHost* host = FindBackgroundHostWithPath(manager, | 66 ExtensionHost* host = FindBackgroundHostWithPath(manager, |
66 "/background.html", 1); | 67 "/background.html", 1); |
67 | 68 |
68 // Grab a handle to the DevToolsManager so we can forward messages to it. | 69 // Grab a handle to the DevToolsManager so we can forward messages to it. |
69 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 70 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
70 | 71 |
71 // Grab the tab_id of whatever tab happens to be first. | 72 // Grab the tab_id of whatever tab happens to be first. |
72 WebContents* web_contents = browser()->GetWebContentsAt(0); | 73 WebContents* web_contents = chrome::GetWebContentsAt(browser(), 0); |
73 ASSERT_TRUE(web_contents); | 74 ASSERT_TRUE(web_contents); |
74 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 75 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
75 | 76 |
76 // Test setup. | 77 // Test setup. |
77 bool result = false; | 78 bool result = false; |
78 std::wstring register_listeners_js = base::StringPrintf( | 79 std::wstring register_listeners_js = base::StringPrintf( |
79 L"setListenersOnTab(%d)", tab_id); | 80 L"setListenersOnTab(%d)", tab_id); |
80 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 81 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
81 host->render_view_host(), L"", register_listeners_js, &result)); | 82 host->render_view_host(), L"", register_listeners_js, &result)); |
82 EXPECT_TRUE(result); | 83 EXPECT_TRUE(result); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 122 |
122 ASSERT_TRUE(LoadExtension( | 123 ASSERT_TRUE(LoadExtension( |
123 test_data_dir_.AppendASCII("devtools").AppendASCII("timeline_api_two"))); | 124 test_data_dir_.AppendASCII("devtools").AppendASCII("timeline_api_two"))); |
124 ExtensionHost* host_two = FindBackgroundHostWithPath(manager, | 125 ExtensionHost* host_two = FindBackgroundHostWithPath(manager, |
125 "/background_two.html", | 126 "/background_two.html", |
126 2); | 127 2); |
127 | 128 |
128 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 129 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
129 | 130 |
130 // Grab the tab_id of whatever tab happens to be first. | 131 // Grab the tab_id of whatever tab happens to be first. |
131 WebContents* web_contents = browser()->GetWebContentsAt(0); | 132 WebContents* web_contents = chrome::GetWebContentsAt(browser(), 0); |
132 ASSERT_TRUE(web_contents); | 133 ASSERT_TRUE(web_contents); |
133 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 134 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
134 | 135 |
135 // Test setup. | 136 // Test setup. |
136 bool result = false; | 137 bool result = false; |
137 std::wstring register_listeners_js = base::StringPrintf( | 138 std::wstring register_listeners_js = base::StringPrintf( |
138 L"setListenersOnTab(%d)", tab_id); | 139 L"setListenersOnTab(%d)", tab_id); |
139 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 140 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
140 host_one->render_view_host(), L"", register_listeners_js, &result)); | 141 host_one->render_view_host(), L"", register_listeners_js, &result)); |
141 EXPECT_TRUE(result); | 142 EXPECT_TRUE(result); |
(...skipping 24 matching lines...) Expand all Loading... |
166 // Removing the listeners from the second extension should tear the bridge | 167 // Removing the listeners from the second extension should tear the bridge |
167 // down. | 168 // down. |
168 result = false; | 169 result = false; |
169 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 170 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
170 host_two->render_view_host(), L"", L"unregisterListeners()", &result)); | 171 host_two->render_view_host(), L"", L"unregisterListeners()", &result)); |
171 EXPECT_TRUE(result); | 172 EXPECT_TRUE(result); |
172 ASSERT_FALSE(devtools_manager->GetDevToolsClientHostFor( | 173 ASSERT_FALSE(devtools_manager->GetDevToolsClientHostFor( |
173 DevToolsAgentHostRegistry::GetDevToolsAgentHost( | 174 DevToolsAgentHostRegistry::GetDevToolsAgentHost( |
174 web_contents->GetRenderViewHost()))); | 175 web_contents->GetRenderViewHost()))); |
175 } | 176 } |
OLD | NEW |