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

Unified Diff: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc

Issue 25305002: Implement initial chrome.browserAction.openPopup API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 7 years, 2 months 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698