From 189214810e034ffa4d4a019d8b6f593a459a19b8 Mon Sep 17 00:00:00 2001 From: elomscansio <163124154+elomscansio@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:12:39 +0100 Subject: [PATCH] layout_image: Include missing request settings in layout-initiated image loads (#36621) This PR updates the `fetch_image_for_layout` function to include missing security-related request settings: - `insecure_requests_policy` - `has_trustworthy_ancestor_origin` - `policy_container` --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #36591 - [X] There are tests for these changes Signed-off-by: Emmanuel Elom --- components/script/layout_image.rs | 5 ++- tests/wpt/mozilla/meta/MANIFEST.json | 7 ++++ .../mozilla/background_image_csp.sub.html | 34 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/tests/mozilla/background_image_csp.sub.html diff --git a/components/script/layout_image.rs b/components/script/layout_image.rs index 7fd23804ffd..df542b4b759 100644 --- a/components/script/layout_image.rs +++ b/components/script/layout_image.rs @@ -119,7 +119,10 @@ pub(crate) fn fetch_image_for_layout( ) .origin(document.origin().immutable().clone()) .destination(Destination::Image) - .pipeline_id(Some(document.global().pipeline_id())); + .pipeline_id(Some(document.global().pipeline_id())) + .insecure_requests_policy(document.insecure_requests_policy()) + .has_trustworthy_ancestor_origin(document.has_trustworthy_ancestor_origin()) + .policy_container(document.policy_container().to_owned()); // Layout image loads do not delay the document load event. document.fetch_background(request, context); diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index c18a78786aa..2cf09181acc 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -12755,6 +12755,13 @@ {} ] ], + "background_image_csp.sub.html": [ + "c326f54de52c6a36cbaf4871c947c5b785cac83d", + [ + null, + {} + ] + ], "binding_keyword.html": [ "818d2aa29471026c1b4215dfcd1b9939a052b1ea", [ diff --git a/tests/wpt/mozilla/tests/mozilla/background_image_csp.sub.html b/tests/wpt/mozilla/tests/mozilla/background_image_csp.sub.html new file mode 100644 index 00000000000..c326f54de52 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/background_image_csp.sub.html @@ -0,0 +1,34 @@ + + + + + +
+ +