diff --git a/moli-core/src/runtime/tests.rs b/moli-core/src/runtime/tests.rs index 990fac12cbd..d5cb267b0ea 100644 --- a/moli-core/src/runtime/tests.rs +++ b/moli-core/src/runtime/tests.rs @@ -2609,29 +2609,28 @@ async fn best_effort_page_readiness_consumes_only_the_remaining_fetch_deadline() Ok(()) } -#[tokio::test(flavor = "multi_thread")] +#[tokio::test] async fn page_fetch_wait_until_apis_do_not_restart_best_effort_timeout() -> Result<()> { let server = FixtureServer::spawn().await?; let browser = Browser::new(AppConfig::default())?; + let url = server.url("/wait-until-shared-deadline"); - for (wait_until, path) in [ - ( - RenderedDomWaitUntil::NetworkIdle, - "/wait-until-slow-interval-fetch", - ), - ( - RenderedDomWaitUntil::DomStable, - "/wait-until-slow-interval-dom-mutation", - ), + for wait_until in [ + RenderedDomWaitUntil::NetworkIdle, + RenderedDomWaitUntil::DomStable, ] { - let started = std::time::Instant::now(); - let page = browser - .fetch_with_wait_until(&server.url(path), wait_until, Duration::from_secs(1)) + // The main response spends four seconds of the ten-second budget. + // The eight-second subresource stays pending on the shared budget + // and has time to complete if readiness starts a fresh budget. + let mut page = browser + .fetch_with_wait_until(&url, wait_until, Duration::from_secs(10)) .await?; assert!( - started.elapsed() < Duration::from_millis(1_300), - "the Page-returning {wait_until:?} API appears to have started a fresh timeout" + page.serialize_html_async() + .await? + .contains("data-activity=\"pending\""), + "the Page-returning {wait_until:?} API waited for activity beyond the shared deadline" ); page.close_async().await?; } diff --git a/moli-test-support/src/routes_wait.rs b/moli-test-support/src/routes_wait.rs index 3ee0a0792a6..1be49e749f9 100644 --- a/moli-test-support/src/routes_wait.rs +++ b/moli-test-support/src/routes_wait.rs @@ -72,6 +72,13 @@ const WAIT_UNTIL_INTERVAL_FETCH_HTML: &str = "
0
"; const WAIT_UNTIL_SLOW_STATIC_HTML: &str = "
slow-main=ready
"; +const WAIT_UNTIL_SHARED_DEADLINE_HTML: &str = r#" +"#; const WAIT_UNTIL_REDIRECT_STATUS_NAVIGATION_HTML: &str = r#" terminal 302 navigation
redirect-status=challenge
@@ -355,6 +362,14 @@ pub(super) fn add_wait_routes(router: Router) -> Router { "/wait-until-slow-interval-dom-mutation", get(wait_until_slow_interval_dom_mutation_page), ) + .route( + "/wait-until-shared-deadline", + get(wait_until_shared_deadline_page), + ) + .route( + "/wait-until-shared-deadline/activity", + get(wait_until_shared_deadline_activity), + ) .route( "/wait-until-redirect-status-navigation", get(wait_until_redirect_status_navigation_page), @@ -784,6 +799,16 @@ async fn wait_until_slow_interval_dom_mutation_page() -> Html<&'static str> { Html(WAIT_UNTIL_INTERVAL_DOM_MUTATION_HTML) } +async fn wait_until_shared_deadline_page() -> Html<&'static str> { + sleep(Duration::from_secs(4)).await; + Html(WAIT_UNTIL_SHARED_DEADLINE_HTML) +} + +async fn wait_until_shared_deadline_activity() -> &'static str { + sleep(Duration::from_secs(8)).await; + "complete" +} + async fn wait_until_data_page() -> Response { ( [(