Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 185dbf0b authored by Carmelo Messina's avatar Carmelo Messina
Browse files

Keep disabled FetchLaterAPI: fix net::ERR_TIMED_OUT (#2308)

also activates the API but denies the actual sending of the request
parent aabb7ddc
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -13,10 +13,10 @@ License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
 .../browser/loader/keep_alive_url_loader.h    |  3 --
 .../Keep-disabled-FetchLaterAPI.inc           |  2 ++
 .../renderer/core/fetch/fetch_manager.cc      | 21 ++++++++++--
 .../loader/child_url_loader_factory_bundle.cc | 14 ++++----
 .../loader/child_url_loader_factory_bundle.cc | 16 +++++----
 .../platform/loader/fetch/resource_fetcher.cc |  2 +-
 .../platform/runtime_enabled_features.json5   |  4 +--
 7 files changed, 63 insertions(+), 16 deletions(-)
 7 files changed, 65 insertions(+), 16 deletions(-)
 create mode 100644 cromite_flags/third_party/blink/common/features_cc/Keep-disabled-FetchLaterAPI.inc

diff --git a/content/browser/loader/keep_alive_url_loader.cc b/content/browser/loader/keep_alive_url_loader.cc
@@ -146,20 +146,22 @@ diff --git a/third_party/blink/renderer/core/fetch/fetch_manager.cc b/third_part
diff --git a/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc b/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc
--- a/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc
+++ b/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc
@@ -250,6 +250,12 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart(
@@ -250,6 +250,14 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart(
     return;
   }
 
+  bool keepalive = request.keepalive;
+  if (keepalive && !request.is_fetch_later_api &&
+        url::IsSameOriginWith(request.url, request.referrer)) {
+  if (keepalive && !request.is_fetch_later_api) {
+    if (request.request_initiator && request.request_initiator->IsSameOriginWith(request.url))
+      keepalive = false;
+    else if (url::IsSameOriginWith(request.url, request.referrer))
+      keepalive = false;
+  }
+
   // Use |keep_alive_loader_factory_| to send the keepalive requests to the
   // KeepAliveURLLoaderService in the browser process and trigger the special
   // keepalive request handling.
@@ -258,12 +264,8 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart(
@@ -258,12 +266,8 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart(
   if (request.keepalive) {
     FetchUtils::LogFetchKeepAliveRequestSentToServiceMetric(request);
   }
@@ -195,8 +197,8 @@ diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5
       // https://chromestatus.com/feature/4654499737632768
-      name: "FetchLaterAPI",
-      status: "stable",
+      name: "FetchLaterAPI",   // disable
+      status: "experimental",  // by default
+      name: "FetchLaterAPI",   // disabled
+      status: "stable",  // by default (note: idl must be active)
     },
     {
       // The retry ability for Fetch keepalive requests.