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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl_browsertest.cc

Issue 2838293002: Ensure all content_browsertests call the host resolver in SetUpOnMainThread and not after. (Closed)
Patch Set: Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/memory/weak_ptr.h" 5 #include "base/memory/weak_ptr.h"
6 #include "content/browser/frame_host/navigation_handle_impl.h" 6 #include "content/browser/frame_host/navigation_handle_impl.h"
7 #include "content/browser/web_contents/web_contents_impl.h" 7 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_contents_observer.h" 9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/common/browser_side_navigation_policy.h" 10 #include "content/public/common/browser_side_navigation_policy.h"
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 1140
1141 // This class allows running tests with PlzNavigate enabled, regardless of 1141 // This class allows running tests with PlzNavigate enabled, regardless of
1142 // default test configuration. 1142 // default test configuration.
1143 class PlzNavigateNavigationHandleImplBrowserTest : public ContentBrowserTest { 1143 class PlzNavigateNavigationHandleImplBrowserTest : public ContentBrowserTest {
1144 public: 1144 public:
1145 PlzNavigateNavigationHandleImplBrowserTest() {} 1145 PlzNavigateNavigationHandleImplBrowserTest() {}
1146 1146
1147 void SetUpCommandLine(base::CommandLine* command_line) override { 1147 void SetUpCommandLine(base::CommandLine* command_line) override {
1148 command_line->AppendSwitch(switches::kEnableBrowserSideNavigation); 1148 command_line->AppendSwitch(switches::kEnableBrowserSideNavigation);
1149 } 1149 }
1150
1151 void SetUpOnMainThread() override {
1152 host_resolver()->AddRule("*", "127.0.0.1");
1153 }
1150 }; 1154 };
1151 1155
1152 // Test to verify that error pages caused by NavigationThrottle blocking a 1156 // Test to verify that error pages caused by NavigationThrottle blocking a
1153 // request from being made are properly committed in the original process 1157 // request from being made are properly committed in the original process
1154 // that requested the navigation. 1158 // that requested the navigation.
1155 IN_PROC_BROWSER_TEST_F(PlzNavigateNavigationHandleImplBrowserTest, 1159 IN_PROC_BROWSER_TEST_F(PlzNavigateNavigationHandleImplBrowserTest,
1156 ErrorPageBlockedNavigation) { 1160 ErrorPageBlockedNavigation) {
1157 host_resolver()->AddRule("*", "127.0.0.1");
1158 SetupCrossSiteRedirector(embedded_test_server()); 1161 SetupCrossSiteRedirector(embedded_test_server());
1159 ASSERT_TRUE(embedded_test_server()->Start()); 1162 ASSERT_TRUE(embedded_test_server()->Start());
1160 1163
1161 GURL start_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); 1164 GURL start_url(embedded_test_server()->GetURL("foo.com", "/title1.html"));
1162 GURL blocked_url(embedded_test_server()->GetURL("bar.com", "/title2.html")); 1165 GURL blocked_url(embedded_test_server()->GetURL("bar.com", "/title2.html"));
1163 1166
1164 { 1167 {
1165 NavigationHandleObserver observer(shell()->web_contents(), start_url); 1168 NavigationHandleObserver observer(shell()->web_contents(), start_url);
1166 EXPECT_TRUE(NavigateToURL(shell(), start_url)); 1169 EXPECT_TRUE(NavigateToURL(shell(), start_url));
1167 EXPECT_TRUE(observer.has_committed()); 1170 EXPECT_TRUE(observer.has_committed());
(...skipping 15 matching lines...) Expand all
1183 EXPECT_EQ(site_instance, 1186 EXPECT_EQ(site_instance,
1184 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); 1187 shell()->web_contents()->GetMainFrame()->GetSiteInstance());
1185 } 1188 }
1186 } 1189 }
1187 1190
1188 // Test to verify that error pages caused by network error or other 1191 // Test to verify that error pages caused by network error or other
1189 // recoverable error are properly committed in the process for the 1192 // recoverable error are properly committed in the process for the
1190 // destination URL. 1193 // destination URL.
1191 IN_PROC_BROWSER_TEST_F(PlzNavigateNavigationHandleImplBrowserTest, 1194 IN_PROC_BROWSER_TEST_F(PlzNavigateNavigationHandleImplBrowserTest,
1192 ErrorPageNetworkError) { 1195 ErrorPageNetworkError) {
1193 host_resolver()->AddRule("*", "127.0.0.1");
1194 SetupCrossSiteRedirector(embedded_test_server()); 1196 SetupCrossSiteRedirector(embedded_test_server());
1195 ASSERT_TRUE(embedded_test_server()->Start()); 1197 ASSERT_TRUE(embedded_test_server()->Start());
1196 1198
1197 GURL start_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); 1199 GURL start_url(embedded_test_server()->GetURL("foo.com", "/title1.html"));
1198 GURL error_url( 1200 GURL error_url(
1199 net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_RESET)); 1201 net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_RESET));
1200 EXPECT_NE(start_url.host(), error_url.host()); 1202 EXPECT_NE(start_url.host(), error_url.host());
1201 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 1203 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
1202 base::Bind(&net::URLRequestFailedJob::AddUrlHandler)); 1204 base::Bind(&net::URLRequestFailedJob::AddUrlHandler));
1203 1205
(...skipping 10 matching lines...) Expand all
1214 NavigationHandleObserver observer(shell()->web_contents(), error_url); 1216 NavigationHandleObserver observer(shell()->web_contents(), error_url);
1215 EXPECT_FALSE(NavigateToURL(shell(), error_url)); 1217 EXPECT_FALSE(NavigateToURL(shell(), error_url));
1216 EXPECT_TRUE(observer.has_committed()); 1218 EXPECT_TRUE(observer.has_committed());
1217 EXPECT_TRUE(observer.is_error()); 1219 EXPECT_TRUE(observer.is_error());
1218 EXPECT_NE(site_instance, 1220 EXPECT_NE(site_instance,
1219 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); 1221 shell()->web_contents()->GetMainFrame()->GetSiteInstance());
1220 } 1222 }
1221 } 1223 }
1222 1224
1223 } // namespace content 1225 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_browsertest.cc ('k') | content/browser/frame_host/render_frame_host_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698