From cdb249e05807677e9628ef31db7a7b51a08fd3af Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Fri, 23 May 2025 22:39:16 +1200 Subject: [PATCH] LibWeb/HTML: Set a fetch client for javascript URL navigations There is an open spec issue for this, and I'm certainly not sure what the client should be here, but using the source snapshot from the global from reading the spec issue seems like a reasonable enough client for now. This can be reproduced by performing a javascript URL navigation with any CSP policy set. For simplicity, simply edit an existing testcase to add such a policy. Fixes: #4853 --- Libraries/LibWeb/HTML/Navigable.cpp | 3 +++ .../Text/input/navigation/iframe-navigate-javascript-url.html | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Libraries/LibWeb/HTML/Navigable.cpp b/Libraries/LibWeb/HTML/Navigable.cpp index ace14a5b7ec..e092e00ea36 100644 --- a/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Libraries/LibWeb/HTML/Navigable.cpp @@ -1931,6 +1931,9 @@ void Navigable::navigate_to_a_javascript_url(URL::URL const& url, HistoryHandlin request->set_url(url); request->set_policy_container(source_snapshot_params->source_policy_container); + // AD-HOC: See https://github.com/whatwg/html/issues/4651, requires some investigation to figure out what we should be setting here. + request->set_client(source_snapshot_params->fetch_client); + // 5. If the result of should navigation request of type be blocked by Content Security Policy? given request and cspNavigationType is "Blocked", then return. if (ContentSecurityPolicy::should_navigation_request_of_type_be_blocked_by_content_security_policy(request, csp_navigation_type) == ContentSecurityPolicy::Directives::Directive::Result::Blocked) return; diff --git a/Tests/LibWeb/Text/input/navigation/iframe-navigate-javascript-url.html b/Tests/LibWeb/Text/input/navigation/iframe-navigate-javascript-url.html index 3f48c5dacde..5b1b4b971f7 100644 --- a/Tests/LibWeb/Text/input/navigation/iframe-navigate-javascript-url.html +++ b/Tests/LibWeb/Text/input/navigation/iframe-navigate-javascript-url.html @@ -1,4 +1,7 @@ + + +