Commit 64aa466c authored by John Abd-El-Malek's avatar John Abd-El-Malek Committed by Commit Bot

Convert SitePerProcessBrowserTest.ProcessTransferAfterError to always use URLLoaderInterceptor.

The test class now works with frame requests when the network service is disabled.

Also remove the exception in BrowserTestBase::InitializeNetworkProcess which isn't needed anymore.

Bug: 776589
Change-Id: I87d5efedba8f967dc6b5c890cede22d53e60c90c
Reviewed-on: https://chromium-review.googlesource.com/1037626Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555510}
parent 95043ec4
...@@ -2661,20 +2661,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) { ...@@ -2661,20 +2661,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) {
// Disable host resolution in the test server and try to navigate the subframe // Disable host resolution in the test server and try to navigate the subframe
// cross-site, which will lead to a committed net error. // cross-site, which will lead to a committed net error.
GURL url_b = embedded_test_server()->GetURL("b.com", "/title3.html"); GURL url_b = embedded_test_server()->GetURL("b.com", "/title3.html");
bool network_service =
base::FeatureList::IsEnabled(network::features::kNetworkService);
std::unique_ptr<URLLoaderInterceptor> url_loader_interceptor; std::unique_ptr<URLLoaderInterceptor> url_loader_interceptor;
if (network_service) { url_loader_interceptor = std::make_unique<URLLoaderInterceptor>(
url_loader_interceptor = std::make_unique<URLLoaderInterceptor>( base::BindRepeating([](URLLoaderInterceptor::RequestParams* params) {
base::BindRepeating([](URLLoaderInterceptor::RequestParams* params) { network::URLLoaderCompletionStatus status;
network::URLLoaderCompletionStatus status; status.error_code = net::ERR_NOT_IMPLEMENTED;
status.error_code = net::ERR_NOT_IMPLEMENTED; params->client->OnComplete(status);
params->client->OnComplete(status); return true;
return true; }));
}));
} else {
host_resolver()->ClearRules();
}
TestNavigationObserver observer(shell()->web_contents()); TestNavigationObserver observer(shell()->web_contents());
NavigateIframeToURL(shell()->web_contents(), "child-0", url_b); NavigateIframeToURL(shell()->web_contents(), "child-0", url_b);
...@@ -2699,11 +2693,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) { ...@@ -2699,11 +2693,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) {
EXPECT_EQ("null", child->current_origin().Serialize()); EXPECT_EQ("null", child->current_origin().Serialize());
// Try again after re-enabling host resolution. // Try again after re-enabling host resolution.
if (network_service) { url_loader_interceptor.reset();
url_loader_interceptor.reset();
} else {
host_resolver()->AddRule("*", "127.0.0.1");
}
NavigateIframeToURL(shell()->web_contents(), "child-0", url_b); NavigateIframeToURL(shell()->web_contents(), "child-0", url_b);
EXPECT_TRUE(observer.last_navigation_succeeded()); EXPECT_TRUE(observer.last_navigation_succeeded());
......
...@@ -454,20 +454,12 @@ void BrowserTestBase::InitializeNetworkProcess() { ...@@ -454,20 +454,12 @@ void BrowserTestBase::InitializeNetworkProcess() {
return; return;
initialized_network_process_ = true; initialized_network_process_ = true;
const testing::TestInfo* const test_info = host_resolver()->DisableModifications();
testing::UnitTest::GetInstance()->current_test_info();
bool network_service =
base::FeatureList::IsEnabled(network::features::kNetworkService);
// ProcessTransferAfterError is the only browser test which needs to modify
// the host rules (when not using the network service).
if (network_service ||
std::string(test_info->name()) != "ProcessTransferAfterError") {
host_resolver()->DisableModifications();
}
// Send the host resolver rules to the network service if it's in use. No need // Send the host resolver rules to the network service if it's in use. No need
// to do this if it's running in the browser process though. // to do this if it's running in the browser process though.
if (!network_service || IsNetworkServiceRunningInProcess()) if (!base::FeatureList::IsEnabled(network::features::kNetworkService) ||
IsNetworkServiceRunningInProcess())
return; return;
net::RuleBasedHostResolverProc::RuleList rules = host_resolver()->GetRules(); net::RuleBasedHostResolverProc::RuleList rules = host_resolver()->GetRules();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment