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..0bd83ae00a69c4b447af3ff214aaaa4296ab4e02 100644 |
--- a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc |
+++ b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc |
@@ -693,5 +693,106 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, TestTriggerBrowserAction) { |
EXPECT_EQ(result, "red"); |
} |
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, TestBrowserActionOpenPopup) { |
+ 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, |
+ TestBrowserActionOpenPopupDoesNotCloseOtherPopups) { |
+ // TODO(justinlin): Implement. |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
+ TestBrowserActionOpenPopupButtonHidden) { |
+ // TODO(justinlin): Implement. |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
+ TestBrowserActionOpenPopupNoWindows) { |
+ // TODO(justinlin): Implement. |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
+ TestBrowserActionOpenPopupDoesNotGrant) { |
+ // TODO(justinlin): Implement |
+} |
+ |
} // namespace |
} // namespace extensions |