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

Side by Side Diff: chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc

Issue 119633002: Close ExtensionPopup on tab switches; add test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecessary NULL checks. Created 7 years 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 | « no previous file | chrome/browser/ui/views/extensions/extension_popup.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/extensions/browser_action_test_util.h" 5 #include "chrome/browser/extensions/browser_action_test_util.h"
6 #include "chrome/browser/extensions/extension_action.h" 6 #include "chrome/browser/extensions/extension_action.h"
7 #include "chrome/browser/extensions/extension_action_manager.h" 7 #include "chrome/browser/extensions/extension_action_manager.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
11 #include "chrome/browser/extensions/extension_tab_util.h" 11 #include "chrome/browser/extensions/extension_tab_util.h"
12 #include "chrome/browser/extensions/extension_test_message_listener.h" 12 #include "chrome/browser/extensions/extension_test_message_listener.h"
13 #include "chrome/browser/ui/browser_commands.h"
13 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/test/base/interactive_test_utils.h" 17 #include "chrome/test/base/interactive_test_utils.h"
17 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
18 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "extensions/common/permissions/permissions_data.h" 21 #include "extensions/common/permissions/permissions_data.h"
21 22
22 namespace extensions { 23 namespace extensions {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 content::NotificationService::AllSources()); 232 content::NotificationService::AllSources());
232 BrowserActionTestUtil(browser()).Press(0); 233 BrowserActionTestUtil(browser()).Press(0);
233 frame_observer.Wait(); 234 frame_observer.Wait();
234 EXPECT_TRUE(BrowserActionTestUtil(browser()).HasPopup()); 235 EXPECT_TRUE(BrowserActionTestUtil(browser()).HasPopup());
235 236
236 // Click on the omnibox to close the extension popup. 237 // Click on the omnibox to close the extension popup.
237 ui_test_utils::ClickOnView(browser(), VIEW_ID_OMNIBOX); 238 ui_test_utils::ClickOnView(browser(), VIEW_ID_OMNIBOX);
238 EXPECT_FALSE(BrowserActionTestUtil(browser()).HasPopup()); 239 EXPECT_FALSE(BrowserActionTestUtil(browser()).HasPopup());
239 } 240 }
240 241
242 // Test that the extension popup is closed on browser tab switches.
243 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, TabSwitchClosesPopup) {
244 if (!ShouldRunPopupTest())
245 return;
246
247 // Add a second tab to the browser.
248 chrome::NewTab(browser());
249 ASSERT_EQ(2, browser()->tab_strip_model()->count());
250
251 // Open an extension popup via the chrome.browserAction.openPopup API.
252 content::WindowedNotificationObserver frame_observer(
253 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
254 content::NotificationService::AllSources());
255 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup",
256 "open_popup_succeeds.html")) << message_;
257 frame_observer.Wait();
258 EXPECT_TRUE(BrowserActionTestUtil(browser()).HasPopup());
259
260 // Press CTRL+TAB to change active tabs, the extension popup should close.
261 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
262 browser(), ui::VKEY_TAB, true, false, false, false));
263 EXPECT_FALSE(BrowserActionTestUtil(browser()).HasPopup());
264 }
265
241 } // namespace 266 } // namespace
242 } // namespace extensions 267 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/extensions/extension_popup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698