From d7d84ee93144a716030653f4d641c29824c91527 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Thu, 9 Nov 2023 18:09:21 -0700 Subject: [PATCH] LibWeb: Ensure a Web::Page is associated with local Worker LoadRequests This is a hack on top of a hack because Workers don't *really* need to have a Web::Page at all, but the ResourceLoader infra that should be going away soon :tm: is not quite ready to axe that requirement for cookies. --- Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp | 3 +++ Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index 7672b5aa72..1e0c176def 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -1728,6 +1729,8 @@ WebIDL::ExceptionOr> nonstandard_resource_load auto& global_object = realm.global_object(); if (is(global_object)) page = static_cast(global_object).page(); + else if (is(global_object)) + page = static_cast(global_object).page(); // NOTE: Using LoadRequest::create_for_url_on_page here will unconditionally add cookies as long as there's a page available. // However, it is up to http_network_or_cache_fetch to determine if cookies should be added to the request. diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index 8a0742b59b..e89ec0c641 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -234,8 +234,10 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback if (request.page().has_value()) m_page = request.page().value(); - if (!m_page.has_value()) + if (!m_page.has_value()) { + log_failure(request, "INTERNAL ERROR: No Page for request"); return; + } FileRequest file_request(url.serialize_path(), [this, success_callback = move(success_callback), error_callback = move(error_callback), log_success, log_failure, request](ErrorOr file_or_error) { --m_pending_loads;