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

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

Issue 1708033002: [Extensions] Don't allow chrome.browserAction.openPopup on popups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2623
Patch Set: Compile fix Created 4 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/extension_action/extension_action_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c8ab70f6f7ad999a2fc9ebda6c5df632bb367776..673765b8296610547a7d307e8932a70a4e0c30e3 100644
--- a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
+++ b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
@@ -17,7 +17,10 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -750,5 +753,42 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionWithRectangularIcon) {
EXPECT_FALSE(gfx::test::AreImagesEqual(first_icon, next_icon));
}
+// Test that we don't try and show a browser action popup with
+// browserAction.openPopup if there is no toolbar (e.g., for web popup windows).
+// Regression test for crbug.com/584747.
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionOpenPopupOnPopup) {
+ // Open a new web popup window.
+ chrome::NavigateParams params(browser(), GURL("http://www.google.com/"),
+ ui::PAGE_TRANSITION_LINK);
+ params.disposition = NEW_POPUP;
+ params.window_action = chrome::NavigateParams::SHOW_WINDOW;
+ ui_test_utils::NavigateToURL(&params);
+ Browser* popup_browser = params.browser;
+ // Verify it is a popup, and it is the active window.
+ ASSERT_TRUE(popup_browser);
+ // The window isn't considered "active" on MacOSX for odd reasons. The more
+ // important test is that it *is* considered the last active browser, since
+ // that's what we check when we try to open the popup.
+#if !defined(OS_MACOSX)
+ EXPECT_TRUE(popup_browser->window()->IsActive());
+#endif
+ EXPECT_FALSE(browser()->window()->IsActive());
+ EXPECT_FALSE(popup_browser->SupportsWindowFeature(Browser::FEATURE_TOOLBAR));
+ EXPECT_EQ(popup_browser,
+ chrome::FindLastActiveWithProfile(browser()->profile(),
+ chrome::GetActiveDesktop()));
+
+ // Load up the extension, which will call chrome.browserAction.openPopup()
+ // when it is loaded and verify that the popup didn't open.
+ ExtensionTestMessageListener listener("ready", true);
+ EXPECT_TRUE(LoadExtension(
+ test_data_dir_.AppendASCII("browser_action/open_popup_on_reply")));
+ EXPECT_TRUE(listener.WaitUntilSatisfied());
+
+ ResultCatcher catcher;
+ listener.Reply(std::string());
+ EXPECT_TRUE(catcher.GetNextResult()) << message_;
+}
+
} // namespace
} // namespace extensions
« no previous file with comments | « no previous file | chrome/browser/extensions/api/extension_action/extension_action_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698