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 |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 const std::string script = | 686 const std::string script = |
687 "window.domAutomationController.send(document.body.style." | 687 "window.domAutomationController.send(document.body.style." |
688 "backgroundColor);"; | 688 "backgroundColor);"; |
689 std::string result; | 689 std::string result; |
690 const std::string frame_xpath; | 690 const std::string frame_xpath; |
691 EXPECT_TRUE(content::ExecuteScriptInFrameAndExtractString( | 691 EXPECT_TRUE(content::ExecuteScriptInFrameAndExtractString( |
692 tab, frame_xpath, script, &result)); | 692 tab, frame_xpath, script, &result)); |
693 EXPECT_EQ(result, "red"); | 693 EXPECT_EQ(result, "red"); |
694 } | 694 } |
695 | 695 |
| 696 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, TestBrowserActionOpenPopup) { |
| 697 ExtensionTestMessageListener listener("ready", true); |
| 698 { |
| 699 // Show first popup in original window and expect it to have loaded. |
| 700 content::WindowedNotificationObserver frame_observer( |
| 701 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 702 content::NotificationService::AllSources()); |
| 703 |
| 704 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", |
| 705 "open_popup_succeeds.html")) << message_; |
| 706 frame_observer.Wait(); |
| 707 EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
| 708 } |
| 709 |
| 710 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 711 |
| 712 { |
| 713 // Open a new window. |
| 714 content::WindowedNotificationObserver frame_observer( |
| 715 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 716 content::NotificationService::AllSources()); |
| 717 browser()->OpenURL(content::OpenURLParams( |
| 718 GURL("about:"), content::Referrer(), NEW_WINDOW, |
| 719 content::PAGE_TRANSITION_TYPED, false)); |
| 720 frame_observer.Wait(); |
| 721 } |
| 722 |
| 723 // Show second popup in new window. |
| 724 listener.Reply(""); |
| 725 |
| 726 { |
| 727 // Expect popup to have loaded. |
| 728 content::WindowedNotificationObserver frame_observer( |
| 729 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 730 content::NotificationService::AllSources()); |
| 731 frame_observer.Wait(); |
| 732 EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
| 733 } |
| 734 } |
| 735 |
| 736 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 737 TestBrowserActionOpenPopupIncognito) { |
| 738 content::WindowedNotificationObserver frame_observer( |
| 739 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 740 content::NotificationService::AllSources()); |
| 741 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", |
| 742 "open_popup_succeeds.html", |
| 743 kFlagEnableIncognito | kFlagUseIncognito)) |
| 744 << message_; |
| 745 frame_observer.Wait(); |
| 746 EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
| 747 } |
| 748 |
| 749 // Test that the popup does not show in an incognito if extension is not enabled |
| 750 // for incognito. |
| 751 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 752 TestBrowserActionOpenPopupIncognitoNotAllowed) { |
| 753 { |
| 754 // Open an incognito window. |
| 755 content::WindowedNotificationObserver frame_observer( |
| 756 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 757 content::NotificationService::AllSources()); |
| 758 browser()->OpenURL(content::OpenURLParams( |
| 759 GURL("about:"), content::Referrer(), OFF_THE_RECORD, |
| 760 content::PAGE_TRANSITION_TYPED, false)); |
| 761 frame_observer.Wait(); |
| 762 } |
| 763 |
| 764 { |
| 765 // Load popup. |
| 766 // TODO(justinlin): Check that it opened in the non-incognito window. |
| 767 content::WindowedNotificationObserver frame_observer( |
| 768 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 769 content::NotificationService::AllSources()); |
| 770 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", |
| 771 "open_popup_succeeds.html")) << message_; |
| 772 frame_observer.Wait(); |
| 773 EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); |
| 774 } |
| 775 } |
| 776 |
| 777 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 778 TestBrowserActionOpenPopupDoesNotCloseOtherPopups) { |
| 779 // TODO(justinlin): Implement. |
| 780 } |
| 781 |
| 782 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 783 TestBrowserActionOpenPopupButtonHidden) { |
| 784 // TODO(justinlin): Implement. |
| 785 } |
| 786 |
| 787 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 788 TestBrowserActionOpenPopupNoWindows) { |
| 789 // TODO(justinlin): Implement. |
| 790 } |
| 791 |
| 792 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 793 TestBrowserActionOpenPopupDoesNotGrant) { |
| 794 // TODO(justinlin): Implement |
| 795 } |
| 796 |
696 } // namespace | 797 } // namespace |
697 } // namespace extensions | 798 } // namespace extensions |
OLD | NEW |