Index: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc |
diff --git a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc |
index 06017801b9eabeeadf4879fe04e0e154f337a984..47856d6d9d329cd4b9eb524220de34be2b2d7492 100644 |
--- a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc |
+++ b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc |
@@ -17,14 +17,17 @@ |
#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/extensions/extension_system.h" |
#include "chrome/browser/extensions/extension_tab_util.h" |
+#include "chrome/browser/extensions/extension_test_message_listener.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_commands.h" |
#include "chrome/browser/ui/browser_window.h" |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
+#include "chrome/common/extensions/features/feature_channel.h" |
#include "chrome/common/url_constants.h" |
#include "chrome/test/base/ui_test_utils.h" |
#include "content/public/browser/notification_service.h" |
+#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/test/browser_test_utils.h" |
#include "grit/theme_resources.h" |
@@ -693,5 +696,100 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, TestTriggerBrowserAction) { |
EXPECT_EQ(result, "red"); |
} |
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, TestBrowserActionOpenPopup) { |
+ ScopedCurrentChannel current_channel(chrome::VersionInfo::CHANNEL_DEV); |
+ |
+ |
+ ExtensionTestMessageListener listener("ready", true); |
+ |
+ { |
+ // Show first popup in original window and expect it to have loaded. |
+ content::WindowedNotificationObserver frame_observer( |
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
+ content::NotificationService::AllSources()); |
+ |
+ ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", |
+ "open_popup_succeeds.html")) << message_; |
+ frame_observer.Wait(); |
+ EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
+ } |
+ |
+ EXPECT_TRUE(listener.WaitUntilSatisfied()); |
+ |
+ { |
+ // Open a new window. |
+ content::WindowedNotificationObserver frame_observer( |
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
+ content::NotificationService::AllSources()); |
+ browser()->OpenURL(content::OpenURLParams( |
+ GURL("about:"), content::Referrer(), NEW_WINDOW, |
+ content::PAGE_TRANSITION_TYPED, false)); |
+ frame_observer.Wait(); |
+ } |
+ |
+ // Show second popup in new window. |
+ listener.Reply(""); |
+ |
+ { |
+ // Expect popup to have loaded. |
+ content::WindowedNotificationObserver frame_observer( |
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
+ content::NotificationService::AllSources()); |
+ frame_observer.Wait(); |
+ EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
+ } |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
+ TestBrowserActionOpenPopupIncognito) { |
+ content::WindowedNotificationObserver frame_observer( |
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
+ content::NotificationService::AllSources()); |
+ ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", |
+ "open_popup_succeeds.html", |
+ kFlagEnableIncognito | kFlagUseIncognito)) |
+ << message_; |
+ frame_observer.Wait(); |
+ EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
+} |
+ |
+// Test that the popup does not show in an incognito if extension is not enabled |
+// for incognito. |
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
+ TestBrowserActionOpenPopupIncognitoNotAllowed) { |
+ { |
+ // Open an incognito window. |
+ content::WindowedNotificationObserver frame_observer( |
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
+ content::NotificationService::AllSources()); |
+ browser()->OpenURL(content::OpenURLParams( |
+ GURL("about:"), content::Referrer(), OFF_THE_RECORD, |
+ content::PAGE_TRANSITION_TYPED, false)); |
+ frame_observer.Wait(); |
+ } |
+ |
+ { |
+ // Load popup. |
+ // TODO(justinlin): Check that it opened in the non-incognito window. |
+ content::WindowedNotificationObserver frame_observer( |
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
+ content::NotificationService::AllSources()); |
+ ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", |
+ "open_popup_succeeds.html")) << message_; |
+ frame_observer.Wait(); |
+ EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
+ } |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
+ TestBrowserActionOpenPopupButtonHidden) { |
+ // TODO(justinlin): Implement. |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
+ TestBrowserActionOpenPopupNoWindows) { |
+ // TODO(justinlin): Implement. |
+} |
+ |
} // namespace |
} // namespace extensions |