Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / extensions / extension_tabs_apitest.cc
blobe75bf4713525e551433f9d0402382e2d7535fa1f
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
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/prefs/incognito_mode_prefs.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/pref_names.h"
14 #include "chrome/common/url_constants.h"
15 #include "net/dns/mock_host_resolver.h"
17 #if defined(OS_WIN)
18 #include "ui/aura/window.h"
19 #include "ui/aura/window_tree_host.h"
20 #endif
22 #if defined(USE_AURA) || defined(OS_MACOSX)
23 // Maximizing/fullscreen popup window doesn't work on aura's managed mode.
24 // See bug crbug.com/116305.
25 // Mac: http://crbug.com/103912
26 #define MAYBE_UpdateWindowShowState DISABLED_UpdateWindowShowState
27 #else
28 #define MAYBE_UpdateWindowShowState UpdateWindowShowState
29 #endif // defined(USE_AURA) || defined(OS_MACOSX)
31 // http://crbug.com/145639
32 #if defined(OS_LINUX) || defined(OS_WIN)
33 #define MAYBE_TabEvents DISABLED_TabEvents
34 #else
35 #define MAYBE_TabEvents TabEvents
36 #endif
38 class ExtensionApiNewTabTest : public ExtensionApiTest {
39 public:
40 ExtensionApiNewTabTest() {}
41 void SetUpCommandLine(base::CommandLine* command_line) override {
42 ExtensionApiTest::SetUpCommandLine(command_line);
43 // Override the default which InProcessBrowserTest adds if it doesn't see a
44 // homepage.
45 command_line->AppendSwitchASCII(
46 switches::kHomePage, chrome::kChromeUINewTabURL);
50 IN_PROC_BROWSER_TEST_F(ExtensionApiNewTabTest, Tabs) {
51 // The test creates a tab and checks that the URL of the new tab
52 // is that of the new tab page. Make sure the pref that controls
53 // this is set.
54 browser()->profile()->GetPrefs()->SetBoolean(
55 prefs::kHomePageIsNewTabPage, true);
57 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "crud.html")) << message_;
60 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabAudible) {
61 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "audible.html")) << message_;
64 // http://crbug.com/521410
65 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_TabMuted) {
66 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "muted.html")) << message_;
69 // Flaky on windows: http://crbug.com/238667
70 #if defined(OS_WIN)
71 #define MAYBE_Tabs2 DISABLED_Tabs2
72 #else
73 #define MAYBE_Tabs2 Tabs2
74 #endif
75 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Tabs2) {
76 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "crud2.html")) << message_;
79 // crbug.com/149924
80 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_TabDuplicate) {
81 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "duplicate.html")) << message_;
84 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabSize) {
85 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "tab_size.html")) << message_;
88 // Flaky on linux: http://crbug.com/396364
89 #if defined(OS_LINUX)
90 #define MAYBE_TabUpdate DISABLED_TabUpdate
91 #else
92 #define MAYBE_TabUpdate TabUpdate
93 #endif
94 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_TabUpdate) {
95 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "update.html")) << message_;
98 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabPinned) {
99 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "pinned.html")) << message_;
102 // Flaky on windows: http://crbug.com/238667
103 #if defined(OS_WIN)
104 #define MAYBE_TabMove DISABLED_TabMove
105 #else
106 #define MAYBE_TabMove TabMove
107 #endif
108 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_TabMove) {
109 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "move.html")) << message_;
112 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_TabEvents) {
113 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "events.html")) << message_;
116 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_TabRelativeURLs) {
117 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "relative_urls.html"))
118 << message_;
121 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabQuery) {
122 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "query.html")) << message_;
125 // Flaky on windows: http://crbug.com/239022
126 #if defined(OS_WIN)
127 #define MAYBE_TabHighlight DISABLED_TabHighlight
128 #else
129 #define MAYBE_TabHighlight TabHighlight
130 #endif
131 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_TabHighlight) {
132 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "highlight.html")) << message_;
135 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabCrashBrowser) {
136 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "crash.html")) << message_;
139 // Flaky on windows: http://crbug.com/238667
140 #if defined(OS_WIN)
141 #define MAYBE_TabOpener DISABLED_TabOpener
142 #else
143 #define MAYBE_TabOpener TabOpener
144 #endif
145 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_TabOpener) {
146 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "opener.html")) << message_;
149 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_TabGetCurrent) {
150 ASSERT_TRUE(RunExtensionTest("tabs/get_current")) << message_;
153 // Flaky on the trybots. See http://crbug.com/96725.
154 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_TabConnect) {
155 ASSERT_TRUE(StartEmbeddedTestServer());
156 ASSERT_TRUE(RunExtensionTest("tabs/connect")) << message_;
159 // Possible race in ChromeURLDataManager. http://crbug.com/59198
160 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_TabOnRemoved) {
161 ASSERT_TRUE(RunExtensionTest("tabs/on_removed")) << message_;
164 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_TabReload) {
165 ASSERT_TRUE(RunExtensionTest("tabs/reload")) << message_;
168 class ExtensionApiCaptureTest : public ExtensionApiTest {
169 public:
170 ExtensionApiCaptureTest() {}
172 void SetUp() override {
173 EnablePixelOutput();
174 ExtensionApiTest::SetUp();
177 void SetUpCommandLine(base::CommandLine* command_line) override {
178 ExtensionApiTest::SetUpCommandLine(command_line);
182 IN_PROC_BROWSER_TEST_F(ExtensionApiCaptureTest,
183 DISABLED_CaptureVisibleTabJpeg) {
184 host_resolver()->AddRule("a.com", "127.0.0.1");
185 host_resolver()->AddRule("b.com", "127.0.0.1");
186 ASSERT_TRUE(StartEmbeddedTestServer());
187 ASSERT_TRUE(RunExtensionSubtest("tabs/capture_visible_tab",
188 "test_jpeg.html")) << message_;
191 IN_PROC_BROWSER_TEST_F(ExtensionApiCaptureTest, DISABLED_CaptureVisibleTabPng) {
192 host_resolver()->AddRule("a.com", "127.0.0.1");
193 host_resolver()->AddRule("b.com", "127.0.0.1");
194 ASSERT_TRUE(StartEmbeddedTestServer());
195 ASSERT_TRUE(RunExtensionSubtest("tabs/capture_visible_tab",
196 "test_png.html")) << message_;
199 // Times out on non-Windows.
200 // See http://crbug.com/80212
201 IN_PROC_BROWSER_TEST_F(ExtensionApiCaptureTest,
202 DISABLED_CaptureVisibleTabRace) {
203 ASSERT_TRUE(RunExtensionSubtest("tabs/capture_visible_tab",
204 "test_race.html")) << message_;
208 // Disabled for being flaky, see http://crbug/367695.
209 IN_PROC_BROWSER_TEST_F(ExtensionApiCaptureTest,
210 DISABLED_CaptureVisibleFile) {
211 ASSERT_TRUE(RunExtensionSubtest("tabs/capture_visible_tab",
212 "test_file.html")) << message_;
215 IN_PROC_BROWSER_TEST_F(ExtensionApiCaptureTest, CaptureVisibleDisabled) {
216 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableScreenshots,
217 true);
218 ASSERT_TRUE(RunExtensionSubtest("tabs/capture_visible_tab",
219 "test_disabled.html")) << message_;
222 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabsOnUpdated) {
223 ASSERT_TRUE(RunExtensionTest("tabs/on_updated")) << message_;
226 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabsNoPermissions) {
227 ASSERT_TRUE(RunExtensionTest("tabs/no_permissions")) << message_;
230 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, UpdateWindowResize) {
231 ASSERT_TRUE(RunExtensionTest("window_update/resize")) << message_;
234 #if defined(OS_WIN)
235 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FocusWindowDoesNotUnmaximize) {
236 HWND window =
237 browser()->window()->GetNativeWindow()->GetHost()->GetAcceleratedWidget();
238 ::SendMessage(window, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
239 ASSERT_TRUE(RunExtensionTest("window_update/focus")) << message_;
240 ASSERT_TRUE(::IsZoomed(window));
242 #endif // OS_WIN
244 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_UpdateWindowShowState) {
245 ASSERT_TRUE(RunExtensionTest("window_update/show_state")) << message_;
248 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoDisabledByPref) {
249 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(),
250 IncognitoModePrefs::DISABLED);
252 // This makes sure that creating an incognito window fails due to pref
253 // (policy) being set.
254 ASSERT_TRUE(RunExtensionTest("tabs/incognito_disabled")) << message_;
257 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_GetViewsOfCreatedPopup) {
258 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "get_views_popup.html"))
259 << message_;
261 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_GetViewsOfCreatedWindow) {
262 ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "get_views_window.html"))
263 << message_;
266 // Adding a new test? Awesome. But API tests are the old hotness. The new
267 // hotness is extension_function_test_utils. See tabs_test.cc for an example.
268 // We are trying to phase out many uses of API tests as they tend to be flaky.