OLD | NEW |
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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/extensions/browser_action_test_util.h" | 12 #include "chrome/browser/extensions/browser_action_test_util.h" |
13 #include "chrome/browser/extensions/extension_action.h" | 13 #include "chrome/browser/extensions/extension_action.h" |
14 #include "chrome/browser/extensions/extension_action_icon_factory.h" | 14 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
15 #include "chrome/browser/extensions/extension_action_manager.h" | 15 #include "chrome/browser/extensions/extension_action_manager.h" |
16 #include "chrome/browser/extensions/extension_apitest.h" | 16 #include "chrome/browser/extensions/extension_apitest.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
19 #include "chrome/browser/extensions/extension_tab_util.h" | 19 #include "chrome/browser/extensions/extension_tab_util.h" |
| 20 #include "chrome/browser/extensions/extension_test_message_listener.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_commands.h" | 23 #include "chrome/browser/ui/browser_commands.h" |
23 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 26 #include "chrome/common/extensions/features/feature_channel.h" |
25 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
26 #include "chrome/test/base/ui_test_utils.h" | 28 #include "chrome/test/base/ui_test_utils.h" |
27 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/render_process_host.h" |
28 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
29 #include "content/public/test/browser_test_utils.h" | 32 #include "content/public/test/browser_test_utils.h" |
30 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
31 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
32 #include "ui/gfx/rect.h" | 35 #include "ui/gfx/rect.h" |
33 #include "ui/gfx/size.h" | 36 #include "ui/gfx/size.h" |
34 #include "ui/gfx/image/image_skia.h" | 37 #include "ui/gfx/image/image_skia.h" |
35 #include "ui/gfx/image/image_skia_operations.h" | 38 #include "ui/gfx/image/image_skia_operations.h" |
36 #include "ui/gfx/skia_util.h" | 39 #include "ui/gfx/skia_util.h" |
37 | 40 |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 const std::string script = | 689 const std::string script = |
687 "window.domAutomationController.send(document.body.style." | 690 "window.domAutomationController.send(document.body.style." |
688 "backgroundColor);"; | 691 "backgroundColor);"; |
689 std::string result; | 692 std::string result; |
690 const std::string frame_xpath; | 693 const std::string frame_xpath; |
691 EXPECT_TRUE(content::ExecuteScriptInFrameAndExtractString( | 694 EXPECT_TRUE(content::ExecuteScriptInFrameAndExtractString( |
692 tab, frame_xpath, script, &result)); | 695 tab, frame_xpath, script, &result)); |
693 EXPECT_EQ(result, "red"); | 696 EXPECT_EQ(result, "red"); |
694 } | 697 } |
695 | 698 |
| 699 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, TestBrowserActionOpenPopup) { |
| 700 ScopedCurrentChannel current_channel(chrome::VersionInfo::CHANNEL_DEV); |
| 701 |
| 702 |
| 703 ExtensionTestMessageListener listener("ready", true); |
| 704 |
| 705 { |
| 706 // Show first popup in original window and expect it to have loaded. |
| 707 content::WindowedNotificationObserver frame_observer( |
| 708 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 709 content::NotificationService::AllSources()); |
| 710 |
| 711 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", |
| 712 "open_popup_succeeds.html")) << message_; |
| 713 frame_observer.Wait(); |
| 714 EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
| 715 } |
| 716 |
| 717 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 718 |
| 719 { |
| 720 // Open a new window. |
| 721 content::WindowedNotificationObserver frame_observer( |
| 722 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 723 content::NotificationService::AllSources()); |
| 724 browser()->OpenURL(content::OpenURLParams( |
| 725 GURL("about:"), content::Referrer(), NEW_WINDOW, |
| 726 content::PAGE_TRANSITION_TYPED, false)); |
| 727 frame_observer.Wait(); |
| 728 } |
| 729 |
| 730 // Show second popup in new window. |
| 731 listener.Reply(""); |
| 732 |
| 733 { |
| 734 // Expect popup to have loaded. |
| 735 content::WindowedNotificationObserver frame_observer( |
| 736 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 737 content::NotificationService::AllSources()); |
| 738 frame_observer.Wait(); |
| 739 EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
| 740 } |
| 741 } |
| 742 |
| 743 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 744 TestBrowserActionOpenPopupIncognito) { |
| 745 content::WindowedNotificationObserver frame_observer( |
| 746 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 747 content::NotificationService::AllSources()); |
| 748 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", |
| 749 "open_popup_succeeds.html", |
| 750 kFlagEnableIncognito | kFlagUseIncognito)) |
| 751 << message_; |
| 752 frame_observer.Wait(); |
| 753 EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
| 754 } |
| 755 |
| 756 // Test that the popup does not show in an incognito if extension is not enabled |
| 757 // for incognito. |
| 758 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 759 TestBrowserActionOpenPopupIncognitoNotAllowed) { |
| 760 { |
| 761 // Open an incognito window. |
| 762 content::WindowedNotificationObserver frame_observer( |
| 763 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 764 content::NotificationService::AllSources()); |
| 765 browser()->OpenURL(content::OpenURLParams( |
| 766 GURL("about:"), content::Referrer(), OFF_THE_RECORD, |
| 767 content::PAGE_TRANSITION_TYPED, false)); |
| 768 frame_observer.Wait(); |
| 769 } |
| 770 |
| 771 { |
| 772 // Load popup. |
| 773 // TODO(justinlin): Check that it opened in the non-incognito window. |
| 774 content::WindowedNotificationObserver frame_observer( |
| 775 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 776 content::NotificationService::AllSources()); |
| 777 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", |
| 778 "open_popup_succeeds.html")) << message_; |
| 779 frame_observer.Wait(); |
| 780 EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
| 781 } |
| 782 } |
| 783 |
| 784 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 785 TestBrowserActionOpenPopupButtonHidden) { |
| 786 // TODO(justinlin): Implement. |
| 787 } |
| 788 |
| 789 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 790 TestBrowserActionOpenPopupNoWindows) { |
| 791 // TODO(justinlin): Implement. |
| 792 } |
| 793 |
696 } // namespace | 794 } // namespace |
697 } // namespace extensions | 795 } // namespace extensions |
OLD | NEW |