Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_test.cc

Issue 1239643004: extensions: tabs: set tab id to -1 for app/devtools windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test chrome.tabs events Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 5
6 #include <string> 6 #include <string>
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/pattern.h" 11 #include "base/strings/pattern.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/devtools/devtools_window_testing.h" 16 #include "chrome/browser/devtools/devtools_window_testing.h"
17 #include "chrome/browser/extensions/api/tabs/tabs_api.h" 17 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
18 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 18 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
19 #include "chrome/browser/extensions/extension_apitest.h"
19 #include "chrome/browser/extensions/extension_function_test_utils.h" 20 #include "chrome/browser/extensions/extension_function_test_utils.h"
20 #include "chrome/browser/extensions/extension_tab_util.h" 21 #include "chrome/browser/extensions/extension_tab_util.h"
21 #include "chrome/browser/extensions/window_controller.h" 22 #include "chrome/browser/extensions/window_controller.h"
22 #include "chrome/browser/prefs/incognito_mode_prefs.h" 23 #include "chrome/browser/prefs/incognito_mode_prefs.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_commands.h" 26 #include "chrome/browser/ui/browser_commands.h"
26 #include "chrome/browser/ui/browser_window.h" 27 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" 28 #include "chrome/browser/ui/tabs/tab_strip_model.h"
28 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" 29 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
29 #include "chrome/test/base/in_process_browser_test.h"
30 #include "chrome/test/base/ui_test_utils.h" 30 #include "chrome/test/base/ui_test_utils.h"
31 #include "content/public/browser/browser_context.h" 31 #include "content/public/browser/browser_context.h"
32 #include "content/public/browser/storage_partition.h" 32 #include "content/public/browser/storage_partition.h"
33 #include "content/public/common/page_zoom.h" 33 #include "content/public/common/page_zoom.h"
34 #include "content/public/common/url_constants.h" 34 #include "content/public/common/url_constants.h"
35 #include "extensions/browser/api_test_utils.h" 35 #include "extensions/browser/api_test_utils.h"
36 #include "extensions/common/manifest_constants.h" 36 #include "extensions/common/manifest_constants.h"
37 #include "extensions/common/test_util.h" 37 #include "extensions/common/test_util.h"
38 #include "extensions/test/extension_test_message_listener.h"
39 #include "extensions/test/result_catcher.h"
38 #include "net/test/spawned_test_server/spawned_test_server.h" 40 #include "net/test/spawned_test_server/spawned_test_server.h"
39 #include "ui/gfx/geometry/rect.h" 41 #include "ui/gfx/geometry/rect.h"
40 42
41 namespace extensions { 43 namespace extensions {
42 44
43 namespace keys = tabs_constants; 45 namespace keys = tabs_constants;
44 namespace utils = extension_function_test_utils; 46 namespace utils = extension_function_test_utils;
45 47
46 namespace { 48 namespace {
47 using ExtensionTabsTest = InProcessBrowserTest; 49 using ExtensionTabsTest = ExtensionApiTest;
48 50
49 class ExtensionWindowCreateTest : public InProcessBrowserTest { 51 class ExtensionWindowCreateTest : public InProcessBrowserTest {
50 public: 52 public:
51 // Runs chrome.windows.create(), expecting an error. 53 // Runs chrome.windows.create(), expecting an error.
52 std::string RunCreateWindowExpectError(const std::string& args) { 54 std::string RunCreateWindowExpectError(const std::string& args) {
53 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction); 55 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction);
54 function->set_extension(test_util::CreateEmptyExtension().get()); 56 function->set_extension(test_util::CreateEmptyExtension().get());
55 return api_test_utils::RunFunctionAndReturnError(function.get(), args, 57 return api_test_utils::RunFunctionAndReturnError(function.get(), args,
56 browser()->profile()); 58 browser()->profile());
57 } 59 }
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 EXPECT_EQ(base::Value::TYPE_DICTIONARY, duplicate_result->GetType()); 738 EXPECT_EQ(base::Value::TYPE_DICTIONARY, duplicate_result->GetType());
737 // Duplicate tab id should be different from the original tab id. 739 // Duplicate tab id should be different from the original tab id.
738 EXPECT_NE(tab_id, duplicate_tab_id); 740 EXPECT_NE(tab_id, duplicate_tab_id);
739 EXPECT_EQ(window_id, duplicate_tab_window_id); 741 EXPECT_EQ(window_id, duplicate_tab_window_id);
740 EXPECT_EQ(tab_index + 1, duplicate_tab_index); 742 EXPECT_EQ(tab_index + 1, duplicate_tab_index);
741 // The test empty extension has no permissions, therefore |duplicate_result| 743 // The test empty extension has no permissions, therefore |duplicate_result|
742 // should not contain url, title, and faviconUrl in the function result. 744 // should not contain url, title, and faviconUrl in the function result.
743 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); 745 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get()));
744 } 746 }
745 747
748 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, NoTabsEventOnDevTools) {
749 extensions::ResultCatcher catcher;
750 ExtensionTestMessageListener listener("ready", true);
751 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("tabs/no_events")));
752 ASSERT_TRUE(listener.WaitUntilSatisfied());
753
754 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync(
755 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */);
756
757 listener.Reply("stop");
758
759 ASSERT_TRUE(catcher.GetNextResult());
760
761 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools);
762 }
763
746 // Tester class for the tabs.zoom* api functions. 764 // Tester class for the tabs.zoom* api functions.
747 class ExtensionTabsZoomTest : public ExtensionTabsTest { 765 class ExtensionTabsZoomTest : public ExtensionTabsTest {
748 public: 766 public:
749 void SetUpOnMainThread() override; 767 void SetUpOnMainThread() override;
750 768
751 // Runs chrome.tabs.setZoom(). 769 // Runs chrome.tabs.setZoom().
752 bool RunSetZoom(int tab_id, double zoom_factor); 770 bool RunSetZoom(int tab_id, double zoom_factor);
753 771
754 // Runs chrome.tabs.getZoom(). 772 // Runs chrome.tabs.getZoom().
755 testing::AssertionResult RunGetZoom(int tab_id, double* zoom_factor); 773 testing::AssertionResult RunGetZoom(int tab_id, double* zoom_factor);
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 EXPECT_TRUE( 1196 EXPECT_TRUE(
1179 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); 1197 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl));
1180 1198
1181 // chrome.tabs.setZoomSettings(). 1199 // chrome.tabs.setZoomSettings().
1182 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); 1200 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab");
1183 EXPECT_TRUE( 1201 EXPECT_TRUE(
1184 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); 1202 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl));
1185 } 1203 }
1186 1204
1187 } // namespace extensions 1205 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698