Truly independent web browser
LibWeb: Hold a fetch request's prompt traversable by id
Luke Wildef084e770f71d
diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cppindex 1dd80671b63..73a1dafa39c 100644--- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp+++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp@@ -487,7 +487,7 @@ void populate_request_from_client(Infrastructure::Request& request, GC::Ptr<HTML// user prompts to global’s navigable’s traversable navigable.if (auto const* window = HTML::window_from_global_object(global)) {if (window->navigable())- request.set_traversable_for_user_prompts(GC::Ptr<HTML::Navigable> { window->navigable()->traversable_navigable() });+ request.set_traversable_for_user_prompts(window->navigable()->traversable_navigable()->id());}}}@@ -2350,7 +2350,7 @@ GC::Ref<PendingResponse> http_network_or_cache_fetch(JS::Realm& realm, Infrastruif (response->status() == 401&& http_request->response_tainting() != Infrastructure::Request::ResponseTainting::CORS&& include_credentials == HTTP::Cookie::IncludeCredentials::Yes- && request->traversable_for_user_prompts().has<GC::Ptr<HTML::Navigable>>()+ && request->traversable_for_user_prompts().has<HTML::CrossProcessId>()&& www_authenticate_has_credential_based_scheme()) {// NB: Every branch below drops this response, for a network error or a new fetch's response.stop_discarded_response_body(*fetch_params.controller(), *response);diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cppindex bd8ab6215f7..f330b36677f 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp+++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp@@ -45,7 +45,6 @@ void Request::visit_edges(JS::Cell::Visitor& visitor)Base::visit_edges(visitor);visitor.visit(m_body);visitor.visit(m_reserved_client);- visitor.visit(m_traversable_for_user_prompts);visitor.visit(m_pending_responses);visitor.visit(m_webdriver_bidi_network_request);}diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.hindex bc65e6ee5b9..ec323de00c6 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h@@ -33,6 +33,7 @@#include <LibWeb/HTML/Scripting/EnvironmentSettingsObjectAddress.h>#include <LibWebCommon/Fetch/Infrastructure/HTTP/RequestPriority.h>#include <LibWebCommon/Fetch/Infrastructure/HTTP/RequestReferrer.h>+#include <LibWebCommon/HTML/CrossProcessId.h>#include <LibWebCommon/HTML/Scripting/EnvironmentId.h>namespace Web::WebDriver::BiDi {@@ -171,7 +172,7 @@ public:using PolicyContainerType = Variant<PolicyContainer, NonnullRefPtr<HTML::PolicyContainer const>>;using ReferrerType = RequestReferrerType;using ReservedClientType = GC::Ptr<HTML::Environment>;- using TraversableForUserPromptsType = Variant<TraversableForUserPrompts, GC::Ptr<HTML::EnvironmentSettingsObject>, GC::Ptr<HTML::Navigable>>;+ using TraversableForUserPromptsType = Variant<TraversableForUserPrompts, HTML::CrossProcessId>;[[nodiscard]] static GC::Ref<Request> create();[[nodiscard]] static GC::Ref<Request> create(JS::VM&);@@ -418,6 +419,7 @@ private:// https://fetch.spec.whatwg.org/#concept-request-window// A request has an associated traversable for user prompts, that is "no-traversable", "client", or a traversable// navigable. Unless stated otherwise it is "client".+ // NB: A traversable navigable is held by its id.TraversableForUserPromptsType m_traversable_for_user_prompts { TraversableForUserPrompts::Client };// https://fetch.spec.whatwg.org/#request-keepalive-flagdiff --git a/Libraries/LibWeb/Fetch/Request.cpp b/Libraries/LibWeb/Fetch/Request.cppindex 2c444e3a628..3a5fb2c0b7b 100644--- a/Libraries/LibWeb/Fetch/Request.cpp+++ b/Libraries/LibWeb/Fetch/Request.cpp@@ -343,11 +343,7 @@ WebIDL::ExceptionOr<GC::Ref<Request>> Request::create_with_settings(HTML::Enviro// 9. If request’s traversable for user prompts is an environment settings object and its origin is same origin with// origin, then set traversableForUserPrompts to request’s traversable for user prompts.- if (input_request->traversable_for_user_prompts().has<GC::Ptr<HTML::EnvironmentSettingsObject>>()) {- auto eso = input_request->traversable_for_user_prompts().get<GC::Ptr<HTML::EnvironmentSettingsObject>>();- if (eso->origin().is_same_origin(origin))- traversable_for_user_prompts = input_request->traversable_for_user_prompts();- }+ // NB: A request's traversable for user prompts is never an environment settings object.// 11. If init["window"] exists, then set traversableForUserPrompts to "no-traversable".if (init.window.has_value()) {