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

Side by Side Diff: chrome/browser/extensions/window_open_apitest.cc

Issue 10689071: Deprecate --aura-panels (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_test_message_listener.h" 9 #include "chrome/browser/extensions/extension_test_message_listener.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 ASSERT_TRUE(RunExtensionTest("window_open/panel_not_enabled")) << message_; 188 ASSERT_TRUE(RunExtensionTest("window_open/panel_not_enabled")) << message_;
189 } 189 }
190 190
191 class WindowOpenPanelTest : public ExtensionApiTest { 191 class WindowOpenPanelTest : public ExtensionApiTest {
192 virtual void SetUpCommandLine(CommandLine* command_line) { 192 virtual void SetUpCommandLine(CommandLine* command_line) {
193 ExtensionApiTest::SetUpCommandLine(command_line); 193 ExtensionApiTest::SetUpCommandLine(command_line);
194 command_line->AppendSwitch(switches::kEnablePanels); 194 command_line->AppendSwitch(switches::kEnablePanels);
195 } 195 }
196 }; 196 };
197 197
198 #if defined(USE_AURA) 198 #if defined(USE_ASH)
199 // On Aura, this currently fails because we're currently opening new panel 199 // On Ash, this currently fails because we're currently opening new panel
200 // windows as popup windows instead. 200 // windows as popup windows instead.
201 #define MAYBE_WindowOpenPanel FAILS_WindowOpenPanel 201 #define MAYBE_WindowOpenPanel FAILS_WindowOpenPanel
202 #else 202 #else
203 #define MAYBE_WindowOpenPanel WindowOpenPanel 203 #define MAYBE_WindowOpenPanel WindowOpenPanel
204 #endif 204 #endif
205 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenPanel) { 205 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenPanel) {
206 ASSERT_TRUE(RunExtensionTest("window_open/panel")) << message_; 206 ASSERT_TRUE(RunExtensionTest("window_open/panel")) << message_;
207 } 207 }
208 208
209 #if defined(OS_MACOSX) || defined(OS_WIN) 209 #if defined(OS_MACOSX) || defined(OS_WIN)
210 // Focus test fails if there is no window manager on Linux. 210 // Focus test fails if there is no window manager on Linux.
211 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, WindowOpenFocus) { 211 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, WindowOpenFocus) {
212 ASSERT_TRUE(RunExtensionTest("window_open/focus")) << message_; 212 ASSERT_TRUE(RunExtensionTest("window_open/focus")) << message_;
213 } 213 }
214 #endif 214 #endif
215 215
216 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, 216 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest,
217 CloseNonExtensionPanelsOnUninstall) { 217 CloseNonExtensionPanelsOnUninstall) {
218 #if defined(USE_ASH)
219 int num_popups = 4;
220 int num_panels = 0;
221 #else
222 int num_popups = 2;
223 int num_panels = 2;
224 #endif
218 ASSERT_TRUE(StartTestServer()); 225 ASSERT_TRUE(StartTestServer());
219 226
220 // Setup listeners to wait on strings we expect the extension pages to send. 227 // Setup listeners to wait on strings we expect the extension pages to send.
221 std::vector<std::string> test_strings; 228 std::vector<std::string> test_strings;
222 test_strings.push_back("content_tab"); 229 test_strings.push_back("content_tab");
223 test_strings.push_back("content_panel"); 230 if (num_panels)
231 test_strings.push_back("content_panel");
224 test_strings.push_back("content_popup"); 232 test_strings.push_back("content_popup");
225 233
226 ScopedVector<ExtensionTestMessageListener> listeners; 234 ScopedVector<ExtensionTestMessageListener> listeners;
227 for (size_t i = 0; i < test_strings.size(); ++i) { 235 for (size_t i = 0; i < test_strings.size(); ++i) {
228 listeners.push_back( 236 listeners.push_back(
229 new ExtensionTestMessageListener(test_strings[i], false)); 237 new ExtensionTestMessageListener(test_strings[i], false));
230 } 238 }
231 239
232 const extensions::Extension* extension = LoadExtension( 240 const extensions::Extension* extension = LoadExtension(
233 test_data_dir_.AppendASCII("window_open").AppendASCII( 241 test_data_dir_.AppendASCII("window_open").AppendASCII(
234 "close_panels_on_uninstall")); 242 "close_panels_on_uninstall"));
235 ASSERT_TRUE(extension); 243 ASSERT_TRUE(extension);
236 244
237 // Two tabs. One in extension domain and one in non-extension domain. 245 // Two tabs. One in extension domain and one in non-extension domain.
238 // Two popups - one in extension domain and one in non-extension domain. 246 // Two popups - one in extension domain and one in non-extension domain.
239 // Two panels - one in extension domain and one in non-extension domain. 247 // Two panels - one in extension domain and one in non-extension domain.
240 WaitForTabsAndPopups(browser(), 2, 2, 2); 248 WaitForTabsAndPopups(browser(), 2, num_popups, num_panels);
241 249
242 // Wait on test messages to make sure the pages loaded. 250 // Wait on test messages to make sure the pages loaded.
243 for (size_t i = 0; i < listeners.size(); ++i) 251 for (size_t i = 0; i < listeners.size(); ++i)
244 ASSERT_TRUE(listeners[i]->WaitUntilSatisfied()); 252 ASSERT_TRUE(listeners[i]->WaitUntilSatisfied());
245 253
246 UninstallExtension(extension->id()); 254 UninstallExtension(extension->id());
247 255
248 // Wait for one tab and one popup in non-extension domain to stay open. 256 // Wait for one tab and one popup in non-extension domain to stay open.
249 // Expect everything else, including panels, to close. 257 // Expect everything else, including panels, to close.
250 WaitForTabsAndPopups(browser(), 1, 1, 0); 258 #if defined(USE_ASH)
259 // In Ash and additional popup remains for the "panel" non-extension domain.
260 num_popups = 2;
261 #else
262 num_popups = 1;
263 #endif
264 WaitForTabsAndPopups(browser(), 1, num_popups, 0);
251 } 265 }
252 266
253 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpener) { 267 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpener) {
254 ASSERT_TRUE(RunExtensionTest("window_open/opener")) << message_; 268 ASSERT_TRUE(RunExtensionTest("window_open/opener")) << message_;
255 } 269 }
256 270
257 // Tests that an extension page can call window.open to an extension URL and 271 // Tests that an extension page can call window.open to an extension URL and
258 // the new window has extension privileges. 272 // the new window has extension privileges.
259 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) { 273 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) {
260 ASSERT_TRUE(LoadExtension( 274 ASSERT_TRUE(LoadExtension(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()), 316 ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()),
303 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ + 317 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ +
304 "/newtab.html"), false, &newtab)); 318 "/newtab.html"), false, &newtab));
305 319
306 // Extension API should succeed. 320 // Extension API should succeed.
307 bool result = false; 321 bool result = false;
308 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 322 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
309 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); 323 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result));
310 EXPECT_TRUE(result); 324 EXPECT_TRUE(result);
311 } 325 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698