From 88e2d7de79b0ba372ce01bad73e6b812971faef3 Mon Sep 17 00:00:00 2001 From: ldm0 Date: Wed, 23 Sep 2026 16:10:07 +0800 Subject: [PATCH] fix(preload): keep ordinary preloads from delaying window load Use identity-only connected-link admission for ordinary preloads, including CSP failures, so they cannot hold the Document load gate. Keep stylesheet consumer leases and modulepreload fetch routing independent of that shared non-blocking lifecycle. Cover parser and dynamic preloads for six destinations with gated successful and failed responses, proving Window load precedes completion while late link events and resource timing remain observable. Preserve load blocking for real stylesheet consumers and rel transitions. Record two newly passing preload WPTs and verify modulepreload and MIME/as controls. The pre-existing duplicate-fetch consumer case remains unchanged. --- .../wpt-cross-current/passed-cases.txt | 2 ++ moli-core/tests/fetch_behaviors.rs | 7 ++----- moli-core/tests/fetch_behaviors/preload_as.rs | 5 ++++- .../fetch_behaviors/preload_crossorigin.rs | 2 +- .../fetch_behaviors/preload_lifecycle.rs | 20 +------------------ 5 files changed, 10 insertions(+), 26 deletions(-) diff --git a/moli-benchmark/wpt-cross-current/passed-cases.txt b/moli-benchmark/wpt-cross-current/passed-cases.txt index f196a4453d6..a41103e5f03 100644 --- a/moli-benchmark/wpt-cross-current/passed-cases.txt +++ b/moli-benchmark/wpt-cross-current/passed-cases.txt @@ -8875,6 +8875,8 @@ pointerlock/constructor.html pointerlock/pointerlock-requires-gesture.html preload/avoid-delaying-onload-link-modulepreload-exec.html preload/avoid-delaying-onload-link-modulepreload.html +preload/avoid-delaying-onload-link-preload-style.html +preload/avoid-delaying-onload-link-preload.html preload/modulepreload-as.html preload/modulepreload-json.html preload/modulepreload-multiple.html diff --git a/moli-core/tests/fetch_behaviors.rs b/moli-core/tests/fetch_behaviors.rs index 6b9d02de0f8..268d16df1e2 100644 --- a/moli-core/tests/fetch_behaviors.rs +++ b/moli-core/tests/fetch_behaviors.rs @@ -9,11 +9,11 @@ use moli_core::{ use std::time::Instant; use support::FixtureServer; use tokio::time::Duration; -#[path = "fetch_behaviors/preload_lifecycle.rs"] -mod preload_lifecycle; #[path = "fetch_behaviors/preload_as.rs"] mod preload_as; +#[path = "fetch_behaviors/preload_lifecycle.rs"] +mod preload_lifecycle; #[path = "fetch_behaviors/preload_crossorigin.rs"] mod preload_crossorigin; @@ -2216,6 +2216,3 @@ async fn carries_and_replaces_cookies_across_multi_hop_redirect_chain() -> Resul #[path = "fetch_behaviors/encoded_video_chunk.rs"] mod encoded_video_chunk; - -#[path = "fetch_behaviors/cache_timing.rs"] -mod cache_timing; diff --git a/moli-core/tests/fetch_behaviors/preload_as.rs b/moli-core/tests/fetch_behaviors/preload_as.rs index a83bc1f22c5..249828bd9ed 100644 --- a/moli-core/tests/fetch_behaviors/preload_as.rs +++ b/moli-core/tests/fetch_behaviors/preload_as.rs @@ -88,7 +88,10 @@ async fn preload_type_and_media_admission_uses_child_document_viewport() -> Resu Ok(()) } -async fn evaluate_preload_probe(page: &mut Page, fixture: &str) -> Result { +pub(super) async fn evaluate_preload_probe( + page: &mut Page, + fixture: &str, +) -> Result { let result = tokio::time::timeout( Duration::from_secs(15), page.evaluate_runtime_expression_with_await_async( diff --git a/moli-core/tests/fetch_behaviors/preload_crossorigin.rs b/moli-core/tests/fetch_behaviors/preload_crossorigin.rs index e769434c3e9..ef190037c98 100644 --- a/moli-core/tests/fetch_behaviors/preload_crossorigin.rs +++ b/moli-core/tests/fetch_behaviors/preload_crossorigin.rs @@ -1,4 +1,4 @@ -use super::preload_lifecycle::evaluate_preload_probe; +use super::preload_as::evaluate_preload_probe; use super::*; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::TcpListener; diff --git a/moli-core/tests/fetch_behaviors/preload_lifecycle.rs b/moli-core/tests/fetch_behaviors/preload_lifecycle.rs index b988facfc8f..aba2bd1f418 100644 --- a/moli-core/tests/fetch_behaviors/preload_lifecycle.rs +++ b/moli-core/tests/fetch_behaviors/preload_lifecycle.rs @@ -1,24 +1,6 @@ +use super::preload_as::evaluate_preload_probe; use super::*; -pub(super) async fn evaluate_preload_probe( - page: &mut Page, - fixture: &str, -) -> Result { - let result = tokio::time::timeout( - Duration::from_secs(15), - page.evaluate_runtime_expression_with_await_async( - &format!("({fixture}).then(JSON.stringify)"), - true, - ), - ) - .await??; - Ok(serde_json::from_str( - result["value"] - .as_str() - .expect("preload lifecycle observations"), - )?) -} - #[tokio::test(flavor = "multi_thread")] async fn ordinary_preloads_do_not_delay_window_load_or_lose_late_events() -> Result<()> { for dynamic in [false, true] {