| OLD | NEW |
| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 #if defined(USE_ASH) | 203 #if defined(USE_ASH) |
| 204 // On Ash, this currently fails because we're currently opening new panel | 204 // On Ash, this currently fails because we're currently opening new panel |
| 205 // windows as popup windows instead. | 205 // windows as popup windows instead. |
| 206 #define MAYBE_WindowOpenPanel FAILS_WindowOpenPanel | 206 #define MAYBE_WindowOpenPanel FAILS_WindowOpenPanel |
| 207 #else | 207 #else |
| 208 #define MAYBE_WindowOpenPanel WindowOpenPanel | 208 #define MAYBE_WindowOpenPanel WindowOpenPanel |
| 209 #endif | 209 #endif |
| 210 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenPanel) { | 210 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenPanel) { |
| 211 if (!PanelManager::UseBrowserlessPanels()) | |
| 212 return; | |
| 213 ASSERT_TRUE(RunExtensionTest("window_open/panel")) << message_; | 211 ASSERT_TRUE(RunExtensionTest("window_open/panel")) << message_; |
| 214 } | 212 } |
| 215 | 213 |
| 216 #if defined(USE_ASH) | 214 #if defined(USE_ASH) |
| 217 // On Ash, this currently fails because we're currently opening new panel | 215 // On Ash, this currently fails because we're currently opening new panel |
| 218 // windows as popup windows instead. | 216 // windows as popup windows instead. |
| 219 #define MAYBE_WindowOpenPanelDetached FAILS_WindowOpenPanelDetached | 217 #define MAYBE_WindowOpenPanelDetached FAILS_WindowOpenPanelDetached |
| 220 #else | 218 #else |
| 221 #define MAYBE_WindowOpenPanelDetached WindowOpenPanelDetached | 219 #define MAYBE_WindowOpenPanelDetached WindowOpenPanelDetached |
| 222 #endif | 220 #endif |
| 223 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenPanelDetached) { | 221 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenPanelDetached) { |
| 224 if (!PanelManager::UseBrowserlessPanels()) | |
| 225 return; | |
| 226 ASSERT_TRUE(RunExtensionTest("window_open/panel_detached")) << message_; | 222 ASSERT_TRUE(RunExtensionTest("window_open/panel_detached")) << message_; |
| 227 } | 223 } |
| 228 | 224 |
| 229 #if defined(OS_MACOSX) || defined(OS_WIN) | 225 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 230 // Focus test fails if there is no window manager on Linux. | 226 // Focus test fails if there is no window manager on Linux. |
| 231 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, WindowOpenFocus) { | 227 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, WindowOpenFocus) { |
| 232 if (!PanelManager::UseBrowserlessPanels()) | |
| 233 return; | |
| 234 ASSERT_TRUE(RunExtensionTest("window_open/focus")) << message_; | 228 ASSERT_TRUE(RunExtensionTest("window_open/focus")) << message_; |
| 235 } | 229 } |
| 236 #endif | 230 #endif |
| 237 | 231 |
| 238 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, | 232 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, |
| 239 CloseNonExtensionPanelsOnUninstall) { | 233 CloseNonExtensionPanelsOnUninstall) { |
| 240 if (!PanelManager::UseBrowserlessPanels()) | |
| 241 return; | |
| 242 #if defined(USE_ASH) | 234 #if defined(USE_ASH) |
| 243 // On Ash, new panel windows open as popup windows instead. | 235 // On Ash, new panel windows open as popup windows instead. |
| 244 int num_popups = 4; | 236 int num_popups = 4; |
| 245 int num_panels = 0; | 237 int num_panels = 0; |
| 246 #else | 238 #else |
| 247 int num_popups = 2; | 239 int num_popups = 2; |
| 248 int num_panels = 2; | 240 int num_panels = 2; |
| 249 #endif | 241 #endif |
| 250 ASSERT_TRUE(StartTestServer()); | 242 ASSERT_TRUE(StartTestServer()); |
| 251 | 243 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 271 // Two popups - one in extension domain and one in non-extension domain. | 263 // Two popups - one in extension domain and one in non-extension domain. |
| 272 // Two panels - one in extension domain and one in non-extension domain. | 264 // Two panels - one in extension domain and one in non-extension domain. |
| 273 WaitForTabsAndPopups(browser(), 2, num_popups, num_panels); | 265 WaitForTabsAndPopups(browser(), 2, num_popups, num_panels); |
| 274 | 266 |
| 275 // Wait on test messages to make sure the pages loaded. | 267 // Wait on test messages to make sure the pages loaded. |
| 276 for (size_t i = 0; i < listeners.size(); ++i) | 268 for (size_t i = 0; i < listeners.size(); ++i) |
| 277 ASSERT_TRUE(listeners[i]->WaitUntilSatisfied()); | 269 ASSERT_TRUE(listeners[i]->WaitUntilSatisfied()); |
| 278 | 270 |
| 279 UninstallExtension(extension->id()); | 271 UninstallExtension(extension->id()); |
| 280 | 272 |
| 281 // Wait for one tab and one popup in non-extension domain to stay open. | 273 // Wait for the tabs and popups in non-extension domain to stay open. |
| 282 // Expect everything else, including panels, to close. | 274 // Expect everything else, including panels, to close. |
| 283 num_popups = 1; | 275 #if defined(USE_ASH) |
| 276 // On Ash, new panel windows open as popup windows instead, so there are 2 |
| 277 // extension domain popups that will close (instead of 1 popup on non-Ash). |
| 278 num_popups -= 2; |
| 279 #else |
| 280 num_popups -= 1; |
| 281 #endif |
| 284 WaitForTabsAndPopups(browser(), 1, num_popups, 0); | 282 WaitForTabsAndPopups(browser(), 1, num_popups, 0); |
| 285 } | 283 } |
| 286 | 284 |
| 287 #if defined(USE_ASH) | 285 #if defined(USE_ASH) |
| 288 // This test is not applicable on Ash. Ash opens panel windows as popup | 286 // This test is not applicable on Ash. Ash opens panel windows as popup |
| 289 // windows. The modified window.open behavior only applies to panel windows. | 287 // windows. The modified window.open behavior only applies to panel windows. |
| 290 #define MAYBE_WindowOpenFromPanel DISABLED_WindowOpenFromPanel | 288 #define MAYBE_WindowOpenFromPanel DISABLED_WindowOpenFromPanel |
| 291 #else | 289 #else |
| 292 #define MAYBE_WindowOpenFromPanel WindowOpenFromPanel | 290 #define MAYBE_WindowOpenFromPanel WindowOpenFromPanel |
| 293 #endif | 291 #endif |
| 294 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenFromPanel) { | 292 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenFromPanel) { |
| 295 if (!PanelManager::UseBrowserlessPanels()) | |
| 296 return; | |
| 297 | |
| 298 ASSERT_TRUE(StartTestServer()); | 293 ASSERT_TRUE(StartTestServer()); |
| 299 | 294 |
| 300 // Load the extension that will open a panel which then calls window.open. | 295 // Load the extension that will open a panel which then calls window.open. |
| 301 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("window_open"). | 296 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("window_open"). |
| 302 AppendASCII("panel_window_open"))); | 297 AppendASCII("panel_window_open"))); |
| 303 | 298 |
| 304 // Expect one panel (opened by extension) and one tab (from the panel calling | 299 // Expect one panel (opened by extension) and one tab (from the panel calling |
| 305 // window.open). Panels modify the WindowOpenDisposition in window.open | 300 // window.open). Panels modify the WindowOpenDisposition in window.open |
| 306 // to always open in a tab. | 301 // to always open in a tab. |
| 307 WaitForTabsAndPopups(browser(), 1, 0, 1); | 302 WaitForTabsAndPopups(browser(), 1, 0, 1); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()), | 354 ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()), |
| 360 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ + | 355 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ + |
| 361 "/newtab.html"), false, &newtab)); | 356 "/newtab.html"), false, &newtab)); |
| 362 | 357 |
| 363 // Extension API should succeed. | 358 // Extension API should succeed. |
| 364 bool result = false; | 359 bool result = false; |
| 365 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 360 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 366 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); | 361 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); |
| 367 EXPECT_TRUE(result); | 362 EXPECT_TRUE(result); |
| 368 } | 363 } |
| OLD | NEW |