test(js): lock script-error isolation for the babel-polyfill case (#358)

Regression test for #355: an uncaught `throw` in one inline <script> must
not prevent later independent <script>s from running. This was fixed by
the #147 poison-guard (present on main) but reported again against 0.1.9
with an explicit throw; this pins the exact scenario so it cannot regress.

Closes #355.
This commit is contained in:
SGavrl authored and GitHub committed 2026-07-07 09:35:49 +02:00
1 parent ad7a7a93d1
commit 5c3d560d8e
1 file changed
+19
+19
View File
@@ -1392,6 +1392,25 @@ mod tests {
assert_eq!(text, serde_json::json!("BODY_TEXT"));
}
/// Regression test for #355: an explicit `throw` in one inline <script> must
/// not stop later independent <script>s from running. Each <script> executes
/// as its own `execute_script` call, mirroring how page.rs runs them, so a
/// thrown error is reported but the next script still runs.
#[test]
fn thrown_error_in_one_script_does_not_stop_later_scripts() {
let mut rt = setup_runtime("<html><body></body></html>");
rt.execute_script("s1", "globalThis.__ran1 = true;").unwrap();
let err = rt
.execute_script("s2", "throw new Error('only one instance of babel-polyfill is allowed');")
.unwrap_err();
assert!(err.contains("babel-polyfill"), "expected the thrown message, got: {}", err);
rt.execute_script("s3", "globalThis.__ran3 = true;").unwrap();
let ran = rt
.evaluate("JSON.stringify([globalThis.__ran1 === true, globalThis.__ran3 === true])")
.unwrap();
assert_eq!(ran, serde_json::json!("[true,true]"));
}
/// Regression test for #356: the `in` operator and `Object.keys` must work on
/// `el.style` (CSSStyleDeclaration) and `el.dataset` (DOMStringMap), `_props`
/// must not leak, and cssText must serialize dashed names with a trailing