| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/ref_counted.h" | 5 #include "base/ref_counted.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "chrome/browser/browser_list.h" | 7 #include "chrome/browser/browser_list.h" |
| 8 #include "chrome/browser/debugger/devtools_client_host.h" | 8 #include "chrome/browser/debugger/devtools_client_host.h" |
| 9 #include "chrome/browser/debugger/devtools_manager.h" | 9 #include "chrome/browser/debugger/devtools_manager.h" |
| 10 #include "chrome/browser/extensions/extension_devtools_browsertest.h" | 10 #include "chrome/browser/extensions/extension_devtools_browsertest.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 // Get the ExtensionHost that is hosting our background page. | 55 // Get the ExtensionHost that is hosting our background page. |
| 56 ExtensionProcessManager* manager = | 56 ExtensionProcessManager* manager = |
| 57 browser()->profile()->GetExtensionProcessManager(); | 57 browser()->profile()->GetExtensionProcessManager(); |
| 58 ExtensionHost* host = FindHostWithPath(manager, "/background.html", 1); | 58 ExtensionHost* host = FindHostWithPath(manager, "/background.html", 1); |
| 59 | 59 |
| 60 // Grab a handle to the DevToolsManager so we can forward messages to it. | 60 // Grab a handle to the DevToolsManager so we can forward messages to it. |
| 61 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 61 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
| 62 | 62 |
| 63 // Grab the tab_id of whatever tab happens to be first. | 63 // Grab the tab_id of whatever tab happens to be first. |
| 64 TabContents* tab_contents = browser()->tabstrip_model()->GetTabContentsAt(0); | 64 TabContents* tab_contents = browser()->GetTabContentsAt(0); |
| 65 ASSERT_TRUE(tab_contents); | 65 ASSERT_TRUE(tab_contents); |
| 66 int tab_id = ExtensionTabUtil::GetTabId(tab_contents); | 66 int tab_id = ExtensionTabUtil::GetTabId(tab_contents); |
| 67 | 67 |
| 68 // Test setup. | 68 // Test setup. |
| 69 bool result = false; | 69 bool result = false; |
| 70 std::wstring register_listeners_js = base::StringPrintf( | 70 std::wstring register_listeners_js = base::StringPrintf( |
| 71 L"setListenersOnTab(%d)", tab_id); | 71 L"setListenersOnTab(%d)", tab_id); |
| 72 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 72 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 73 host->render_view_host(), L"", register_listeners_js, &result)); | 73 host->render_view_host(), L"", register_listeners_js, &result)); |
| 74 EXPECT_TRUE(result); | 74 EXPECT_TRUE(result); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ExtensionHost* host_one = FindHostWithPath(manager, "/background.html", 1); | 110 ExtensionHost* host_one = FindHostWithPath(manager, "/background.html", 1); |
| 111 | 111 |
| 112 ASSERT_TRUE(LoadExtension( | 112 ASSERT_TRUE(LoadExtension( |
| 113 test_data_dir_.AppendASCII("devtools").AppendASCII("timeline_api_two"))); | 113 test_data_dir_.AppendASCII("devtools").AppendASCII("timeline_api_two"))); |
| 114 ExtensionHost* host_two = FindHostWithPath(manager, | 114 ExtensionHost* host_two = FindHostWithPath(manager, |
| 115 "/background_two.html", 2); | 115 "/background_two.html", 2); |
| 116 | 116 |
| 117 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 117 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
| 118 | 118 |
| 119 // Grab the tab_id of whatever tab happens to be first. | 119 // Grab the tab_id of whatever tab happens to be first. |
| 120 TabContents* tab_contents = browser()->tabstrip_model()->GetTabContentsAt(0); | 120 TabContents* tab_contents = browser()->GetTabContentsAt(0); |
| 121 ASSERT_TRUE(tab_contents); | 121 ASSERT_TRUE(tab_contents); |
| 122 int tab_id = ExtensionTabUtil::GetTabId(tab_contents); | 122 int tab_id = ExtensionTabUtil::GetTabId(tab_contents); |
| 123 | 123 |
| 124 // Test setup. | 124 // Test setup. |
| 125 bool result = false; | 125 bool result = false; |
| 126 std::wstring register_listeners_js = base::StringPrintf( | 126 std::wstring register_listeners_js = base::StringPrintf( |
| 127 L"setListenersOnTab(%d)", tab_id); | 127 L"setListenersOnTab(%d)", tab_id); |
| 128 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 128 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 129 host_one->render_view_host(), L"", register_listeners_js, &result)); | 129 host_one->render_view_host(), L"", register_listeners_js, &result)); |
| 130 EXPECT_TRUE(result); | 130 EXPECT_TRUE(result); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 152 | 152 |
| 153 // Removing the listeners from the second extension should tear the bridge | 153 // Removing the listeners from the second extension should tear the bridge |
| 154 // down. | 154 // down. |
| 155 result = false; | 155 result = false; |
| 156 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 156 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 157 host_two->render_view_host(), L"", L"unregisterListeners()", &result)); | 157 host_two->render_view_host(), L"", L"unregisterListeners()", &result)); |
| 158 EXPECT_TRUE(result); | 158 EXPECT_TRUE(result); |
| 159 ASSERT_FALSE(devtools_manager->GetDevToolsClientHostFor( | 159 ASSERT_FALSE(devtools_manager->GetDevToolsClientHostFor( |
| 160 tab_contents->render_view_host())); | 160 tab_contents->render_view_host())); |
| 161 } | 161 } |
| OLD | NEW |