electron/patches/chromium/revert_remove_contentrendererclient_shouldfork.patch
Electron Bot 2b53788c35
chore: bump chromium to 4b6692e4cc2839729bb7ac009586a (master) (#21864)
* chore: bump chromium in DEPS to a1ea0d7aedd6b5fe58fbabfa3b05aa8ee41304ff

* update patches

* update extensions code

* Remove WebPoint

https://chromium-review.googlesource.com/c/chromium/src/+/2007474

* fix build

* chore: bump chromium in DEPS to 9351e26c2a3714f8bbb10789c71bb51b0b494c75

* update patches

* Remove error description from the DidFailLoadWithError message

https://chromium-review.googlesource.com/c/chromium/src/+/2011280

* Make SimpleNetworkHintsHandlerImpl use the right NetworkIsolationKey

https://chromium-review.googlesource.com/c/chromium/src/+/1994430

* Rename libgtkui to gtk

https://chromium-review.googlesource.com/c/chromium/src/+/2011683

* [metrics] Remove histogram Startup.WarmStartTimeFromRemoteProcessStart*.

https://chromium-review.googlesource.com/c/chromium/src/+/2003211

* fix requestSingleInstanceLock test

* chore: bump chromium in DEPS to a813567a4f17ea08292c2b26fa10d0ffd47010d9

* chore: bump chromium in DEPS to f0aca2de536ceecd6eb66e928051d11e6d11991f

* chore: bump chromium in DEPS to 865556af6d0c9d990f5b1816cb792f7c3859667b

* chore: bump chromium in DEPS to 98538fdd28c4b6692e4cc2839729bb7ac009586a

* update patches

* fix broken tests

* Update node tests for v8 changes

* Update node patches for test failures

* Update for number of tests

Co-authored-by: Jeremy Apthorp <nornagon@nornagon.net>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
2020-01-29 07:01:37 -05:00

107 lines
4.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Wed, 23 Oct 2019 15:30:18 -0700
Subject: Revert "Remove ContentRendererClient::ShouldFork."
This reverts commit 6b068eb8ca4a3c7350bdafa22fc0cf0636ef8b74.
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index e03ad3a5a115383143d1324164dfd37f87c6f2f2..1c179e0cca8b0b1fc19971d1c9e93d59af7b9383 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -1291,6 +1291,17 @@ bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame,
return true;
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
+ DCHECK(!frame->Parent());
+
+ // If |url| matches one of the prerendered URLs, stop this navigation and try
+ // to swap in the prerendered page on the browser process. If the prerendered
+ // page no longer exists by the time the OpenURL IPC is handled, a normal
+ // navigation is attempted.
+ if (prerender_dispatcher_.get() &&
+ prerender_dispatcher_->IsPrerenderURL(url)) {
+ return true;
+ }
+
return false;
}
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 775ef1dd795e8bcab1d4a22719fd1679e8a27967..7a56f78966fb578429d8dc39fc0b58af52d2a550 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -1003,6 +1003,73 @@ TEST_F(RenderViewImplTest, BeginNavigationForWebUI) {
FrameHostMsg_OpenURL::ID));
}
+class AlwaysForkingRenderViewTest : public RenderViewImplTest {
+ public:
+ ContentRendererClient* CreateContentRendererClient() override {
+ return new TestContentRendererClient;
+ }
+
+ private:
+ class TestContentRendererClient : public ContentRendererClient {
+ public:
+ bool ShouldFork(blink::WebLocalFrame* frame,
+ const GURL& url,
+ const std::string& http_method,
+ bool is_initial_navigation,
+ bool is_server_redirect) override {
+ return true;
+ }
+ };
+};
+
+TEST_F(AlwaysForkingRenderViewTest, BeginNavigationDoesNotForkEmptyUrl) {
+ GURL example_url("http://example.com");
+ GURL empty_url("");
+
+ LoadHTMLWithUrlOverride("<body></body", example_url.spec().c_str());
+ EXPECT_EQ(example_url,
+ GURL(frame()->GetWebFrame()->GetDocumentLoader()->GetUrl()));
+
+ // Empty url should never fork.
+ blink::WebURLRequest request(empty_url);
+ request.SetMode(network::mojom::RequestMode::kNavigate);
+ request.SetRedirectMode(network::mojom::RedirectMode::kManual);
+ request.SetRequestContext(blink::mojom::RequestContextType::INTERNAL);
+ request.SetRequestorOrigin(blink::WebSecurityOrigin::Create(example_url));
+ auto navigation_info = std::make_unique<blink::WebNavigationInfo>();
+ navigation_info->url_request = request;
+ navigation_info->frame_type =
+ network::mojom::RequestContextFrameType::kTopLevel;
+ navigation_info->navigation_policy = blink::kWebNavigationPolicyCurrentTab;
+ frame()->BeginNavigation(std::move(navigation_info));
+ EXPECT_FALSE(render_thread_->sink().GetUniqueMessageMatching(
+ FrameHostMsg_OpenURL::ID));
+}
+
+TEST_F(AlwaysForkingRenderViewTest, BeginNavigationDoesNotForkAboutBlank) {
+ GURL example_url("http://example.com");
+ GURL blank_url(url::kAboutBlankURL);
+
+ LoadHTMLWithUrlOverride("<body></body", example_url.spec().c_str());
+ EXPECT_EQ(example_url,
+ GURL(frame()->GetWebFrame()->GetDocumentLoader()->GetUrl()));
+
+ // about:blank should never fork.
+ blink::WebURLRequest request(blank_url);
+ request.SetMode(network::mojom::RequestMode::kNavigate);
+ request.SetRedirectMode(network::mojom::RedirectMode::kManual);
+ request.SetRequestContext(blink::mojom::RequestContextType::INTERNAL);
+ request.SetRequestorOrigin(blink::WebSecurityOrigin::Create(example_url));
+ auto navigation_info = std::make_unique<blink::WebNavigationInfo>();
+ navigation_info->url_request = request;
+ navigation_info->frame_type =
+ network::mojom::RequestContextFrameType::kTopLevel;
+ navigation_info->navigation_policy = blink::kWebNavigationPolicyCurrentTab;
+ frame()->BeginNavigation(std::move(navigation_info));
+ EXPECT_FALSE(render_thread_->sink().GetUniqueMessageMatching(
+ FrameHostMsg_OpenURL::ID));
+}
+
// This test verifies that when device emulation is enabled, RenderFrameProxy
// continues to receive the original ScreenInfo and not the emualted
// ScreenInfo.