Truly independent web browser
LibWeb: Use a request's reserved client for its target browsing context
Jelle Raaijmakers138d6c3657e3
diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cppindex b3e7f4c394e..0f281e235bf 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp+++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp@@ -17,6 +17,7 @@#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>#include <LibWeb/HTML/LocalTraversableNavigable.h>+#include <LibWeb/HTML/Scripting/Environments.h>namespace Web::Fetch::Infrastructure {@@ -134,6 +135,15 @@ bool Request::is_navigation_request() const});}+// Mixed Content refers to a request's target browsing context, which Fetch does not define. A navigation request targets+// its reserved client's target browsing context: the navigable's active browsing context when the client was reserved.+GC::Ptr<HTML::BrowsingContext> Request::target_browsing_context() const+{+ if (!m_reserved_client)+ return {};+ return m_reserved_client->target_browsing_context.ptr();+}+// https://fetch.spec.whatwg.org/#concept-request-tainted-originRedirectTaint Request::redirect_taint() const{diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.hindex 89b52f012ea..f3a5223fbe2 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h@@ -28,6 +28,7 @@#include <LibWeb/Export.h>#include <LibWeb/Fetch/Infrastructure/HTTP.h>#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>+#include <LibWeb/Forward.h>#include <LibWebCommon/Fetch/Infrastructure/HTTP/RequestPriority.h>#include <LibWebCommon/Fetch/Infrastructure/HTTP/RequestReferrer.h>#include <LibWebCommon/HTML/Scripting/EnvironmentId.h>@@ -309,6 +310,7 @@ public:[[nodiscard]] bool is_subresource_request() const;[[nodiscard]] bool is_navigation_request() const;+ [[nodiscard]] GC::Ptr<HTML::BrowsingContext> target_browsing_context() const;[[nodiscard]] RedirectTaint redirect_taint() const;diff --git a/Libraries/LibWeb/Fetch/Infrastructure/NetworkPartitionKey.cpp b/Libraries/LibWeb/Fetch/Infrastructure/NetworkPartitionKey.cppindex 007b8d9f6c8..5e835dfe245 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/NetworkPartitionKey.cpp+++ b/Libraries/LibWeb/Fetch/Infrastructure/NetworkPartitionKey.cpp@@ -94,10 +94,10 @@ Optional<NetworkPartitionKey> determine_the_network_partition_key(Infrastructurekey->frame_site = URL::Site::serialize_for_partitioning(current_url_origin);key->is_subframe_document = true;key->has_cross_site_ancestor = [&] {- auto reserved_client = request.reserved_client();- if (!reserved_client || !reserved_client->target_browsing_context)+ auto target_browsing_context = request.target_browsing_context();+ if (!target_browsing_context)return false;- auto const* document = reserved_client->target_browsing_context->active_document();+ auto const* document = target_browsing_context->active_document();auto navigable = document ? document->navigable() : nullptr;auto parent = navigable ? navigable->parent() : nullptr;if (!parent)diff --git a/Libraries/LibWeb/MixedContent/AbstractOperations.cpp b/Libraries/LibWeb/MixedContent/AbstractOperations.cppindex d5d0b67e300..5af58f1caba 100644--- a/Libraries/LibWeb/MixedContent/AbstractOperations.cpp+++ b/Libraries/LibWeb/MixedContent/AbstractOperations.cpp@@ -90,7 +90,7 @@ Fetch::Infrastructure::RequestOrResponseBlocking should_fetching_request_be_bloc// 4. request’s destination is "document", and request’s target browsing context has no parent browsing context.// TODO: "parent browsing context" doesn't exist anymore and is a spec bug, seems like it should be `is_top_level`- || (request.destination() == Fetch::Infrastructure::Request::Destination::Document && request.client()->target_browsing_context && request.client()->target_browsing_context->is_top_level())) {+ || (request.destination() == Fetch::Infrastructure::Request::Destination::Document && request.target_browsing_context() && request.target_browsing_context()->is_top_level())) {return Fetch::Infrastructure::RequestOrResponseBlocking::Allowed;}@@ -115,7 +115,7 @@ Web::Fetch::Infrastructure::RequestOrResponseBlocking should_response_to_request// 4. request’s destination is "document", and request’s target browsing context has no parent browsing context.// TODO: "parent browsing context" doesn't exist anymore and is a spec bug, seems like it should be `is_top_level`- || (request.destination() == Fetch::Infrastructure::Request::Destination::Document && request.client()->target_browsing_context && request.client()->target_browsing_context->is_top_level())) {+ || (request.destination() == Fetch::Infrastructure::Request::Destination::Document && request.target_browsing_context() && request.target_browsing_context()->is_top_level())) {return Fetch::Infrastructure::RequestOrResponseBlocking::Allowed;}