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

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

Issue 1683433002: [Extensions] Don't allow chrome.browserAction.openPopup on popups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
10 #include "chrome/browser/extensions/browser_action_test_util.h" 10 #include "chrome/browser/extensions/browser_action_test_util.h"
11 #include "chrome/browser/extensions/extension_action.h" 11 #include "chrome/browser/extensions/extension_action.h"
12 #include "chrome/browser/extensions/extension_action_icon_factory.h" 12 #include "chrome/browser/extensions/extension_action_icon_factory.h"
13 #include "chrome/browser/extensions/extension_action_manager.h" 13 #include "chrome/browser/extensions/extension_action_manager.h"
14 #include "chrome/browser/extensions/extension_apitest.h" 14 #include "chrome/browser/extensions/extension_apitest.h"
15 #include "chrome/browser/extensions/extension_tab_util.h" 15 #include "chrome/browser/extensions/extension_tab_util.h"
16 #include "chrome/browser/extensions/extension_util.h" 16 #include "chrome/browser/extensions/extension_util.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_commands.h" 19 #include "chrome/browser/ui/browser_commands.h"
20 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/browser_navigator_params.h"
20 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
23 #include "chrome/test/base/ui_test_utils.h" 25 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/render_frame_host.h" 27 #include "content/public/browser/render_frame_host.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
27 #include "content/public/test/browser_test_utils.h" 29 #include "content/public/test/browser_test_utils.h"
28 #include "extensions/browser/extension_registry.h" 30 #include "extensions/browser/extension_registry.h"
29 #include "extensions/browser/extension_system.h" 31 #include "extensions/browser/extension_system.h"
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 test_data_dir_.AppendASCII("browser_action").AppendASCII("rect_icon"))); 745 test_data_dir_.AppendASCII("browser_action").AppendASCII("rect_icon")));
744 EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); 746 EXPECT_TRUE(ready_listener.WaitUntilSatisfied());
745 gfx::Image first_icon = GetBrowserActionsBar()->GetIcon(0); 747 gfx::Image first_icon = GetBrowserActionsBar()->GetIcon(0);
746 ResultCatcher catcher; 748 ResultCatcher catcher;
747 ready_listener.Reply(std::string()); 749 ready_listener.Reply(std::string());
748 EXPECT_TRUE(catcher.GetNextResult()); 750 EXPECT_TRUE(catcher.GetNextResult());
749 gfx::Image next_icon = GetBrowserActionsBar()->GetIcon(0); 751 gfx::Image next_icon = GetBrowserActionsBar()->GetIcon(0);
750 EXPECT_FALSE(gfx::test::AreImagesEqual(first_icon, next_icon)); 752 EXPECT_FALSE(gfx::test::AreImagesEqual(first_icon, next_icon));
751 } 753 }
752 754
755 // Test that we don't try and show a popup with browserAction.openPopup if there
756 // is no toolbar (e.g., for popup windows).
lazyboy 2016/02/09 00:06:10 Took me a while to figure this one out. Too many
Devlin 2016/02/09 01:19:52 Done.
757 // Regression test for crbug.com/584747.
758 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionOpenPopupOnPopup) {
759 // Open a new popup.
760 chrome::NavigateParams params(browser(), GURL("http://www.google.com/"),
761 ui::PAGE_TRANSITION_LINK);
762 params.disposition = NEW_POPUP;
763 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
764 ui_test_utils::NavigateToURL(&params);
765 Browser* popup_browser = params.browser;
766 // Verify it is a popup, and it is the active window.
767 ASSERT_TRUE(popup_browser);
768 EXPECT_TRUE(popup_browser->window()->IsActive());
769 EXPECT_FALSE(browser()->window()->IsActive());
770 EXPECT_FALSE(popup_browser->SupportsWindowFeature(Browser::FEATURE_TOOLBAR));
771 EXPECT_EQ(popup_browser,
772 chrome::FindLastActiveWithProfile(browser()->profile()));
773
774 // Load up the extension, which will call chrome.browserAction.openPopup
775 // when it is loaded and verify that the popup didn't open.
776 ExtensionTestMessageListener listener("ready", true);
777 EXPECT_TRUE(LoadExtension(
778 test_data_dir_.AppendASCII("browser_action/open_popup_on_reply")));
779 EXPECT_TRUE(listener.WaitUntilSatisfied());
780
781 ResultCatcher catcher;
782 listener.Reply(std::string());
783 EXPECT_TRUE(catcher.GetNextResult()) << message_;
784 }
785
753 } // namespace 786 } // namespace
754 } // namespace extensions 787 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698