Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(history): preserve traversal state identity in the owning realm
ldm0203b088184b6
diff --git a/moli-renderer-v8/src/context_bootstrap/history_runtime/apply.rs b/moli-renderer-v8/src/context_bootstrap/history_runtime/apply.rsindex d15c1f374..a379277ae 100644--- a/moli-renderer-v8/src/context_bootstrap/history_runtime/apply.rs+++ b/moli-renderer-v8/src/context_bootstrap/history_runtime/apply.rs@@ -55,10 +55,14 @@ pub(in crate::context_bootstrap) fn prepare_local_history_entry_commit<'s>(let record = record.borrow();(record.url.clone(), record.history_state.clone())};- let state = snapshot- .as_ref()- .and_then(|state| crate::structured_clone::deserialize_history_state(scope, state))- .unwrap_or_else(|| v8::null(scope).into());+ let context = history.get_creation_context(scope)?;+ let state = {+ let scope = &mut v8::ContextScope::new(scope, context);+ snapshot+ .as_ref()+ .and_then(|state| crate::structured_clone::deserialize_history_state(scope, state))+ .unwrap_or_else(|| v8::null(scope).into())+ };let entry = super::native::entry_wrapper(scope, owner, record.clone());let location = window_location_for_holder(scope, owner)?;let parsed_url = url::Url::parse(&url).ok()?;diff --git a/moli-renderer-v8/src/context_bootstrap/history_runtime/state.rs b/moli-renderer-v8/src/context_bootstrap/history_runtime/state.rsindex 99267e95e..1269a3196 100644--- a/moli-renderer-v8/src/context_bootstrap/history_runtime/state.rs+++ b/moli-renderer-v8/src/context_bootstrap/history_runtime/state.rs@@ -197,7 +197,11 @@ pub(in crate::context_bootstrap) fn cache_current_history_state<'s>(return;};let revision = record.borrow().revision();- if history.get_creation_context(scope) == Some(scope.get_current_context()) {+ let history_context = history.get_creation_context(scope);+ let state_context = v8::Local::<v8::Object>::try_from(state)+ .ok()+ .map_or(history_context, |state| state.get_creation_context(scope));+ if state_context == history_context {cache_history_state(scope, history, revision, state);}}