feat(script): create import map parse result (#37405)

Implement import map parser
Spec:
https://html.spec.whatwg.org/multipage/#create-an-import-map-parse-result

- Create an import map parse result
- Sorting and normalizing a module specifier map
- Sorting and normalizing scopes
- Normalizing a module integrity map

Testing: should pass current WPT
Fixes: part of https://github.com/servo/servo/issues/37316

---------

Signed-off-by: Jason Tsai <git@pews.dev>
Co-authored-by: Wu Yu Wei <yuweiwu@pm.me>
This commit is contained in:
Jason Tsai 2025-06-12 18:34:31 +09:00 committed by GitHub
parent f242c120b6
commit 41bed9840a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 338 additions and 4 deletions

View file

@ -76,6 +76,7 @@ use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingLi
use crate::realms::enter_realm;
use crate::script_module::{
ModuleOwner, ScriptFetchOptions, fetch_external_module_script, fetch_inline_module_script,
parse_an_import_map_string,
};
use crate::script_runtime::CanGc;
use crate::task_source::{SendableTaskSource, TaskSourceName};
@ -967,8 +968,14 @@ impl HTMLScriptElement {
);
},
ScriptType::ImportMap => {
// TODO: Let result be the result of creating an import map
// Step 32.1 Let result be the result of creating an import map
// parse result given source text and base URL.
let _result = parse_an_import_map_string(
ModuleOwner::Window(Trusted::new(self)),
text_rc,
base_url.clone(),
can_gc,
);
},
}
}