Truly independent web browser
LibWeb: Give scripts their fetch options
Andreas Klinga6285bffc171
diff --git a/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Libraries/LibWeb/Bindings/MainThreadVM.cppindex 207fab9648e..5bd8616379a 100644--- a/Libraries/LibWeb/Bindings/MainThreadVM.cpp+++ b/Libraries/LibWeb/Bindings/MainThreadVM.cpp@@ -515,7 +515,8 @@ void initialize_main_thread_vm(HTML::AgentType type)// 3. Set fetchReferrer to referencingScript's base URL.fetch_referrer = referencing_script->base_url().value();- // FIXME: 4. Set originalFetchOptions to referencingScript's fetch options.+ // 4. Set originalFetchOptions to referencingScript's fetch options.+ original_fetch_options = referencing_script->fetch_options();}// 7. If referrer is a Cyclic Module Record and moduleRequest is equal to the first element of referrer.[[RequestedModules]], then:diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Libraries/LibWeb/HTML/HTMLScriptElement.cppindex 4307aa90ddb..371ff02254d 100644--- a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp@@ -510,8 +510,8 @@ void HTMLScriptElement::prepare_script()// -> "classic"if (m_script_type == ScriptType::Classic) {// 1. Let script be the result of creating a classic script using source text, settings object, base URL, and options.- // FIXME: Pass options.auto script = ClassicScript::create(m_document->url().to_byte_string(), source_text, settings_object, base_url, m_source_line_number, ClassicScript::MutedErrors::No, ScriptRegistry::IsInlineSource::Yes);+ script->set_fetch_options(options);// 2. Mark as ready el given script.mark_as_ready(Result(move(script)));@@ -533,8 +533,7 @@ void HTMLScriptElement::prepare_script()});// 2. Fetch an inline module script graph, given source text, base URL, settings object, options, and with the following steps given result:- // FIXME: Pass options- fetch_inline_module_script_graph(HTML::relevant_realm(*this), m_document->url().to_byte_string(), source_text.utf16_view(), base_url, document().relevant_settings_object(), m_source_line_number, steps);+ fetch_inline_module_script_graph(HTML::relevant_realm(*this), m_document->url().to_byte_string(), source_text.utf16_view(), base_url, document().relevant_settings_object(), options, m_source_line_number, steps);}// -> "importmap"else if (m_script_type == ScriptType::ImportMap) {diff --git a/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp b/Libraries/LibWeb/HTML/Scripting/ClassicScript.cppindex 0fba71ad865..953e7dcb5a0 100644--- a/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp+++ b/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp@@ -47,7 +47,8 @@ GC::Ref<ClassicScript> ClassicScript::create(ByteString filename, Utf16View sour// 5. Set script's base URL to baseURL.auto script = GC::Heap::the().allocate<ClassicScript>(move(base_url), move(filename), settings);- // FIXME: 6. Set script's fetch options to options.+ // 6. Set script's fetch options to options.+ // NB: Callers set the script's fetch options once it has been created.// 7. Set script's muted errors to muted errors.script->m_muted_errors = muted_errors;diff --git a/Libraries/LibWeb/HTML/Scripting/Fetching.cpp b/Libraries/LibWeb/HTML/Scripting/Fetching.cppindex 6345cd8bacf..55bb2ba70ac 100644--- a/Libraries/LibWeb/HTML/Scripting/Fetching.cpp+++ b/Libraries/LibWeb/HTML/Scripting/Fetching.cpp@@ -650,6 +650,14 @@ void fetch_classic_script(GC::Ref<HTMLScriptElement> element, URL::URL const& ur// 4. Set up the classic script request given request and options.set_up_classic_script_request(*request, options);+ // NB: The script is created in several places below. They all hand it to onComplete, which is where we set its+ // fetch options to options.+ on_complete = create_on_fetch_script_complete(GC::Heap::the(), [options, on_complete](GC::Ptr<Script> script) {+ if (script)+ script->set_fetch_options(options);+ on_complete->function()(script);+ });+// 5. Fetch request with the following processResponseConsumeBody steps given response response and null, failure,// or a byte sequence bodyBytes:Fetch::Infrastructure::FetchAlgorithms::Input fetch_algorithms_input {};@@ -685,7 +693,6 @@ void fetch_classic_script(GC::Ref<HTMLScriptElement> element, URL::URL const& ur// 7. Let script be the result of creating a classic script given source text, settings object's realm, response's URL,// options, and muted errors.- // FIXME: Pass options.auto response_url = response->url().value_or({});auto on_complete_root = GC::make_root(on_complete);@@ -1085,7 +1092,7 @@ void fetch_single_module_script(JS::Realm& realm,// 13. If performFetch was given, run performFetch with request, isTopLevel, and with processResponseConsumeBody as defined below.// Otherwise, fetch request with processResponseConsumeBody set to processResponseConsumeBody as defined below.// In both cases, let processResponseConsumeBody given response response and null, failure, or a byte sequence bodyBytes be the following algorithm:- auto process_response_consume_body = [request, &module_map, url, module_type, &settings_object](GC::Ref<Fetch::Infrastructure::Response> response, Fetch::Infrastructure::FetchAlgorithms::BodyBytes body_bytes) {+ auto process_response_consume_body = [request, &module_map, url, module_type, &settings_object, options](GC::Ref<Fetch::Infrastructure::Response> response, Fetch::Infrastructure::FetchAlgorithms::BodyBytes body_bytes) {auto internal_response = response->unsafe_response();// 1. If any of the following are true:@@ -1113,9 +1120,10 @@ void fetch_single_module_script(JS::Realm& realm,// 6. If mimeType's essence is "application/wasm" and moduleType is "javascript-or-wasm", then set moduleScript// to the result of creating a WebAssembly module script given bodyBytes, settingsObject, response's URL, and// options.- // FIXME: Pass options.if (mime_type.has_value() && mime_type->essence() == "application/wasm"sv && module_type == "javascript-or-wasm"sv) {module_script = ModuleScript::create_a_webassembly_module_script(url.to_byte_string(), take_body_bytes_as_byte_buffer(body_bytes), settings_object, response->url().value_or({})).release_value_but_fixme_should_propagate_errors();+ if (module_script)+ module_script->set_fetch_options(options);}// 7. Otherwise@@ -1133,7 +1141,6 @@ void fetch_single_module_script(JS::Realm& realm,// 3. If mimeType is a JavaScript MIME type and moduleType is "javascript-or-wasm", then set moduleScript to// the result of creating a JavaScript module script given sourceText, settingsObject, response's URL,// and options.- // FIXME: Pass options.if (mime_type.has_value() && mime_type->is_javascript() && module_type == "javascript-or-wasm"sv) {auto settings_root = GC::make_root(settings_object);auto url_string = url.to_byte_string();@@ -1158,7 +1165,7 @@ void fetch_single_module_script(JS::Realm& realm,bytecode_cache_context = move(bytecode_cache_context),source_hash = move(source_hash),source_length,- settings_root = move(settings_root)](auto bytecode_cache) mutable {+ options, settings_root = move(settings_root)](auto bytecode_cache) mutable {Optional<NonnullRefPtr<JS::SourceCode const>> source_code;if (bytecode_cache) {source_code = JS::SourceCode::create(@@ -1168,6 +1175,7 @@ void fetch_single_module_script(JS::Realm& realm,source_byte_storage);auto module_script = ModuleScript::create_from_bytecode_cache(url_string, *source_code, *settings_root, response_url, bytecode_cache.release_nonnull()).release_value_but_fixme_should_propagate_errors();if (module_script && module_script->parse_error().is_null()) {+ module_script->set_fetch_options(options);settings_root->module_map().complete_fetch(url, module_type_string, module_script);return;}@@ -1187,7 +1195,7 @@ void fetch_single_module_script(JS::Realm& realm,module_type_string = move(module_type_string),bytecode_cache_context = move(bytecode_cache_context),source_hash = move(source_hash),- settings_root = move(settings_root)](auto result, auto source_code) mutable {+ options, settings_root = move(settings_root)](auto result, auto source_code) mutable {auto source_code_for_cache = source_code;auto should_generate_bytecode_cache = result.compiled && bytecode_cache_context.has_value();auto module_script = result.compiled@@ -1195,6 +1203,7 @@ void fetch_single_module_script(JS::Realm& realm,: ModuleScript::create_from_pre_parsed(url_string, move(source_code), *settings_root, move(response_url), move(result.parsed)).release_value_but_fixme_should_propagate_errors();BytecodeCacheInstallTarget install_target;if (module_script) {+ module_script->set_fetch_options(options);module_script->record().visit([](Empty) { },[&](GC::Ref<JS::SourceTextModule> module) { install_target.module = module; },@@ -1226,7 +1235,7 @@ void fetch_single_module_script(JS::Realm& realm,module_type_string = move(module_type_string),bytecode_cache_context = move(bytecode_cache_context),source_hash = move(source_hash),- settings_root = move(settings_root)](auto result, auto source_code) mutable {+ options, settings_root = move(settings_root)](auto result, auto source_code) mutable {auto source_code_for_cache = source_code;auto should_generate_bytecode_cache = result.compiled && bytecode_cache_context.has_value();auto module_script = result.compiled@@ -1234,6 +1243,7 @@ void fetch_single_module_script(JS::Realm& realm,: ModuleScript::create_from_pre_parsed(url_string, move(source_code), *settings_root, move(response_url), move(result.parsed)).release_value_but_fixme_should_propagate_errors();BytecodeCacheInstallTarget install_target;if (module_script) {+ module_script->set_fetch_options(options);module_script->record().visit([](Empty) { },[&](GC::Ref<JS::SourceTextModule> module) { install_target.module = module; },@@ -1343,10 +1353,11 @@ void fetch_modulepreload_module_script_graph(JS::Realm& realm, URL::URL const& u}// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-an-inline-module-script-graph-void fetch_inline_module_script_graph(JS::Realm& realm, ByteString const& filename, Utf16View source_text, URL::URL const& base_url, EnvironmentSettingsObject& settings_object, size_t source_line_number, OnFetchScriptComplete on_complete)+void fetch_inline_module_script_graph(JS::Realm& realm, ByteString const& filename, Utf16View source_text, URL::URL const& base_url, EnvironmentSettingsObject& settings_object, ScriptFetchOptions const& options, size_t source_line_number, OnFetchScriptComplete on_complete){// 1. Let script be the result of creating a JavaScript module script using sourceText, settingsObject, baseURL, and options.auto script = ModuleScript::create_a_javascript_module_script(filename, source_text, settings_object, base_url, source_line_number, ScriptRegistry::IsInlineSource::Yes).release_value_but_fixme_should_propagate_errors();+ script->set_fetch_options(options);// 2. Fetch the descendants of and link script, given settingsObject, "script", and onComplete.fetch_descendants_of_and_link_a_module_script(realm, *script, settings_object, Fetch::Infrastructure::Request::Destination::Script, nullptr, on_complete);diff --git a/Libraries/LibWeb/HTML/Scripting/Fetching.h b/Libraries/LibWeb/HTML/Scripting/Fetching.hindex 22a0465a6ce..20d74894753 100644--- a/Libraries/LibWeb/HTML/Scripting/Fetching.h+++ b/Libraries/LibWeb/HTML/Scripting/Fetching.h@@ -14,6 +14,7 @@#include <LibWeb/HTML/Scripting/ImportMap.h>#include <LibWeb/HTML/Scripting/ModuleMap.h>#include <LibWeb/HTML/Scripting/ModuleScript.h>+#include <LibWeb/HTML/Scripting/ScriptFetchOptions.h>#include <LibWebCommon/ReferrerPolicy/ReferrerPolicy.h>namespace Web::HTML {@@ -29,33 +30,6 @@ using PerformTheFetchHook = GC::Ptr<GC::Function<WebIDL::ExceptionOr<void>(GC::RWEB_API OnFetchScriptComplete create_on_fetch_script_complete(GC::Heap& heap, Function<void(GC::Ptr<Script>)> function);WEB_API PerformTheFetchHook create_perform_the_fetch_hook(GC::Heap& heap, Function<WebIDL::ExceptionOr<void>(GC::Ref<Fetch::Infrastructure::Request>, TopLevelModule, Fetch::Infrastructure::FetchAlgorithms::ProcessResponseConsumeBodyFunction)> function);-// https://html.spec.whatwg.org/multipage/webappapis.html#script-fetch-options-struct ScriptFetchOptions {- // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-nonce- Utf16String cryptographic_nonce {};-- // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-integrity- Utf16String integrity_metadata {};-- // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-parser- Fetch::Infrastructure::Request::ParserMetadata parser_metadata { Fetch::Infrastructure::Request::ParserMetadata::NotParserInserted };-- // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-credentials- Fetch::Infrastructure::Request::CredentialsMode credentials_mode { Fetch::Infrastructure::Request::CredentialsMode::SameOrigin };-- // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-referrer-policy- ReferrerPolicy::ReferrerPolicy referrer_policy { ReferrerPolicy::ReferrerPolicy::EmptyString };-- // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-render-blocking- bool render_blocking { false };-- // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-fetch-priority- Fetch::Infrastructure::Request::Priority fetch_priority {};-};--// https://html.spec.whatwg.org/multipage/webappapis.html#default-script-fetch-options-ScriptFetchOptions default_script_fetch_options();-class FetchContext : public JS::Cell {GC_CELL(FetchContext, JS::Cell);GC_DECLARE_ALLOCATOR(FetchContext);@@ -98,7 +72,7 @@ WEB_API WebIDL::ExceptionOr<void> fetch_module_worker_script_graph(URL::URL consWebIDL::ExceptionOr<void> fetch_worklet_module_worker_script_graph(URL::URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook, OnFetchScriptComplete, Fetch::Infrastructure::Request::CredentialsMode = Fetch::Infrastructure::Request::CredentialsMode::SameOrigin);void fetch_external_module_script_graph(JS::Realm&, URL::URL const&, EnvironmentSettingsObject& settings_object, ScriptFetchOptions const&, OnFetchScriptComplete on_complete);void fetch_modulepreload_module_script_graph(JS::Realm&, URL::URL const&, Fetch::Infrastructure::Request::Destination, EnvironmentSettingsObject& settings_object, ScriptFetchOptions const&, OnFetchScriptComplete on_complete);-void fetch_inline_module_script_graph(JS::Realm&, ByteString const& filename, Utf16View source_text, URL::URL const& base_url, EnvironmentSettingsObject& settings_object, size_t source_line_number, OnFetchScriptComplete on_complete);+void fetch_inline_module_script_graph(JS::Realm&, ByteString const& filename, Utf16View source_text, URL::URL const& base_url, EnvironmentSettingsObject& settings_object, ScriptFetchOptions const& options, size_t source_line_number, OnFetchScriptComplete on_complete);void fetch_single_imported_module_script(JS::Realm&, URL::URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, ScriptFetchOptions const&, EnvironmentSettingsObject&, Fetch::Infrastructure::Request::ReferrerType, JS::ModuleRequest const&, PerformTheFetchHook, OnFetchScriptComplete on_complete);void fetch_descendants_of_and_link_a_module_script(JS::Realm&, ModuleScript&, EnvironmentSettingsObject&, Fetch::Infrastructure::Request::Destination, PerformTheFetchHook, OnFetchScriptComplete on_complete);diff --git a/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp b/Libraries/LibWeb/HTML/Scripting/ModuleScript.cppindex 2e71b31c958..ae9596ecbea 100644--- a/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp+++ b/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp@@ -63,7 +63,8 @@ WebIDL::ExceptionOr<GC::Ptr<ModuleScript>> ModuleScript::create_a_javascript_mod// 4. Set script's base URL to baseURL.auto script = create_internal(move(base_url), filename, settings);- // FIXME: 5. Set script's fetch options to options.+ // 5. Set script's fetch options to options.+ // NB: Callers set the script's fetch options once it has been created.// 6. Set script's parse error and error to rethrow to null.script->set_parse_error(JS::js_null());@@ -262,7 +263,8 @@ WebIDL::ExceptionOr<GC::Ptr<ModuleScript>> ModuleScript::create_a_webassembly_mo// 2. Let script be a new module script that this algorithm will subsequently initialize.// 3. Set script's settings object to settings.// 4. Set script's base URL to baseURL.- // FIXME: 5. Set script's fetch options to options.+ // 5. Set script's fetch options to options.+ // NB: Callers set the script's fetch options once it has been created.auto script = create_internal(move(base_url), filename, settings);// 6. Set script's parse error and error to rethrow to null.diff --git a/Libraries/LibWeb/HTML/Scripting/Script.cpp b/Libraries/LibWeb/HTML/Scripting/Script.cppindex 0d71c84d91b..ffb0194c941 100644--- a/Libraries/LibWeb/HTML/Scripting/Script.cpp+++ b/Libraries/LibWeb/HTML/Scripting/Script.cpp@@ -4,9 +4,11 @@* SPDX-License-Identifier: BSD-2-Clause*/+#include <AK/NeverDestroyed.h>#include <LibWeb/DOM/Document.h>#include <LibWeb/HTML/Scripting/Environments.h>#include <LibWeb/HTML/Scripting/Script.h>+#include <LibWeb/HTML/Scripting/ScriptFetchOptions.h>#include <LibWeb/Page/Page.h>namespace Web::HTML {@@ -57,6 +59,19 @@ Script::Script(Optional<URL::URL> base_url, ByteString filename, Utf16String disScript::~Script() = default;+ScriptFetchOptions const& Script::fetch_options() const+{+ static NeverDestroyed<ScriptFetchOptions> default_fetch_options { default_script_fetch_options() };+ if (!m_fetch_options)+ return *default_fetch_options;+ return *m_fetch_options;+}++void Script::set_fetch_options(ScriptFetchOptions fetch_options)+{+ m_fetch_options = make<ScriptFetchOptions>(move(fetch_options));+}+EnvironmentSettingsObject& Script::settings_object(){return m_settings;diff --git a/Libraries/LibWeb/HTML/Scripting/Script.h b/Libraries/LibWeb/HTML/Scripting/Script.hindex 9432c410dc3..a6f73aac823 100644--- a/Libraries/LibWeb/HTML/Scripting/Script.h+++ b/Libraries/LibWeb/HTML/Scripting/Script.h@@ -6,6 +6,7 @@#pragma once+#include <AK/OwnPtr.h>#include <AK/Utf16String.h>#include <LibJS/Heap/Cell.h>#include <LibJS/Position.h>@@ -18,6 +19,8 @@namespace Web::HTML {+struct ScriptFetchOptions;+// https://html.spec.whatwg.org/multipage/webappapis.html#concept-scriptclass WEB_API Script : public JS::Cell {GC_CELL(Script, JS::Cell);@@ -35,6 +38,9 @@ public:EnvironmentSettingsObject& settings_object();+ ScriptFetchOptions const& fetch_options() const;+ void set_fetch_options(ScriptFetchOptions);+[[nodiscard]] JS::Value error_to_rethrow() const { return m_error_to_rethrow; }void set_error_to_rethrow(JS::Value value) { m_error_to_rethrow = value; }@@ -66,6 +72,10 @@ private:// An environment settings object, containing various settings that are shared with other scripts in the same context.GC::Ref<EnvironmentSettingsObject> m_settings;+ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-script-fetch-options+ // NB: This is null while the script has the default script fetch options.+ OwnPtr<ScriptFetchOptions> m_fetch_options;+// https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-parse-errorJS::Value m_parse_error;Optional<JS::Position> m_parse_error_position;diff --git a/Libraries/LibWeb/HTML/Scripting/ScriptFetchOptions.h b/Libraries/LibWeb/HTML/Scripting/ScriptFetchOptions.hnew file mode 100644index 00000000000..0eb78e2d94f--- /dev/null+++ b/Libraries/LibWeb/HTML/Scripting/ScriptFetchOptions.h@@ -0,0 +1,44 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <AK/Utf16String.h>+#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>+#include <LibWebCommon/ReferrerPolicy/ReferrerPolicy.h>++namespace Web::HTML {++// https://html.spec.whatwg.org/multipage/webappapis.html#script-fetch-options+struct ScriptFetchOptions {+ AK_ALLOC_WITH_KMALLOC;++ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-nonce+ Utf16String cryptographic_nonce {};++ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-integrity+ Utf16String integrity_metadata {};++ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-parser+ Fetch::Infrastructure::Request::ParserMetadata parser_metadata { Fetch::Infrastructure::Request::ParserMetadata::NotParserInserted };++ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-credentials+ Fetch::Infrastructure::Request::CredentialsMode credentials_mode { Fetch::Infrastructure::Request::CredentialsMode::SameOrigin };++ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-referrer-policy+ ReferrerPolicy::ReferrerPolicy referrer_policy { ReferrerPolicy::ReferrerPolicy::EmptyString };++ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-render-blocking+ bool render_blocking { false };++ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-fetch-priority+ Fetch::Infrastructure::Request::Priority fetch_priority {};+};++// https://html.spec.whatwg.org/multipage/webappapis.html#default-script-fetch-options+ScriptFetchOptions default_script_fetch_options();++}diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cppindex 1a8425a5580..df71f102ec2 100644--- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp+++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp@@ -879,16 +879,25 @@ WebIDL::ExceptionOr<i32> WindowOrWorkerGlobalScopeMixin::run_timer_initializatioauto& settings_object = relevant_settings_object(*this);// 3. Let fetch options be the default classic script fetch options.- ScriptFetchOptions options {};+ auto options = default_script_fetch_options();// 4. Let base URL be settings object's API base URL.auto base_url = settings_object.api_base_url();// 5. If initiating script is not null, then:if (initiating_script) {- // FIXME: 1. Set fetch options to a script fetch options whose cryptographic nonce is initiating script's fetch options's cryptographic nonce,- // integrity metadata is the empty string, parser metadata is "not-parser-inserted", credentials mode is initiating script's fetch- // options's credentials mode, referrer policy is initiating script's fetch options's referrer policy, and fetch priority is "auto".+ // 1. Set fetch options to a script fetch options whose cryptographic nonce is initiating script's fetch options's cryptographic nonce,+ // integrity metadata is the empty string, parser metadata is "not-parser-inserted", credentials mode is initiating script's fetch+ // options's credentials mode, referrer policy is initiating script's fetch options's referrer policy, and fetch priority is "auto".+ auto const& initiating_options = initiating_script->fetch_options();+ options = ScriptFetchOptions {+ .cryptographic_nonce = initiating_options.cryptographic_nonce,+ .integrity_metadata = {},+ .parser_metadata = Fetch::Infrastructure::Request::ParserMetadata::NotParserInserted,+ .credentials_mode = initiating_options.credentials_mode,+ .referrer_policy = initiating_options.referrer_policy,+ .fetch_priority = Fetch::Infrastructure::Request::Priority::Auto,+ };// 2. Set base URL to initiating script's base URL.base_url = initiating_script->base_url().value();@@ -898,9 +907,9 @@ WebIDL::ExceptionOr<i32> WindowOrWorkerGlobalScopeMixin::run_timer_initializatio}// 6. Let script be the result of creating a classic script given handler, settings object, base URL, and fetch options.- // FIXME: Pass fetch options.auto filename = base_url.to_byte_string();auto script = ClassicScript::create(move(filename), source, settings_object, move(base_url));+ script->set_fetch_options(move(options));// 7. Run the classic script script.(void)script->run();diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-external-classic.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-external-classic.txtindex 2ab7d7edd0c..59c946e73f9 100644--- a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-external-classic.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-external-classic.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Dynamically imported module should eval when imported from script w/ a valid nonce.\ No newline at end of file+1 Pass+Pass Dynamically imported module should eval when imported from script w/ a valid nonce.\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-external-module.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-external-module.txtindex 2ab7d7edd0c..59c946e73f9 100644--- a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-external-module.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-external-module.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Dynamically imported module should eval when imported from script w/ a valid nonce.\ No newline at end of file+1 Pass+Pass Dynamically imported module should eval when imported from script w/ a valid nonce.\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-inline-classic.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-inline-classic.txtindex 2ab7d7edd0c..59c946e73f9 100644--- a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-inline-classic.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-inline-classic.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Dynamically imported module should eval when imported from script w/ a valid nonce.\ No newline at end of file+1 Pass+Pass Dynamically imported module should eval when imported from script w/ a valid nonce.\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-inline-module.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-inline-module.txtindex 2ab7d7edd0c..59c946e73f9 100644--- a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-inline-module.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/scripting-1/the-script-element/module/dynamic-import/propagate-nonce-inline-module.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Dynamically imported module should eval when imported from script w/ a valid nonce.\ No newline at end of file+1 Pass+Pass Dynamically imported module should eval when imported from script w/ a valid nonce.\ No newline at end of file