The headless browser for AI agents and web scraping
Dismiss noninteractive confirmation dialogs by default
SGavrl33aeb3f1b771
diff --git a/crates/obscura-js/js/bootstrap.js b/crates/obscura-js/js/bootstrap.jsindex 43c314c4..77f28615 100644--- a/crates/obscura-js/js/bootstrap.js+++ b/crates/obscura-js/js/bootstrap.js@@ -17111,7 +17111,7 @@ globalThis.focus = function() {}; _markNative(globalThis.focus);globalThis.blur = function() {}; _markNative(globalThis.blur);globalThis.print = function() {}; _markNative(globalThis.print);globalThis.alert = function() {}; _markNative(globalThis.alert);-globalThis.confirm = function() { return true; }; _markNative(globalThis.confirm);+globalThis.confirm = function() { return false; }; _markNative(globalThis.confirm);globalThis.prompt = function() { return null; }; _markNative(globalThis.prompt);globalThis.open = function() { return null; }; _markNative(globalThis.open);globalThis.close = function() {}; _markNative(globalThis.close);diff --git a/crates/obscura-js/src/runtime.rs b/crates/obscura-js/src/runtime.rsindex a47571e3..e9876971 100644--- a/crates/obscura-js/src/runtime.rs+++ b/crates/obscura-js/src/runtime.rs@@ -4606,6 +4606,30 @@ impl Default for ObscuraJsRuntime {#[cfg(test)]mod tests {+ #[test]+ fn noninteractive_dialogs_do_not_accept_destructive_confirmation() {+ let mut rt = setup_runtime("<html><body></body></html>");+ assert_eq!(rt.evaluate(r#"(() => {+ const records = ["keep"];+ const accepted = confirm("Delete this record?");+ if (accepted) records.pop();+ return {accepted, records, prompt: prompt("Edit", "draft"),+ alertResult: typeof alert("Notice")};+ })()"#).unwrap(), serde_json::json!({+ "accepted": false, "records": ["keep"], "prompt": null,+ "alertResult": "undefined",+ }));+ }++ #[test]+ fn noninteractive_dialog_defaults_apply_to_child_realms() {+ let mut rt = setup_runtime("<html><body></body></html>");+ let frame = crate::frame::FrameRealm::new(&mut rt, 1, 0,+ "http://example.com/child", "<html><body></body></html>").unwrap();+ assert_eq!(frame.evaluate(&mut rt, "confirm('Delete?')").unwrap(),+ serde_json::json!(false));+ }+#[cfg(obscura_external_bootstrap)]#[test]fn snapshot_core_methods_have_bytecode_before_first_use() {diff --git a/docs/Architecture-overview.md b/docs/Architecture-overview.mdindex 70b98f3b..9f863688 100644--- a/docs/Architecture-overview.md+++ b/docs/Architecture-overview.md@@ -132,6 +132,11 @@ for Playwright frame locators or iframe screenshot fidelity.`obscura-js/js/bootstrap.js` provides the browser globals: `document`, `window`, `navigator`, `location`, observers, fetch, indexedDB, etc.+The noninteractive dialog defaults dismiss `confirm()` (`false`), cancel+`prompt()` (`null`), and let `alert()` return without blocking. These functions+do not emit client-controlled CDP dialogs. `Page.handleJavaScriptDialog`+continues to resolve the separate beforeunload confirmation from `Page.close`.+`window.origin` (including the bare `origin` identifier) reports the owningdocument's origin, including inherited blank-frame origins. Page assignmentreplaces this property without changing the document's actual origin.