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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 if (!PanelManager::UseBrowserlessPanels()) | 213 if (!PanelManager::UseBrowserlessPanels()) |
214 return; | 214 return; |
215 ASSERT_TRUE(RunExtensionTest("window_open/focus")) << message_; | 215 ASSERT_TRUE(RunExtensionTest("window_open/focus")) << message_; |
216 } | 216 } |
217 #endif | 217 #endif |
218 | 218 |
219 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, | 219 IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, |
220 CloseNonExtensionPanelsOnUninstall) { | 220 CloseNonExtensionPanelsOnUninstall) { |
221 if (!PanelManager::UseBrowserlessPanels()) | 221 if (!PanelManager::UseBrowserlessPanels()) |
222 return; | 222 return; |
223 #if defined(USE_ASH) | |
224 int num_popups = 4; | |
225 int num_panels = 0; | |
226 #else | |
227 int num_popups = 2; | 223 int num_popups = 2; |
228 int num_panels = 2; | 224 int num_panels = 2; |
229 #endif | |
230 ASSERT_TRUE(StartTestServer()); | 225 ASSERT_TRUE(StartTestServer()); |
231 | 226 |
232 // 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. |
233 std::vector<std::string> test_strings; | 228 std::vector<std::string> test_strings; |
234 test_strings.push_back("content_tab"); | 229 test_strings.push_back("content_tab"); |
235 if (num_panels) | 230 if (num_panels) |
236 test_strings.push_back("content_panel"); | 231 test_strings.push_back("content_panel"); |
237 test_strings.push_back("content_popup"); | 232 test_strings.push_back("content_popup"); |
238 | 233 |
239 ScopedVector<ExtensionTestMessageListener> listeners; | 234 ScopedVector<ExtensionTestMessageListener> listeners; |
(...skipping 13 matching lines...) Expand all Loading... |
253 WaitForTabsAndPopups(browser(), 2, num_popups, num_panels); | 248 WaitForTabsAndPopups(browser(), 2, num_popups, num_panels); |
254 | 249 |
255 // Wait on test messages to make sure the pages loaded. | 250 // Wait on test messages to make sure the pages loaded. |
256 for (size_t i = 0; i < listeners.size(); ++i) | 251 for (size_t i = 0; i < listeners.size(); ++i) |
257 ASSERT_TRUE(listeners[i]->WaitUntilSatisfied()); | 252 ASSERT_TRUE(listeners[i]->WaitUntilSatisfied()); |
258 | 253 |
259 UninstallExtension(extension->id()); | 254 UninstallExtension(extension->id()); |
260 | 255 |
261 // 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. |
262 // Expect everything else, including panels, to close. | 257 // Expect everything else, including panels, to close. |
263 #if defined(USE_ASH) | |
264 // In Ash and additional popup remains for the "panel" non-extension domain. | |
265 num_popups = 2; | |
266 #else | |
267 num_popups = 1; | 258 num_popups = 1; |
268 #endif | |
269 WaitForTabsAndPopups(browser(), 1, num_popups, 0); | 259 WaitForTabsAndPopups(browser(), 1, num_popups, 0); |
270 } | 260 } |
271 | 261 |
272 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpener) { | 262 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpener) { |
273 ASSERT_TRUE(RunExtensionTest("window_open/opener")) << message_; | 263 ASSERT_TRUE(RunExtensionTest("window_open/opener")) << message_; |
274 } | 264 } |
275 | 265 |
276 // Tests that an extension page can call window.open to an extension URL and | 266 // Tests that an extension page can call window.open to an extension URL and |
277 // the new window has extension privileges. | 267 // the new window has extension privileges. |
278 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) { | 268 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()), | 311 ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()), |
322 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ + | 312 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ + |
323 "/newtab.html"), false, &newtab)); | 313 "/newtab.html"), false, &newtab)); |
324 | 314 |
325 // Extension API should succeed. | 315 // Extension API should succeed. |
326 bool result = false; | 316 bool result = false; |
327 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 317 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
328 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); | 318 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); |
329 EXPECT_TRUE(result); | 319 EXPECT_TRUE(result); |
330 } | 320 } |
OLD | NEW |