LibWeb: Set LinkProcessingOptions' cryptographic_nonce_metadata

Fixes external CSS being blocked on https://beatsaver.com/, where they
have a `style-src` directive set to `'self' 'nonce-[value]'`

Relates to #5643, but does not make the website load.
This commit is contained in:
Luke Wilde 2025-08-05 19:01:27 +01:00 committed by Alexander Kalenik
commit 59162342e6
Notes: github-actions[bot] 2025-08-07 17:29:14 +00:00
3 changed files with 14 additions and 1 deletions

View file

@ -265,6 +265,8 @@ HTMLLinkElement::LinkProcessingOptions HTMLLinkElement::create_link_options()
// 2. Let options be a new link processing options with
LinkProcessingOptions options {
// FIXME: destination the result of translating the state of el's as attribute
// cryptographic nonce metadata the current value of el's [[CryptographicNonce]] internal slot
.cryptographic_nonce_metadata = m_cryptographic_nonce,
// crossorigin the state of el's crossorigin content attribute
.crossorigin = cors_setting_attribute_from_keyword(get_attribute(AttributeNames::crossorigin)),
// referrer policy the state of el's referrerpolicy content attribute
@ -280,7 +282,6 @@ HTMLLinkElement::LinkProcessingOptions HTMLLinkElement::create_link_options()
.policy_container = document.policy_container(),
// document document
.document = &document,
// FIXME: cryptographic nonce metadata the current value of el's [[CryptographicNonce]] internal slot
// fetch priority the state of el's fetchpriority content attribute
.fetch_priority = Fetch::Infrastructure::request_priority_from_string(get_attribute_value(HTML::AttributeNames::fetchpriority)).value_or(Fetch::Infrastructure::Request::Priority::Auto),
};

View file

@ -0,0 +1 @@
rgb(255, 0, 0)

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Security-Policy" content="style-src 'nonce-value';">
<link rel="stylesheet" href="../body-background-color-red.css" nonce="value">
</head>
<script src="../include.js"></script>
<script>
test(() => {
println(window.getComputedStyle(document.body).backgroundColor);
});
</script>