script: revamp module script loading to follow current spec (#41779)

Rewrite module script fetching logic to follow current spec.

Testing: Covered by existing wpt tests
Fixes: #31397

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
Gae24
2026-01-22 12:40:53 +01:00
committed by GitHub
parent 52efe439fc
commit a953ba954a
20 changed files with 1058 additions and 892 deletions

View File

@@ -62,7 +62,7 @@ use crate::dom::window::Window;
use crate::fetch::{RequestWithGlobalScope, create_a_potential_cors_request};
use crate::network_listener::{self, FetchResponseListener, ResourceTimingListener};
use crate::script_module::{
ImportMap, ModuleOwner, ModuleTree, ScriptFetchOptions, fetch_external_module_script,
ImportMap, ModuleOwner, ModuleTree, ScriptFetchOptions, fetch_an_external_module_script,
fetch_inline_module_script, parse_an_import_map_string, register_import_map,
};
use crate::script_runtime::{CanGc, IntroductionType};
@@ -842,10 +842,9 @@ impl HTMLScriptElement {
},
ScriptType::Module => {
// Step 31.11. Fetch an external module script graph.
fetch_external_module_script(
ModuleOwner::Window(Trusted::new(self)),
fetch_an_external_module_script(
url.clone(),
Destination::Script,
ModuleOwner::Window(Trusted::new(self)),
options,
can_gc,
);
@@ -916,7 +915,7 @@ impl HTMLScriptElement {
base_url.clone(),
self.id,
options,
self.line_number,
self.line_number as u32,
can_gc,
);
},