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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
23 #include "chrome/browser/ui/host_desktop.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
23 #include "chrome/test/base/ui_test_utils.h" 26 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/render_frame_host.h" 28 #include "content/public/browser/render_frame_host.h"
26 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
27 #include "content/public/test/browser_test_utils.h" 30 #include "content/public/test/browser_test_utils.h"
28 #include "extensions/browser/extension_registry.h" 31 #include "extensions/browser/extension_registry.h"
29 #include "extensions/browser/extension_system.h" 32 #include "extensions/browser/extension_system.h"
30 #include "extensions/browser/notification_types.h" 33 #include "extensions/browser/notification_types.h"
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 test_data_dir_.AppendASCII("browser_action").AppendASCII("rect_icon"))); 746 test_data_dir_.AppendASCII("browser_action").AppendASCII("rect_icon")));
744 EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); 747 EXPECT_TRUE(ready_listener.WaitUntilSatisfied());
745 gfx::Image first_icon = GetBrowserActionsBar()->GetIcon(0); 748 gfx::Image first_icon = GetBrowserActionsBar()->GetIcon(0);
746 ResultCatcher catcher; 749 ResultCatcher catcher;
747 ready_listener.Reply(std::string()); 750 ready_listener.Reply(std::string());
748 EXPECT_TRUE(catcher.GetNextResult()); 751 EXPECT_TRUE(catcher.GetNextResult());
749 gfx::Image next_icon = GetBrowserActionsBar()->GetIcon(0); 752 gfx::Image next_icon = GetBrowserActionsBar()->GetIcon(0);
750 EXPECT_FALSE(gfx::test::AreImagesEqual(first_icon, next_icon)); 753 EXPECT_FALSE(gfx::test::AreImagesEqual(first_icon, next_icon));
751 } 754 }
752 755
756 // Test that we don't try and show a browser action popup with
757 // browserAction.openPopup if there is no toolbar (e.g., for web popup windows).
758 // Regression test for crbug.com/584747.
759 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionOpenPopupOnPopup) {
760 // Open a new web popup window.
761 chrome::NavigateParams params(browser(), GURL("http://www.google.com/"),
762 ui::PAGE_TRANSITION_LINK);
763 params.disposition = NEW_POPUP;
764 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
765 ui_test_utils::NavigateToURL(&params);
766 Browser* popup_browser = params.browser;
767 // Verify it is a popup, and it is the active window.
768 ASSERT_TRUE(popup_browser);
769 // The window isn't considered "active" on MacOSX for odd reasons. The more
770 // important test is that it *is* considered the last active browser, since
771 // that's what we check when we try to open the popup.
772 #if !defined(OS_MACOSX)
773 EXPECT_TRUE(popup_browser->window()->IsActive());
774 #endif
775 EXPECT_FALSE(browser()->window()->IsActive());
776 EXPECT_FALSE(popup_browser->SupportsWindowFeature(Browser::FEATURE_TOOLBAR));
777 EXPECT_EQ(popup_browser,
778 chrome::FindLastActiveWithProfile(browser()->profile(),
779 chrome::GetActiveDesktop()));
780
781 // Load up the extension, which will call chrome.browserAction.openPopup()
782 // when it is loaded and verify that the popup didn't open.
783 ExtensionTestMessageListener listener("ready", true);
784 EXPECT_TRUE(LoadExtension(
785 test_data_dir_.AppendASCII("browser_action/open_popup_on_reply")));
786 EXPECT_TRUE(listener.WaitUntilSatisfied());
787
788 ResultCatcher catcher;
789 listener.Reply(std::string());
790 EXPECT_TRUE(catcher.GetNextResult()) << message_;
791 }
792
753 } // namespace 793 } // namespace
754 } // namespace extensions 794 } // namespace extensions
OLDNEW
« 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