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

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

Issue 2851103002: Update some host_resolver()->AddRules in chrome/browser. (Closed)
Patch Set: fix Created 3 years, 7 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/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 icon_portion) 116 icon_portion)
117 .GetRepresentation(1.0f) 117 .GetRepresentation(1.0f)
118 .sk_bitmap())); 118 .sk_bitmap()));
119 } 119 }
120 120
121 class BrowserActionApiTest : public ExtensionApiTest { 121 class BrowserActionApiTest : public ExtensionApiTest {
122 public: 122 public:
123 BrowserActionApiTest() {} 123 BrowserActionApiTest() {}
124 ~BrowserActionApiTest() override {} 124 ~BrowserActionApiTest() override {}
125 125
126 void SetUpOnMainThread() override {
127 ExtensionApiTest::SetUpOnMainThread();
128 host_resolver()->AddRule("*", "127.0.0.1");
129 }
130
126 protected: 131 protected:
127 BrowserActionTestUtil* GetBrowserActionsBar() { 132 BrowserActionTestUtil* GetBrowserActionsBar() {
128 if (!browser_action_test_util_) 133 if (!browser_action_test_util_)
129 browser_action_test_util_.reset(new BrowserActionTestUtil(browser())); 134 browser_action_test_util_.reset(new BrowserActionTestUtil(browser()));
130 return browser_action_test_util_.get(); 135 return browser_action_test_util_.get();
131 } 136 }
132 137
133 WebContents* OpenPopup(int index) { 138 WebContents* OpenPopup(int index) {
134 ResultCatcher catcher; 139 ResultCatcher catcher;
135 content::WindowedNotificationObserver popup_observer( 140 content::WindowedNotificationObserver popup_observer(
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 "backgroundColor);"; 732 "backgroundColor);";
728 std::string result; 733 std::string result;
729 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); 734 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result));
730 EXPECT_EQ(result, "red"); 735 EXPECT_EQ(result, "red");
731 } 736 }
732 737
733 // Test that a browser action popup with a web iframe works correctly. This 738 // Test that a browser action popup with a web iframe works correctly. This
734 // primarily targets --isolate-extensions and --site-per-process modes, where 739 // primarily targets --isolate-extensions and --site-per-process modes, where
735 // the iframe runs in a separate process. See https://crbug.com/546267. 740 // the iframe runs in a separate process. See https://crbug.com/546267.
736 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopupWithIframe) { 741 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopupWithIframe) {
737 host_resolver()->AddRule("*", "127.0.0.1");
738 ASSERT_TRUE(embedded_test_server()->Start()); 742 ASSERT_TRUE(embedded_test_server()->Start());
739 743
740 ASSERT_TRUE(LoadExtension( 744 ASSERT_TRUE(LoadExtension(
741 test_data_dir_.AppendASCII("browser_action/popup_with_iframe"))); 745 test_data_dir_.AppendASCII("browser_action/popup_with_iframe")));
742 BrowserActionTestUtil* actions_bar = GetBrowserActionsBar(); 746 BrowserActionTestUtil* actions_bar = GetBrowserActionsBar();
743 const Extension* extension = GetSingleLoadedExtension(); 747 const Extension* extension = GetSingleLoadedExtension();
744 ASSERT_TRUE(extension) << message_; 748 ASSERT_TRUE(extension) << message_;
745 749
746 // Simulate a click on the browser action to open the popup. 750 // Simulate a click on the browser action to open the popup.
747 ASSERT_TRUE(OpenPopup(0)); 751 ASSERT_TRUE(OpenPopup(0));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 } 830 }
827 831
828 class NavigatingExtensionPopupBrowserTest : public BrowserActionApiTest { 832 class NavigatingExtensionPopupBrowserTest : public BrowserActionApiTest {
829 public: 833 public:
830 const Extension& popup_extension() { return *popup_extension_; } 834 const Extension& popup_extension() { return *popup_extension_; }
831 const Extension& other_extension() { return *other_extension_; } 835 const Extension& other_extension() { return *other_extension_; }
832 836
833 void SetUpOnMainThread() override { 837 void SetUpOnMainThread() override {
834 BrowserActionApiTest::SetUpOnMainThread(); 838 BrowserActionApiTest::SetUpOnMainThread();
835 839
836 host_resolver()->AddRule("*", "127.0.0.1");
837 ASSERT_TRUE(embedded_test_server()->Start()); 840 ASSERT_TRUE(embedded_test_server()->Start());
838 841
839 // Load an extension with a pop-up. 842 // Load an extension with a pop-up.
840 ASSERT_TRUE(popup_extension_ = LoadExtension(test_data_dir_.AppendASCII( 843 ASSERT_TRUE(popup_extension_ = LoadExtension(test_data_dir_.AppendASCII(
841 "browser_action/popup_with_form"))); 844 "browser_action/popup_with_form")));
842 845
843 // Load another extension (that we can try navigating to). 846 // Load another extension (that we can try navigating to).
844 ASSERT_TRUE(other_extension_ = LoadExtension(test_data_dir_.AppendASCII( 847 ASSERT_TRUE(other_extension_ = LoadExtension(test_data_dir_.AppendASCII(
845 "browser_action/popup_with_iframe"))); 848 "browser_action/popup_with_iframe")));
846 } 849 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 // The test verification below is applicable only to scenarios where the 1046 // The test verification below is applicable only to scenarios where the
1044 // download shelf is supported - on ChromeOS, instead of the download shelf, 1047 // download shelf is supported - on ChromeOS, instead of the download shelf,
1045 // there is a download notification in the right-bottom corner of the screen. 1048 // there is a download notification in the right-bottom corner of the screen.
1046 #if !defined(OS_CHROMEOS) 1049 #if !defined(OS_CHROMEOS)
1047 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); 1050 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
1048 #endif 1051 #endif
1049 } 1052 }
1050 1053
1051 } // namespace 1054 } // namespace
1052 } // namespace extensions 1055 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698