diff --git a/moli-core/tests/web_apis.rs b/moli-core/tests/web_apis.rs index 2e38543cf91..1e42f751653 100644 --- a/moli-core/tests/web_apis.rs +++ b/moli-core/tests/web_apis.rs @@ -13,9 +13,6 @@ mod font_queries; #[path = "web_apis/indexed_db_transaction.rs"] mod indexed_db_transaction; -#[path = "web_apis/pipe_disturbed.rs"] -mod pipe_disturbed; - use moli_test_support as support; use anyhow::Result; @@ -40,6 +37,8 @@ mod event_dispatch; mod fetch_body_native; #[path = "web_apis/fetch_body_realm.rs"] mod fetch_body_realm; +#[path = "web_apis/pipe_disturbed.rs"] +mod pipe_disturbed; #[path = "web_apis/request_init.rs"] mod request_init; #[path = "web_apis/request_stream.rs"] diff --git a/moli-core/tests/web_apis/indexed_db_transaction.rs b/moli-core/tests/web_apis/indexed_db_transaction.rs index 037edbbd4e0..1baf4656620 100644 --- a/moli-core/tests/web_apis/indexed_db_transaction.rs +++ b/moli-core/tests/web_apis/indexed_db_transaction.rs @@ -1,4 +1,4 @@ -use super::pipe_disturbed::run_probe; +use super::event_dispatch::run_probe; use super::*; async fn assert_multi_entry_keys(scenario: &str) -> Result<()> { diff --git a/moli-core/tests/web_apis/pipe_disturbed.rs b/moli-core/tests/web_apis/pipe_disturbed.rs index 4f08b9779a1..e3996e56be2 100644 --- a/moli-core/tests/web_apis/pipe_disturbed.rs +++ b/moli-core/tests/web_apis/pipe_disturbed.rs @@ -11,7 +11,7 @@ async fn assert_pipe_disturbed(scenario: &str) -> Result<()> { for target in ["window", "child", "worker"] { let observed = tokio::time::timeout( Duration::from_secs(20), - run_probe(&browser, &server, target, &source), + super::event_dispatch::run_probe(&browser, &server, target, &source), ) .await??; assert_eq!( @@ -33,59 +33,3 @@ async fn piping_disturbs_fetch_bodies_before_reads_and_abort_handling() -> Resul async fn rejected_piping_preserves_undisturbed_fetch_bodies() -> Result<()> { assert_pipe_disturbed("reject").await } - -fn markup_url(server: &FixtureServer, markup: &str) -> String { - let mut url = url::Url::parse(&server.url("/compat/child-dynamic-markup-document")).unwrap(); - url.query_pairs_mut().append_pair("markup", markup); - url.into() -} - -pub(super) async fn run_probe( - browser: &Browser, - server: &FixtureServer, - target: &str, - source: &str, -) -> Result { - let markup = if target == "worker" { - let source = serde_json::to_string(&format!( - "self.finish = value => postMessage(value);\n{source}" - ))?; - format!( - r#""# - ) - } else { - format!( - "" - ) - }; - let url = markup_url(server, &markup); - let url = if target == "child" { - markup_url( - server, - &format!( - "", - url.replace('&', "&") - ), - ) - } else { - url - }; - let mut page = browser.fetch(&url).await?; - let expression = if target == "child" { - "document.getElementById('target').contentWindow.done.then(JSON.stringify)" - } else { - "done.then(JSON.stringify)" - }; - let value = page - .evaluate_runtime_expression_with_await_async(expression, true) - .await?; - Ok(serde_json::from_str( - value["value"].as_str().expect("callback probe result"), - )?) -}