diff --git a/moli-core/tests/scripts.rs b/moli-core/tests/scripts.rs index a6a02404ac..015016b317 100644 --- a/moli-core/tests/scripts.rs +++ b/moli-core/tests/scripts.rs @@ -13,6 +13,9 @@ use moli_core::{ use support::FixtureServer; use tokio::time::Duration; +#[path = "scripts/child_error_insertion.rs"] +mod child_error_insertion; + fn diagnostic_global<'a>( page: &'a moli_core::page::Page, name: &str, diff --git a/moli-core/tests/scripts/child_error_insertion.rs b/moli-core/tests/scripts/child_error_insertion.rs new file mode 100644 index 0000000000..a089a056a3 --- /dev/null +++ b/moli-core/tests/scripts/child_error_insertion.rs @@ -0,0 +1,75 @@ +use super::*; + +async fn child_script_error_write_probe( + nested: bool, + unknown_scheme: bool, +) -> Result { + let server = FixtureServer::spawn().await?; + let browser = Browser::new(AppConfig::default())?; + let mut page = browser.fetch(&server.url("/static")).await?; + let source = if unknown_scheme { + "no-such-script-scheme:missing".to_owned() + } else { + server.url("/missing-child-parser-script.js") + }; + let expression = r#"new Promise(resolve => { + let during = null; + globalThis.childErrorObserved = value => { during = value; }; + const frame = document.createElement('iframe'); + frame.onload = () => resolve(JSON.stringify({ + during, after: frame.contentDocument.body.textContent, + nestedRan: frame.contentWindow.nestedRan === true + })); + const written = NESTED + ? '