Index: content/browser/site_per_process_browsertest.cc |
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc |
index fdf7ab570a71aca6ab23acee05238327fdda4a6a..d8caf50f325b232bfaaf66b1f2dfcf25f8361031 100644 |
--- a/content/browser/site_per_process_browsertest.cc |
+++ b/content/browser/site_per_process_browsertest.cc |
@@ -38,6 +38,7 @@ |
#include "content/browser/frame_host/render_frame_proxy_host.h" |
#include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
#include "content/browser/gpu/compositor_util.h" |
+#include "content/browser/loader/navigation_url_loader_network_service.h" |
#include "content/browser/loader/resource_dispatcher_host_impl.h" |
#include "content/browser/renderer_host/input/input_router_impl.h" |
#include "content/browser/renderer_host/input/synthetic_tap_gesture.h" |
@@ -71,6 +72,7 @@ |
#include "content/test/content_browser_test_utils_internal.h" |
#include "ipc/ipc.mojom.h" |
#include "ipc/ipc_security_test_util.h" |
+#include "mojo/public/cpp/bindings/strong_binding.h" |
#include "net/dns/mock_host_resolver.h" |
#include "net/test/embedded_test_server/embedded_test_server.h" |
#include "net/test/embedded_test_server/http_request.h" |
@@ -2395,6 +2397,40 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteAfterError) { |
} |
} |
+namespace { |
+class FailingURLLoaderImpl : public mojom::URLLoader { |
+ public: |
+ explicit FailingURLLoaderImpl(mojom::URLLoaderClientPtr client) { |
+ ResourceRequestCompletionStatus status; |
+ status.error_code = net::ERR_NOT_IMPLEMENTED; |
+ client->OnComplete(status); |
+ } |
+ |
+ void FollowRedirect() override {} |
+ void SetPriority(net::RequestPriority priority, |
+ int32_t intra_priority_value) override {} |
+}; |
+ |
+class FailingLoadFactory : public mojom::URLLoaderFactory { |
+ public: |
+ FailingLoadFactory() {} |
+ ~FailingLoadFactory() override {} |
+ |
+ void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest loader, |
+ int32_t routing_id, |
+ int32_t request_id, |
+ uint32_t options, |
+ const ResourceRequest& request, |
+ mojom::URLLoaderClientPtr client) override { |
+ new FailingURLLoaderImpl(std::move(client)); |
+ } |
+ void SyncLoad(int32_t routing_id, |
+ int32_t request_id, |
+ const ResourceRequest& request, |
+ SyncLoadCallback callback) override {} |
+}; |
+} |
+ |
// Ensure that a cross-site page ends up in the correct process when it |
// successfully loads after earlier encountering a network error for it. |
// See https://crbug.com/560511. |
@@ -2413,7 +2449,18 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) { |
// Disable host resolution in the test server and try to navigate the subframe |
// cross-site, which will lead to a committed net error. |
GURL url_b = embedded_test_server()->GetURL("b.com", "/title3.html"); |
- host_resolver()->ClearRules(); |
+ bool network_service = base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableNetworkService); |
+ mojom::URLLoaderFactoryPtr failing_factory; |
+ mojo::MakeStrongBinding(base::MakeUnique<FailingLoadFactory>(), |
+ mojo::MakeRequest(&failing_factory)); |
+ if (network_service) { |
+ NavigationURLLoaderNetworkService::OverrideURLLoaderFactoryForTesting( |
+ std::move(failing_factory)); |
+ } else { |
+ host_resolver()->ClearRules(); |
+ } |
+ |
TestNavigationObserver observer(shell()->web_contents()); |
NavigateIframeToURL(shell()->web_contents(), "child-0", url_b); |
EXPECT_FALSE(observer.last_navigation_succeeded()); |
@@ -2446,7 +2493,9 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) { |
EXPECT_EQ("null", child->current_origin().Serialize()); |
// Try again after re-enabling host resolution. |
- host_resolver()->AddRule("*", "127.0.0.1"); |
+ if (!network_service) |
+ host_resolver()->AddRule("*", "127.0.0.1"); |
Charlie Reis
2017/04/28 18:08:14
Shouldn't there be an else branch here? How would
jam
2017/04/28 18:09:53
The URLLoaderFactory set above is only used for on
Charlie Reis
2017/04/28 18:14:52
Oh, ok. That seems a bit non-obvious, but glad it
jam
2017/04/28 19:25:24
This was documented in the test method; but point
|
+ |
NavigateIframeToURL(shell()->web_contents(), "child-0", url_b); |
EXPECT_TRUE(observer.last_navigation_succeeded()); |
EXPECT_EQ(url_b, observer.last_navigation_url()); |
@@ -9654,7 +9703,6 @@ class RequestDelayingSitePerProcessBrowserTest |
// Must be called after any calls to SetDelayedRequestsForPath. |
void SetUpEmbeddedTestServer() { |
- host_resolver()->AddRule("*", "127.0.0.1"); |
SetupCrossSiteRedirector(test_server_.get()); |
test_server_->RegisterRequestHandler(base::Bind( |
&RequestDelayingSitePerProcessBrowserTest::HandleMockResource, |