mirror of
https://github.com/lexmount/moli.git
synced 2026-11-20 16:03:35 +00:00
fix(import-maps): merge maps after module loading
This commit is contained in:
+2
-2
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
window.dynamicAsyncImportMapErrors = 0;
|
||||
window.addEventListener("error", () => {
|
||||
window.dynamicAsyncImportMapErrors =
|
||||
(window.dynamicAsyncImportMapErrors || 0) + 1;
|
||||
window.dynamicAsyncImportMapErrors += 1;
|
||||
});
|
||||
|
||||
const firstModule = document.createElement("script");
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
<body>
|
||||
<script>
|
||||
window.parserImportMapAfterDynamicModuleErrors = 0;
|
||||
window.addEventListener("error", () => {
|
||||
window.parserImportMapAfterDynamicModuleErrors =
|
||||
(window.parserImportMapAfterDynamicModuleErrors || 0) + 1;
|
||||
window.parserImportMapAfterDynamicModuleErrors += 1;
|
||||
});
|
||||
|
||||
const dynamicModule = document.createElement('script');
|
||||
+2
-2
@@ -13,9 +13,9 @@
|
||||
window.parserModuleAcquisitionFirstGreeting = greeting;
|
||||
</script>
|
||||
<script>
|
||||
window.parserModuleAcquisitionLateErrors = 0;
|
||||
window.addEventListener("error", () => {
|
||||
window.parserModuleAcquisitionLateErrors =
|
||||
(window.parserModuleAcquisitionLateErrors || 0) + 1;
|
||||
window.parserModuleAcquisitionLateErrors += 1;
|
||||
});
|
||||
|
||||
const lateMap = document.createElement("script");
|
||||
@@ -3409,12 +3409,12 @@ async fn importmap_registered_after_module_load_adds_unresolved_mapping() -> Res
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn dynamic_async_module_does_not_close_multiple_import_map_registration() -> Result<()> {
|
||||
async fn dynamic_async_module_allows_late_importmap() -> Result<()> {
|
||||
let server = FixtureServer::spawn().await?;
|
||||
let browser = Browser::new(AppConfig::default())?;
|
||||
|
||||
let page = browser
|
||||
.fetch(&server.url("/compat/dynamic-async-module-closes-importmap-acquisition"))
|
||||
.fetch(&server.url("/compat/dynamic-async-module-allows-late-importmap"))
|
||||
.await?;
|
||||
assert_eq!(diagnostic_global(&page, "dynamicAsyncImportMapLoads"), None);
|
||||
assert_eq!(
|
||||
@@ -3423,7 +3423,7 @@ async fn dynamic_async_module_does_not_close_multiple_import_map_registration()
|
||||
);
|
||||
assert_eq!(
|
||||
diagnostic_global(&page, "dynamicAsyncImportMapErrors"),
|
||||
None
|
||||
Some(&JsValueSnapshot::Number(0.0))
|
||||
);
|
||||
assert_eq!(
|
||||
diagnostic_global(&page, "dynamicAsyncModuleReady"),
|
||||
@@ -3436,14 +3436,12 @@ async fn dynamic_async_module_does_not_close_multiple_import_map_registration()
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn parser_owned_module_allows_late_dynamic_map_to_add_unresolved_mapping() -> Result<()> {
|
||||
async fn parser_owned_module_allows_late_dynamic_importmap() -> Result<()> {
|
||||
let server = FixtureServer::spawn().await?;
|
||||
let browser = Browser::new(AppConfig::default())?;
|
||||
|
||||
let page = browser
|
||||
.fetch(
|
||||
&server.url("/compat/importmap-closed-by-parser-owned-module-before-late-dynamic-map"),
|
||||
)
|
||||
.fetch(&server.url("/compat/parser-owned-module-allows-late-dynamic-importmap"))
|
||||
.await?;
|
||||
assert_eq!(
|
||||
diagnostic_global(&page, "parserModuleAcquisitionFirstGreeting"),
|
||||
@@ -3455,7 +3453,7 @@ async fn parser_owned_module_allows_late_dynamic_map_to_add_unresolved_mapping()
|
||||
);
|
||||
assert_eq!(
|
||||
diagnostic_global(&page, "parserModuleAcquisitionLateErrors"),
|
||||
None
|
||||
Some(&JsValueSnapshot::Number(0.0))
|
||||
);
|
||||
assert_eq!(
|
||||
diagnostic_global(&page, "parserModuleAcquisitionMutationDone"),
|
||||
@@ -3467,13 +3465,12 @@ async fn parser_owned_module_allows_late_dynamic_map_to_add_unresolved_mapping()
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn parser_owned_importmap_after_dynamic_module_prepare_adds_unresolved_mapping() -> Result<()>
|
||||
{
|
||||
async fn parser_owned_importmap_applies_after_dynamic_module_prepare() -> Result<()> {
|
||||
let server = FixtureServer::spawn().await?;
|
||||
let browser = Browser::new(AppConfig::default())?;
|
||||
|
||||
let page = browser
|
||||
.fetch(&server.url("/compat/parser-owned-importmap-blocked-after-dynamic-module-prepare"))
|
||||
.fetch(&server.url("/compat/parser-owned-importmap-applies-after-dynamic-module-prepare"))
|
||||
.await?;
|
||||
assert_eq!(
|
||||
diagnostic_global(&page, "dynamicModulePrepareBarrierInstalled"),
|
||||
@@ -3489,7 +3486,7 @@ async fn parser_owned_importmap_after_dynamic_module_prepare_adds_unresolved_map
|
||||
);
|
||||
assert_eq!(
|
||||
diagnostic_global(&page, "parserImportMapAfterDynamicModuleErrors"),
|
||||
None
|
||||
Some(&JsValueSnapshot::Number(0.0))
|
||||
);
|
||||
assert_eq!(
|
||||
diagnostic_global(&page, "parserImportMapAfterDynamicModuleDone"),
|
||||
@@ -6796,12 +6793,6 @@ mod child_markup_insertion;
|
||||
#[path = "scripts/child_input_stream_readiness.rs"]
|
||||
mod child_input_stream_readiness;
|
||||
|
||||
#[path = "scripts/document_close.rs"]
|
||||
mod document_close;
|
||||
|
||||
#[path = "scripts/post_parse_async.rs"]
|
||||
mod post_parse_async;
|
||||
|
||||
#[path = "scripts/text_modules.rs"]
|
||||
mod text_modules;
|
||||
|
||||
|
||||
@@ -988,8 +988,8 @@ const DYNAMIC_SCRIPT_PREPARATION_CONTEXT_STAYS_IN_OLD_DOCUMENT_HTML: &str = incl
|
||||
);
|
||||
const DYNAMIC_IMPORTMAP_BEFORE_MODULE_HTML: &str =
|
||||
include_str!("../../moli-core/tests/fixtures/runtime/dynamic_importmap_before_module.html");
|
||||
const DYNAMIC_ASYNC_MODULE_CLOSES_IMPORTMAP_ACQUISITION_HTML: &str = include_str!(
|
||||
"../../moli-core/tests/fixtures/runtime/dynamic_async_module_closes_importmap_acquisition.html"
|
||||
const DYNAMIC_ASYNC_MODULE_ALLOWS_LATE_IMPORTMAP_HTML: &str = include_str!(
|
||||
"../../moli-core/tests/fixtures/runtime/dynamic_async_module_allows_late_importmap.html"
|
||||
);
|
||||
const DYNAMIC_EXTERNAL_IMPORTMAP_ERROR_BEFORE_MODULE_HTML: &str = include_str!(
|
||||
"../../moli-core/tests/fixtures/runtime/dynamic_external_importmap_error_before_module.html"
|
||||
@@ -1012,11 +1012,11 @@ const IMPORTMAP_URL_LIKE_NORMALIZATION_HTML: &str =
|
||||
include_str!("../../moli-core/tests/fixtures/runtime/importmap_url_like_normalization.html");
|
||||
const IMPORTMAP_AFTER_MODULE_LOAD_HTML: &str =
|
||||
include_str!("../../moli-core/tests/fixtures/runtime/importmap_after_module_load.html");
|
||||
const IMPORTMAP_CLOSED_BY_PARSER_OWNED_MODULE_BEFORE_LATE_DYNAMIC_MAP_HTML: &str = include_str!(
|
||||
"../../moli-core/tests/fixtures/runtime/importmap_closed_by_parser_owned_module_before_late_dynamic_map.html"
|
||||
const PARSER_OWNED_MODULE_ALLOWS_LATE_DYNAMIC_IMPORTMAP_HTML: &str = include_str!(
|
||||
"../../moli-core/tests/fixtures/runtime/parser_owned_module_allows_late_dynamic_importmap.html"
|
||||
);
|
||||
const PARSER_OWNED_IMPORTMAP_BLOCKED_AFTER_DYNAMIC_MODULE_PREPARE_HTML: &str = include_str!(
|
||||
"../../moli-core/tests/fixtures/runtime/parser_owned_importmap_blocked_after_dynamic_module_prepare.html"
|
||||
const PARSER_OWNED_IMPORTMAP_APPLIES_AFTER_DYNAMIC_MODULE_PREPARE_HTML: &str = include_str!(
|
||||
"../../moli-core/tests/fixtures/runtime/parser_owned_importmap_applies_after_dynamic_module_prepare.html"
|
||||
);
|
||||
const IMPORTMAP_NULL_BLOCKS_DYNAMIC_IMPORT_HTML: &str = include_str!(
|
||||
"../../moli-core/tests/fixtures/runtime/importmap_null_blocks_dynamic_import.html"
|
||||
|
||||
@@ -2794,8 +2794,8 @@ pub(super) async fn dynamic_importmap_before_module_page() -> Html<&'static str>
|
||||
Html(DYNAMIC_IMPORTMAP_BEFORE_MODULE_HTML)
|
||||
}
|
||||
|
||||
pub(super) async fn dynamic_async_module_closes_importmap_acquisition_page() -> Html<&'static str> {
|
||||
Html(DYNAMIC_ASYNC_MODULE_CLOSES_IMPORTMAP_ACQUISITION_HTML)
|
||||
pub(super) async fn dynamic_async_module_allows_late_importmap_page() -> Html<&'static str> {
|
||||
Html(DYNAMIC_ASYNC_MODULE_ALLOWS_LATE_IMPORTMAP_HTML)
|
||||
}
|
||||
|
||||
pub(super) async fn dynamic_external_importmap_error_before_module_page() -> Html<&'static str> {
|
||||
@@ -2842,14 +2842,13 @@ pub(super) async fn importmap_after_module_load_page() -> Html<&'static str> {
|
||||
Html(IMPORTMAP_AFTER_MODULE_LOAD_HTML)
|
||||
}
|
||||
|
||||
pub(super) async fn importmap_closed_by_parser_owned_module_before_late_dynamic_map_page()
|
||||
-> Html<&'static str> {
|
||||
Html(IMPORTMAP_CLOSED_BY_PARSER_OWNED_MODULE_BEFORE_LATE_DYNAMIC_MAP_HTML)
|
||||
pub(super) async fn parser_owned_module_allows_late_dynamic_importmap_page() -> Html<&'static str> {
|
||||
Html(PARSER_OWNED_MODULE_ALLOWS_LATE_DYNAMIC_IMPORTMAP_HTML)
|
||||
}
|
||||
|
||||
pub(super) async fn parser_owned_importmap_blocked_after_dynamic_module_prepare_page()
|
||||
pub(super) async fn parser_owned_importmap_applies_after_dynamic_module_prepare_page()
|
||||
-> Html<&'static str> {
|
||||
Html(PARSER_OWNED_IMPORTMAP_BLOCKED_AFTER_DYNAMIC_MODULE_PREPARE_HTML)
|
||||
Html(PARSER_OWNED_IMPORTMAP_APPLIES_AFTER_DYNAMIC_MODULE_PREPARE_HTML)
|
||||
}
|
||||
|
||||
pub(super) async fn importmap_null_blocks_dynamic_import_page() -> Html<&'static str> {
|
||||
|
||||
@@ -1550,8 +1550,8 @@ pub(super) fn build_router() -> Router {
|
||||
get(dynamic_importmap_before_module_page),
|
||||
)
|
||||
.route(
|
||||
"/compat/dynamic-async-module-closes-importmap-acquisition",
|
||||
get(dynamic_async_module_closes_importmap_acquisition_page),
|
||||
"/compat/dynamic-async-module-allows-late-importmap",
|
||||
get(dynamic_async_module_allows_late_importmap_page),
|
||||
)
|
||||
.route(
|
||||
"/compat/dynamic-external-importmap-error-before-module",
|
||||
@@ -1610,12 +1610,12 @@ pub(super) fn build_router() -> Router {
|
||||
get(importmap_after_module_load_page),
|
||||
)
|
||||
.route(
|
||||
"/compat/importmap-closed-by-parser-owned-module-before-late-dynamic-map",
|
||||
get(importmap_closed_by_parser_owned_module_before_late_dynamic_map_page),
|
||||
"/compat/parser-owned-module-allows-late-dynamic-importmap",
|
||||
get(parser_owned_module_allows_late_dynamic_importmap_page),
|
||||
)
|
||||
.route(
|
||||
"/compat/parser-owned-importmap-blocked-after-dynamic-module-prepare",
|
||||
get(parser_owned_importmap_blocked_after_dynamic_module_prepare_page),
|
||||
"/compat/parser-owned-importmap-applies-after-dynamic-module-prepare",
|
||||
get(parser_owned_importmap_applies_after_dynamic_module_prepare_page),
|
||||
)
|
||||
.route(
|
||||
"/compat/importmap-null-blocks-dynamic-import",
|
||||
|
||||
Reference in New Issue
Block a user