Index: chrome/browser/extensions/api/tabs/tabs_test.cc |
diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc |
index 0c2c75a3df675cadfe83118beafcac258f012484..d22f93fd89aa15fb1bb49abcbe9bf673a254c219 100644 |
--- a/chrome/browser/extensions/api/tabs/tabs_test.cc |
+++ b/chrome/browser/extensions/api/tabs/tabs_test.cc |
@@ -11,6 +11,7 @@ |
#include "base/strings/string_util.h" |
#include "base/strings/stringprintf.h" |
#include "base/values.h" |
+#include "chrome/browser/devtools/devtools_window_testing.h" |
#include "chrome/browser/extensions/api/tabs/tabs_api.h" |
#include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
#include "chrome/browser/extensions/extension_function_test_utils.h" |
@@ -188,6 +189,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { |
window_ids.insert(ExtensionTabUtil::GetWindowId(new_browser)); |
} |
+ // Undocked DevTools window should not be accessible. |
+ DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( |
+ browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); |
+ |
scoped_refptr<WindowsGetAllFunction> function = new WindowsGetAllFunction(); |
scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); |
function->set_extension(extension.get()); |
@@ -231,6 +236,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { |
} |
// The returned ids should contain all the current browser instance ids. |
EXPECT_EQ(window_ids, result_ids); |
+ |
+ DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
} |
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateNoPermissions) { |
@@ -437,6 +444,41 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { |
} |
} |
+IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryAllTabsWithDevTools) { |
+ const size_t kNumWindows = 3; |
+ std::set<int> window_ids; |
+ window_ids.insert(ExtensionTabUtil::GetWindowId(browser())); |
+ for (size_t i = 0; i < kNumWindows - 1; ++i) { |
+ Browser* new_browser = CreateBrowser(browser()->profile()); |
+ window_ids.insert(ExtensionTabUtil::GetWindowId(new_browser)); |
+ } |
+ |
+ // Undocked DevTools window should not be accessible. |
+ DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( |
+ browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); |
+ |
+ // Get tabs in the 'current' window called from non-focused browser. |
+ scoped_refptr<TabsQueryFunction> function = new TabsQueryFunction(); |
+ function->set_extension(test_util::CreateEmptyExtension().get()); |
+ scoped_ptr<base::ListValue> result(utils::ToList( |
+ utils::RunFunctionAndReturnSingleResult(function.get(), |
+ "[{}]", |
+ browser()))); |
+ |
+ std::set<int> result_ids; |
+ base::ListValue* result_tabs = result.get(); |
+ // We should have one tab per browser except for DevTools. |
+ EXPECT_EQ(kNumWindows, result_tabs->GetSize()); |
+ for (size_t i = 0; i < result_tabs->GetSize(); ++i) { |
+ base::DictionaryValue* result_tab = NULL; |
+ EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab)); |
+ result_ids.insert(utils::GetInteger(result_tab, keys::kWindowIdKey)); |
+ } |
+ EXPECT_EQ(window_ids, result_ids); |
+ |
+ DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
+} |
+ |
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) { |
// Test creates new popup window, closes it right away and then tries to open |
// a new tab in it. Tab should not be opened in the popup window, but in a |