Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
refactor(navigation): centralize history entry wrappers
ldm00810c974ef9d
diff --git a/moli-renderer-v8/src/context_bootstrap/events/wrappers.rs b/moli-renderer-v8/src/context_bootstrap/events/wrappers.rsindex 2bd1bac19..8f6acba35 100644--- a/moli-renderer-v8/src/context_bootstrap/events/wrappers.rs+++ b/moli-renderer-v8/src/context_bootstrap/events/wrappers.rs@@ -6,6 +6,7 @@//! The world cache contains weak wrappers, not persistent roots for that graph.use super::*;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::context_bootstrap::{exposed_interfaces, world_wrappers};const EVENT_ATTRIBUTE_GETTERS_SLOT: &str = "__moliEventAttributeGetters";@@ -58,11 +59,7 @@ impl AttributeProjection {Self::PlatformObject => {crate::context_bootstrap::platform_object_worlds::in_realm(scope, value, context)}- Self::NavigationEntry => Some(- crate::context_bootstrap::history_runtime::native::entry_value_in_realm(- scope, value, context,- ),- ),+ Self::NavigationEntry => Some(entry_wrappers::value_in_realm(scope, value, context)),Self::NavigationDestination => {let destination = v8::Local::<v8::Object>::try_from(value).ok()?;let scope = &mut v8::ContextScope::new(scope, context);diff --git a/moli-renderer-v8/src/context_bootstrap/history_mutation.rs b/moli-renderer-v8/src/context_bootstrap/history_mutation.rsindex c1c18424e..13649d302 100644--- a/moli-renderer-v8/src/context_bootstrap/history_mutation.rs+++ b/moli-renderer-v8/src/context_bootstrap/history_mutation.rs@@ -1,7 +1,6 @@use super::history_runtime::require_fully_active_history_owner;use super::history_runtime::state::{push_history_entry, replace_history_entry};use super::location_runtime::{location_href_slot, sync_location_object};-use super::navigation_activation::bind_navigation_entry_runtime_owner;use super::navigation_callbacks::cancel_active_intercepted_same_document_navigation;use super::navigation_entry::{cache_current_history_state, copy_navigation_entry_document_id, create_navigation_entry,@@ -207,7 +206,6 @@ fn mutate_history_object<'s>(if let Some(previous_entry) = previous_entry {copy_navigation_entry_document_id(scope, previous_entry, entry);}- bind_navigation_entry_runtime_owner(scope, entry, owner);pruned = push_history_entry(scope, history, entry);entry}@@ -227,7 +225,6 @@ fn mutate_history_object<'s>(if let Some(previous_entry) = previous_entry {copy_navigation_entry_document_id(scope, previous_entry, entry);}- bind_navigation_entry_runtime_owner(scope, entry, owner);replace_history_entry(scope, history, entry);entry}diff --git a/moli-renderer-v8/src/context_bootstrap/history_runtime/apply.rs b/moli-renderer-v8/src/context_bootstrap/history_runtime/apply.rsindex a379277ae..210198104 100644--- a/moli-renderer-v8/src/context_bootstrap/history_runtime/apply.rs+++ b/moli-renderer-v8/src/context_bootstrap/history_runtime/apply.rs@@ -17,6 +17,7 @@ use super::super::navigation_window::{window_location_for_holder, window_navigation_for_holder,};use super::super::*;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::script_vm::perform_microtask_checkpoint_and_report_pending_promise_rejections;pub(in crate::context_bootstrap) struct AppliedHistoryEntry<'s> {@@ -63,7 +64,7 @@ pub(in crate::context_bootstrap) fn prepare_local_history_entry_commit<'s>(.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 entry = entry_wrappers::for_window(scope, owner, record.clone());let location = window_location_for_holder(scope, owner)?;let parsed_url = url::Url::parse(&url).ok()?;Some(PreparedHistoryEntry {diff --git a/moli-renderer-v8/src/context_bootstrap/history_runtime/native.rs b/moli-renderer-v8/src/context_bootstrap/history_runtime/native.rsindex d5a8a1ddc..942ac8007 100644--- a/moli-renderer-v8/src/context_bootstrap/history_runtime/native.rs+++ b/moli-renderer-v8/src/context_bootstrap/history_runtime/native.rs@@ -5,13 +5,12 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc};use moli_history::{HistoryEntryRef, WindowHistory};-use crate::util::{get_private_value, set_private_value, v8_string};+use crate::util::{get_private_value, set_private_value};pub(in crate::context_bootstrap) type HistoryRef = Rc<RefCell<WindowHistory>>;type Store = Rc<RefCell<NativeRecords>>;const HISTORY_ID: &str = "__moliNativeHistory";const ENTRY_ID: &str = "__moliNativeHistoryEntry";-const ENTRY_WRAPPERS: &str = "__moliNavigationEntryWrappers";#[derive(Default)]struct NativeRecords {@@ -145,26 +144,19 @@ pub(in crate::context_bootstrap) fn entry<'s>(.map(|(_, record)| record.clone())}-/// V8 wrappers are world-local, while their record and event target are shared.-/// Weak handles preserve identity for observable wrappers without retaining a-/// destroyed isolated realm from the Window's canonical wrapper cache.-pub(in crate::context_bootstrap) fn entry_in_realm<'s>(+/// Find an observable wrapper for this native record in the requested realm.+/// Clone the weak handles before touching V8 so finalizers can borrow the store.+pub(in crate::context_bootstrap) fn find_entry_wrapper<'s>(scope: &mut v8::PinScope<'s, '_>,- source: v8::Local<'s, v8::Object>,+ record: &HistoryEntryRef,context: v8::Local<'s, v8::Context>,-) -> v8::Local<'s, v8::Object> {- if source.get_creation_context(scope) == Some(context) {- return source;- }- let Some(record) = entry(scope, source) else {- return source;- };- let registry = store(scope);+) -> Option<v8::Local<'s, v8::Object>> {+ let registry = scope.get_slot::<Store>()?;let candidates: Vec<_> = {let records = registry.borrow();records.entry_ids- .get(&(Rc::as_ptr(&record) as usize))+ .get(&(Rc::as_ptr(record) as usize)).into_iter().flatten().filter_map(|id| records.entries.get(id))@@ -175,114 +167,10 @@ pub(in crate::context_bootstrap) fn entry_in_realm<'s>(if let Some(wrapper) = candidate.to_local(scope)&& wrapper.get_creation_context(scope) == Some(context){- return wrapper;- }- }- let owner = super::super::navigation_window::runtime_window_owner(scope, source);- let target = super::super::shared_event_targets::shared_target_owner(scope, source);- let scope = &mut v8::ContextScope::new(scope, context);- let wrapper = super::super::navigation_entry::wrap_native_navigation_entry(scope, record);- super::super::navigation_window::set_runtime_window_owner(scope, wrapper, owner);- super::super::shared_event_targets::bind_shared_target(scope, wrapper, target);- wrapper-}--pub(in crate::context_bootstrap) fn entry_value_in_realm<'s>(- scope: &mut v8::PinScope<'s, '_>,- value: v8::Local<'s, v8::Value>,- context: v8::Local<'s, v8::Context>,-) -> v8::Local<'s, v8::Value> {- let Ok(object) = v8::Local::<v8::Object>::try_from(value) else {- return value;- };- if entry(scope, object).is_none() {- return value;- }- entry_in_realm(scope, object, context).into()-}--fn wrappers<'s>(- scope: &mut v8::PinScope<'s, '_>,- owner: v8::Local<'s, v8::Object>,-) -> v8::Local<'s, v8::Map> {- if let Some(map) = get_private_value(scope, owner, ENTRY_WRAPPERS)- .and_then(|value| v8::Local::<v8::Map>::try_from(value).ok())- {- return map;- }- let map = v8::Map::new(scope);- set_private_value(scope, owner, ENTRY_WRAPPERS, map.into());- map-}--pub(in crate::context_bootstrap) fn cache_entry<'s>(- scope: &mut v8::PinScope<'s, '_>,- owner: v8::Local<'s, v8::Object>,- wrapper: v8::Local<'s, v8::Object>,-) {- let Some(entry) = entry(scope, wrapper) else {- return;- };- let id = entry.borrow().id.clone();- let Some(key) = v8_string(scope, &id) else {- return;- };- let _ = wrappers(scope, owner).set(scope, key.into(), wrapper.into());-}--pub(in crate::context_bootstrap) fn entry_wrapper<'s>(- scope: &mut v8::PinScope<'s, '_>,- owner: v8::Local<'s, v8::Object>,- entry: HistoryEntryRef,-) -> v8::Local<'s, v8::Object> {- let context = owner- .get_creation_context(scope)- .expect("History Window realm");- let scope = &mut v8::ContextScope::new(scope, context);- let id = entry.borrow().id.clone();- let map = wrappers(scope, owner);- if let Some(key) = v8_string(scope, &id)- && let Some(wrapper) = map- .get(scope, key.into())- .and_then(|value| v8::Local::<v8::Object>::try_from(value).ok())- && self::entry(scope, wrapper).is_some_and(|record| Rc::ptr_eq(&record, &entry))- {- return wrapper;- }- let wrapper = super::super::navigation_entry::wrap_native_navigation_entry(scope, entry);- super::super::navigation_activation::bind_navigation_entry_runtime_owner(scope, wrapper, owner);- wrapper-}--pub(in crate::context_bootstrap) fn prune_entry_wrappers<'s>(- scope: &mut v8::PinScope<'s, '_>,- owner: v8::Local<'s, v8::Object>,- entries: &[HistoryEntryRef],-) {- let live: std::collections::HashMap<_, _> = entries- .iter()- .map(|entry| (entry.borrow().id.clone(), Rc::as_ptr(entry)))- .collect();- let Some(map) = get_private_value(scope, owner, ENTRY_WRAPPERS)- .and_then(|value| v8::Local::<v8::Map>::try_from(value).ok())- else {- return;- };- let pairs = map.as_array(scope);- for index in (0..pairs.length()).step_by(2) {- let Some(key) = pairs.get_index(scope, index) else {- continue;- };- let record = pairs- .get_index(scope, index + 1)- .and_then(|value| v8::Local::<v8::Object>::try_from(value).ok())- .and_then(|wrapper| entry(scope, wrapper));- let retained = record- .is_some_and(|record| live.get(&record.borrow().id) == Some(&Rc::as_ptr(&record)));- if !retained {- let _ = map.delete(scope, key);+ return Some(wrapper);}}+ None}#[cfg(test)]diff --git a/moli-renderer-v8/src/context_bootstrap/history_runtime/state.rs b/moli-renderer-v8/src/context_bootstrap/history_runtime/state.rsindex 1269a3196..26345f215 100644--- a/moli-renderer-v8/src/context_bootstrap/history_runtime/state.rs+++ b/moli-renderer-v8/src/context_bootstrap/history_runtime/state.rs@@ -2,6 +2,7 @@use super::super::navigation_window::runtime_window_owner;use super::native;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::structured_clone::deserialize_history_state;use crate::util::{get_private_value, private_key, set_private_value, v8_string};use moli_history::{HistoryEntryRef, ScrollRestoration};@@ -54,10 +55,11 @@ pub(in crate::context_bootstrap) fn set_history_entries<'s>(return;};let owner = runtime_window_owner(scope, history);- native::prune_entry_wrappers(scope, owner, &entries);+ entry_wrappers::prune_for_window(scope, owner, &entries);record.borrow_mut().restore_entries(entries);}+/// Commit a complete wrapper created for this history's Window.pub(in crate::context_bootstrap) fn push_history_entry<'s>(scope: &mut v8::PinScope<'s, '_>,history: v8::Local<'s, v8::Object>,@@ -70,17 +72,17 @@ pub(in crate::context_bootstrap) fn push_history_entry<'s>(return Vec::new();};let owner = runtime_window_owner(scope, history);- super::super::navigation_activation::bind_navigation_entry_runtime_owner(scope, wrapper, owner);let removed = record.borrow_mut().push(entry);let removed = removed.into_iter()- .map(|entry| native::entry_wrapper(scope, owner, entry))+ .map(|entry| entry_wrappers::for_window(scope, owner, entry)).collect();let retained = record.borrow().entries().to_vec();- native::prune_entry_wrappers(scope, owner, &retained);+ entry_wrappers::prune_for_window(scope, owner, &retained);removed}+/// Commit a complete wrapper created for this history's Window.pub(in crate::context_bootstrap) fn replace_history_entry<'s>(scope: &mut v8::PinScope<'s, '_>,history: v8::Local<'s, v8::Object>,@@ -93,10 +95,9 @@ pub(in crate::context_bootstrap) fn replace_history_entry<'s>(return;};let owner = runtime_window_owner(scope, history);- super::super::navigation_activation::bind_navigation_entry_runtime_owner(scope, wrapper, owner);record.borrow_mut().replace(entry);let retained = record.borrow().entries().to_vec();- native::prune_entry_wrappers(scope, owner, &retained);+ entry_wrappers::prune_for_window(scope, owner, &retained);}pub(in crate::context_bootstrap) fn history_index<'s>(diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_activation.rs b/moli-renderer-v8/src/context_bootstrap/navigation_activation.rsindex 2a9f32407..cb41183fc 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_activation.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_activation.rs@@ -6,10 +6,9 @@ use super::navigation_entry::{history_entries, navigation_entry_public_token};use super::navigation_lifecycle::enqueue_navigation_lifecycle_microtask;use super::navigation_result::suppress_unhandled_rejection;use super::navigation_seed::history_entry_from_snapshot;-use super::navigation_window::{- runtime_window_owner, set_runtime_window_owner, window_history_for_holder,-};+use super::navigation_window::{runtime_window_owner, window_history_for_holder};use super::*;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::native_bridge::{NavigationActivationSeed, NavigationHistorySerializedEntry};use crate::util::{get_private_value, set_private_value};use crate::web_api_interfaces;@@ -125,11 +124,11 @@ pub(super) fn navigation_entry_object_from_snapshot<'s>({for entry in entries {if native_entry_matches_activation_snapshot(&entry.borrow(), snapshot) {- return native::entry_wrapper(scope, owner, entry);+ return entry_wrappers::for_window(scope, owner, entry);}}}- native::entry_wrapper(scope, owner, history_entry_from_snapshot(snapshot))+ entry_wrappers::for_window(scope, owner, history_entry_from_snapshot(snapshot))}fn navigation_activation_entry_object<'s>(@@ -143,15 +142,6 @@ fn navigation_activation_entry_object<'s>(navigation_entry_object_from_snapshot(scope, current_entry, &activation.entry)}-pub(super) fn bind_navigation_entry_runtime_owner<'s>(- scope: &mut v8::PinScope<'s, '_>,- entry: v8::Local<'s, v8::Object>,- owner: v8::Local<'s, v8::Object>,-) {- set_runtime_window_owner(scope, entry, owner);- super::history_runtime::native::cache_entry(scope, owner, entry);-}-pub(super) fn create_navigation_activation_object<'s>(scope: &mut v8::PinScope<'s, '_>,context: v8::Local<'s, v8::Context>,@@ -175,9 +165,9 @@ pub(super) fn create_navigation_activation_object<'s>(.and_then(|value| v8_string(scope, value)).map(v8::Local::<v8::Value>::from).unwrap_or_else(|| v8::null(scope).into());- let entry = super::history_runtime::native::entry_in_realm(scope, entry, context);+ let entry = entry_wrappers::in_realm(scope, entry, context);let from = if let Ok(from) = v8::Local::<v8::Object>::try_from(from) {- super::history_runtime::native::entry_in_realm(scope, from, context).into()+ entry_wrappers::in_realm(scope, from, context).into()} else {from};@@ -224,7 +214,7 @@ pub(super) fn install_navigation_transition<'s>(let committed = committed_resolver.get_promise(scope);suppress_unhandled_rejection(scope, committed);let context = scope.get_current_context();- let from = super::history_runtime::native::entry_in_realm(scope, from, context);+ let from = entry_wrappers::in_realm(scope, from, context);let to =to.and_then(|to| super::navigation_events::navigation_destination_for_realm(scope, to));let transition = NavigationTransitionObjectDeclaration {@@ -253,7 +243,7 @@ pub(super) fn resolve_navigation_transition_committed<'s>(.get_promise(scope).get_creation_context(scope).unwrap_or_else(|| scope.get_current_context());- let value = super::history_runtime::native::entry_value_in_realm(scope, value, context);+ let value = entry_wrappers::value_in_realm(scope, value, context);let _ = resolver.resolve(scope, value);}}@@ -376,7 +366,7 @@ pub(super) fn navigation_current_entry_value<'s>(let owner = runtime_window_owner(scope, navigation);let entry = super::navigation_entry::navigation_current_entry(scope, owner)?;let context = navigation.get_creation_context(scope)?;- Some(super::history_runtime::native::entry_in_realm(scope, entry, context).into())+ Some(entry_wrappers::in_realm(scope, entry, context).into())}pub(super) fn navigation_activation_value<'s>(diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_bootstrap.rs b/moli-renderer-v8/src/context_bootstrap/navigation_bootstrap.rsindex 86470b3db..456f5e77b 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_bootstrap.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_bootstrap.rs@@ -19,6 +19,7 @@ use super::navigation_surface::{};use super::navigation_window::set_runtime_window_owner;use super::*;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::util::{get_private_value, set_private_value};use crate::web_api_interfaces;use anyhow::Result;@@ -107,7 +108,7 @@ pub(crate) fn reset_window_location_history_navigation_runtime_state<'s>(let entries = build_history_entries_from_seed(&initial_seed);let current_entry = entries.get(initial_seed.current_index as usize)- .map(|entry| super::history_runtime::native::entry_wrapper(scope, window, entry.clone()))+ .map(|entry| entry_wrappers::for_window(scope, window, entry.clone())).unwrap_or_else(|| {build_current_navigation_entry_from_seed(scope,diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_entry.rs b/moli-renderer-v8/src/context_bootstrap/navigation_entry.rsindex 11602d0b5..f929c2dd9 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_entry.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_entry.rs@@ -3,9 +3,7 @@ pub(super) use super::history_runtime::state::{cache_current_history_state, history_entries, history_index, history_scroll_restoration_value,history_state_value, set_history_entries, set_history_index, set_history_scroll_restoration,};-use super::location_history_storage::{- NAVIGATION_CURRENT_ENTRY_SLOT, NAVIGATION_ENTRY_EVENT_LISTENERS_SLOT,-};+use super::location_history_storage::NAVIGATION_CURRENT_ENTRY_SLOT;use super::location_runtime::urls_refer_to_same_document;use super::navigation_activation::set_navigation_current_entry;use super::navigation_entry_state::navigation_entry_state_snapshot;@@ -17,12 +15,14 @@ use super::navigation_window::{use super::*;use crate::util::get_private_value;use crate::web_api_interfaces;-use moli_history::{HistoryEntry, HistoryEntryRef, ScrollRestoration};+use moli_history::{HistoryEntry, ScrollRestoration};use moli_page_types::NavigationHistoryEntryId;use moli_session_history::NavigationHistoryDocumentId;use moli_session_history::NavigationHistoryEntryKey;use moli_webapi_declare::WebApiObject;+pub(super) mod wrappers;+#[derive(Clone, Copy)]enum EntryStringField {Document,@@ -140,25 +140,7 @@ pub(super) fn create_navigation_entry<'s>(scroll_offset: None,}.into_ref();- native::entry_wrapper(scope, owner, entry)-}--pub(in crate::context_bootstrap) fn wrap_native_navigation_entry<'s>(- scope: &mut v8::PinScope<'s, '_>,- record: HistoryEntryRef,-) -> v8::Local<'s, v8::Object> {- let entry = NavigationHistoryEntryObjectDeclaration::new()- .bind(scope)- .expect("NavigationHistoryEntry declaration should bind");- native::bind_entry(scope, entry, record);- super::media_queries::install_simple_event_target_methods(- scope,- entry,- NAVIGATION_ENTRY_EVENT_LISTENERS_SLOT,- false,- );- super::shared_event_targets::install_handlers(scope, entry, true);- entry+ wrappers::for_window(scope, owner, entry)}pub(super) fn new_navigation_entry_id() -> NavigationHistoryEntryId {diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_entry/wrappers.rs b/moli-renderer-v8/src/context_bootstrap/navigation_entry/wrappers.rsnew file mode 100644index 000000000..c1937ce39--- /dev/null+++ b/moli-renderer-v8/src/context_bootstrap/navigation_entry/wrappers.rs@@ -0,0 +1,146 @@+//! Complete NavigationHistoryEntry wrappers. Runtime ownership and creation+//! realm are independent: Window wrappers use the owner's realm and strong+//! cache; other worlds share the native record and event target via weak views.++use std::{collections::HashMap, rc::Rc};++use moli_history::HistoryEntryRef;++use super::NavigationHistoryEntryObjectDeclaration;+use crate::context_bootstrap::history_runtime::native;+use crate::context_bootstrap::location_history_storage::NAVIGATION_ENTRY_EVENT_LISTENERS_SLOT;+use crate::context_bootstrap::navigation_window::{runtime_window_owner, set_runtime_window_owner};+use crate::context_bootstrap::{media_queries, shared_event_targets};+use crate::util::{get_private_value, set_private_value, v8_string};++const ENTRY_WRAPPERS: &str = "__moliNavigationEntryWrappers";++/// Get the canonical wrapper in the owning Window's realm. The entire cache+/// operation runs there, even when first called from another Window or world.+pub(in crate::context_bootstrap) fn for_window<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ owner: v8::Local<'s, v8::Object>,+ record: HistoryEntryRef,+) -> v8::Local<'s, v8::Object> {+ let context = owner+ .get_creation_context(scope)+ .expect("History Window realm");+ let scope = &mut v8::ContextScope::new(scope, context);+ let id = record.borrow().id.clone();+ let key = v8_string(scope, &id);+ let map = window_wrappers(scope, owner);+ if let Some(key) = key+ && let Some(wrapper) = map+ .get(scope, key.into())+ .and_then(|value| v8::Local::<v8::Object>::try_from(value).ok())+ && native::entry(scope, wrapper).is_some_and(|entry| Rc::ptr_eq(&entry, &record))+ {+ return wrapper;+ }+ let wrapper = allocate_in_current_realm(scope, owner, record);+ if let Some(key) = key {+ let _ = map.set(scope, key.into(), wrapper.into());+ }+ wrapper+}++/// Preserve the source's runtime owner and shared EventTarget, while using the+/// requested realm's interface. Weak reuse never roots that realm in Window.+pub(in crate::context_bootstrap) fn in_realm<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ source: v8::Local<'s, v8::Object>,+ context: v8::Local<'s, v8::Context>,+) -> v8::Local<'s, v8::Object> {+ if source.get_creation_context(scope) == Some(context) {+ return source;+ }+ let Some(record) = native::entry(scope, source) else {+ return source;+ };+ if let Some(wrapper) = native::find_entry_wrapper(scope, &record, context) {+ return wrapper;+ }+ let owner = runtime_window_owner(scope, source);+ let target = shared_event_targets::shared_target_owner(scope, source);+ let scope = &mut v8::ContextScope::new(scope, context);+ let wrapper = allocate_in_current_realm(scope, owner, record);+ shared_event_targets::bind_shared_target(scope, wrapper, target);+ wrapper+}++pub(in crate::context_bootstrap) fn value_in_realm<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ value: v8::Local<'s, v8::Value>,+ context: v8::Local<'s, v8::Context>,+) -> v8::Local<'s, v8::Value> {+ match v8::Local::<v8::Object>::try_from(value) {+ Ok(object) => in_realm(scope, object, context).into(),+ Err(_) => value,+ }+}++pub(in crate::context_bootstrap) fn prune_for_window<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ owner: v8::Local<'s, v8::Object>,+ entries: &[HistoryEntryRef],+) {+ let live: HashMap<_, _> = entries+ .iter()+ .map(|entry| (entry.borrow().id.clone(), Rc::as_ptr(entry)))+ .collect();+ let Some(map) = get_private_value(scope, owner, ENTRY_WRAPPERS)+ .and_then(|value| v8::Local::<v8::Map>::try_from(value).ok())+ else {+ return;+ };+ let pairs = map.as_array(scope);+ for index in (0..pairs.length()).step_by(2) {+ let Some(key) = pairs.get_index(scope, index) else {+ continue;+ };+ let record = pairs+ .get_index(scope, index + 1)+ .and_then(|value| v8::Local::<v8::Object>::try_from(value).ok())+ .and_then(|wrapper| native::entry(scope, wrapper));+ let retained = record+ .is_some_and(|record| live.get(&record.borrow().id) == Some(&Rc::as_ptr(&record)));+ if !retained {+ let _ = map.delete(scope, key);+ }+ }+}++// The caller selects the creation realm. Owner binding must never switch it.+fn allocate_in_current_realm<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ owner: v8::Local<'s, v8::Object>,+ record: HistoryEntryRef,+) -> v8::Local<'s, v8::Object> {+ let wrapper = NavigationHistoryEntryObjectDeclaration::new()+ .bind(scope)+ .expect("NavigationHistoryEntry declaration should bind");+ native::bind_entry(scope, wrapper, record);+ media_queries::install_simple_event_target_methods(+ scope,+ wrapper,+ NAVIGATION_ENTRY_EVENT_LISTENERS_SLOT,+ false,+ );+ shared_event_targets::install_handlers(scope, wrapper, true);+ set_runtime_window_owner(scope, wrapper, owner);+ wrapper+}++fn window_wrappers<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ owner: v8::Local<'s, v8::Object>,+) -> v8::Local<'s, v8::Map> {+ if let Some(map) = get_private_value(scope, owner, ENTRY_WRAPPERS)+ .and_then(|value| v8::Local::<v8::Map>::try_from(value).ok())+ {+ return map;+ }+ let map = v8::Map::new(scope);+ set_private_value(scope, owner, ENTRY_WRAPPERS, map.into());+ map+}diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_events.rs b/moli-renderer-v8/src/context_bootstrap/navigation_events.rsindex 15857a9a0..6f9f05c2a 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_events.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_events.rs@@ -24,6 +24,7 @@ use super::navigation_window::{window_task_target_for_runtime_owner,};use super::*;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::document_runtime::EventTargetHandle;use crate::page_task_queue::RendererPageHashChangeData;use crate::util::{get_private_value, set_private_value};@@ -1242,7 +1243,7 @@ pub(super) fn dispatch_navigation_traverse_event_with_outcome<'s>(return NavigationDispatchOutcome::proceed();};let owner = runtime_window_owner(scope, navigation);- let entry = super::history_runtime::native::entry_wrapper(scope, owner, entry.clone());+ let entry = entry_wrappers::for_window(scope, owner, entry.clone());let destination = create_navigation_destination_for_entry(scope, navigation, entry);let target_href = destination.get(scope, v8str(scope, "url").into())diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_history_pruning.rs b/moli-renderer-v8/src/context_bootstrap/navigation_history_pruning.rsindex dd57fc50c..e9d08b729 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_history_pruning.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_history_pruning.rs@@ -1,10 +1,10 @@-use super::history_runtime::native;use super::navigation_entry::{history_entries, history_index, navigation_current_entry, navigation_entry_key_value,set_history_entries, set_history_index,};use super::navigation_events::dispatch_navigation_entry_dispose;use super::navigation_window::window_history_for_holder;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use moli_history::HistoryEntryRef;#[derive(Debug)]@@ -53,7 +53,7 @@ pub(crate) fn apply_navigation_history_prune_plan(for entry in entries {let key = entry.borrow().key.as_str().to_owned();if plan.removed_entry_keys.contains(&key) {- removed_entries.push((key, native::entry_wrapper(scope, owner, entry)));+ removed_entries.push((key, entry_wrappers::for_window(scope, owner, entry)));} else {retained_entries.push((key, entry));}diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_lifecycle.rs b/moli-renderer-v8/src/context_bootstrap/navigation_lifecycle.rsindex 1056180c2..1854edeff 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_lifecycle.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_lifecycle.rs@@ -9,6 +9,7 @@ use super::navigation_events::{navigation_scroll_target_href,};use super::*;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::native_bridge::element::{process_post_parse_autofocus, scroll_to_url_fragment_or_top, update_focus,};@@ -131,7 +132,7 @@ pub(super) fn settle_navigation_finished_resolved_immediately<'s>(let context = resolve.get_creation_context(scope).unwrap_or_else(|| scope.get_current_context());- let value = super::history_runtime::native::entry_value_in_realm(scope, value, context);+ let value = entry_wrappers::value_in_realm(scope, value, context);let receiver = v8::undefined(scope).into();let _ = resolve.call(scope, receiver, &[value]);}diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_mutation.rs b/moli-renderer-v8/src/context_bootstrap/navigation_mutation.rsindex 01102941a..1f9f86a1e 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_mutation.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_mutation.rs@@ -1,8 +1,7 @@use super::location_navigation::LocationNavigationKind;use super::location_runtime::sync_location_object;use super::navigation_activation::{- bind_navigation_entry_runtime_owner, install_navigation_activation_runtime_state,- set_navigation_current_entry,+ install_navigation_activation_runtime_state, set_navigation_current_entry,};use super::navigation_entry::{cache_current_history_state, copy_navigation_entry_document_id, create_navigation_entry,diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_mutation/local.rs b/moli-renderer-v8/src/context_bootstrap/navigation_mutation/local.rsindex 8d07f4ea2..1937d0fb5 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_mutation/local.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_mutation/local.rs@@ -1,5 +1,6 @@use super::super::history_runtime::state::{push_history_entry, replace_history_entry};use super::*;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;pub(crate) fn apply_local_window_location_navigation<'s>(scope: &mut v8::PinScope<'s, '_>,@@ -33,7 +34,6 @@ pub(crate) fn apply_local_window_location_navigation<'s>();let document_id = moli_session_history::NavigationHistoryDocumentId::allocate();set_navigation_entry_document_id(scope, next_entry, document_id.as_str());- bind_navigation_entry_runtime_owner(scope, next_entry, owner);let _ = push_history_entry(scope, history, next_entry);if super::super::navigation_window::child_browsing_context_handle_for_runtime_owner(scope, owner,@@ -68,7 +68,6 @@ pub(crate) fn apply_local_window_location_navigation<'s>();let document_id = moli_session_history::NavigationHistoryDocumentId::allocate();set_navigation_entry_document_id(scope, entry, document_id.as_str());- bind_navigation_entry_runtime_owner(scope, entry, owner);replace_history_entry(scope, history, entry);cache_current_history_state(scope, history, state);set_navigation_current_entry(scope, navigation, entry);@@ -93,11 +92,7 @@ pub(crate) fn apply_local_window_location_navigation<'s>(}LocationNavigationKind::Reload => {if let Some(record) = entries.get(current_index as usize) {- let entry = super::super::history_runtime::native::entry_wrapper(- scope,- owner,- record.clone(),- );+ let entry = entry_wrappers::for_window(scope, owner, record.clone());let current_entry = previous_entry.unwrap_or(entry);if previous_entry.is_none() {sync_navigation_current_entry_from_history_entry(scope, owner, entry);diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_mutation/same_document.rs b/moli-renderer-v8/src/context_bootstrap/navigation_mutation/same_document.rsindex 4e084fea3..f9333f819 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_mutation/same_document.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_mutation/same_document.rs@@ -119,7 +119,6 @@ pub(in crate::context_bootstrap) fn apply_navigation_navigate_same_document<'s>(if let Some(previous_entry) = previous_entry {copy_navigation_entry_document_id(scope, previous_entry, next_entry);}- bind_navigation_entry_runtime_owner(scope, next_entry, owner);if let Some(state) = navigation_state {set_navigation_entry_state(scope, next_entry, state);}@@ -156,7 +155,6 @@ pub(in crate::context_bootstrap) fn apply_navigation_navigate_same_document<'s>(if let Some(previous_entry) = previous_entry {copy_navigation_entry_document_id(scope, previous_entry, entry);}- bind_navigation_entry_runtime_owner(scope, entry, owner);if let Some(state) = navigation_state {set_navigation_entry_state(scope, entry, state);}diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_projection.rs b/moli-renderer-v8/src/context_bootstrap/navigation_projection.rsindex 8ad181a81..f1741e2f6 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_projection.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_projection.rs@@ -3,6 +3,7 @@ use super::navigation_window::{child_browsing_context_handle_for_runtime_owner, runtime_window_is_global,runtime_window_owner, runtime_window_uses_top_level_history_model,};+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::util::{context_host_ptr_from_global_bridge, serialize_v8_iter_array};use moli_history::HistoryEntryRef;use std::rc::Rc;@@ -18,8 +19,8 @@ pub(super) fn build_visible_navigation_entries_array<'s>(let wrappers: Vec<_> = visible_entries.into_iter().map(|entry| {- let wrapper = native::entry_wrapper(scope, owner, entry);- native::entry_in_realm(scope, wrapper, context)+ let wrapper = entry_wrappers::for_window(scope, owner, entry);+ entry_wrappers::in_realm(scope, wrapper, context)}).collect();let scope = &mut v8::ContextScope::new(scope, context);diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_restore.rs b/moli-renderer-v8/src/context_bootstrap/navigation_restore.rsindex 9a10795a5..7c6e262ba 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_restore.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_restore.rs@@ -1,4 +1,3 @@-use super::history_runtime::native;use super::navigation_activation::{install_navigation_activation_runtime_state, set_navigation_current_entry,};@@ -11,6 +10,7 @@ use super::navigation_seed::{build_current_navigation_entry_from_seed, build_history_entries_from_seed,};use super::navigation_window::{window_history_for_holder, window_navigation_for_holder};+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::native_bridge::NavigationHistoryEntrySeed;pub(crate) fn install_navigation_bootstrap_entry(@@ -65,7 +65,7 @@ pub(crate) fn install_navigation_entry_view_for_holder<'s>(let entries = build_history_entries_from_seed(entry_seed);let current_entry = entries.get(entry_seed.current_index as usize)- .map(|entry| native::entry_wrapper(scope, owner, entry.clone()))+ .map(|entry| entry_wrappers::for_window(scope, owner, entry.clone())).unwrap_or_else(|| {build_current_navigation_entry_from_seed(scope,diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_result.rs b/moli-renderer-v8/src/context_bootstrap/navigation_result.rsindex cb863830e..743a25cd0 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_result.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_result.rs@@ -11,6 +11,7 @@ pub(super) use super::navigation_lifecycle::{perform_navigation_scroll_if_needed, reset_navigation_focus_if_unchanged,};use super::*;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::util::{get_private_value, set_private_value};use moli_webapi_declare::WebApiObject;@@ -480,8 +481,7 @@ pub(super) fn navigation_immediate_result_with_value<'s>(resolved_value: v8::Local<'s, v8::Value>,) -> v8::Local<'s, v8::Object> {let context = scope.get_current_context();- let resolved_value =- super::history_runtime::native::entry_value_in_realm(scope, resolved_value, context);+ let resolved_value = entry_wrappers::value_in_realm(scope, resolved_value, context);let Some(committed_resolver) = v8::PromiseResolver::new(scope) else {return navigation_result_fallback_object(scope);};diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_seed.rs b/moli-renderer-v8/src/context_bootstrap/navigation_seed.rsindex bdc84fc05..310744b63 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_seed.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_seed.rs@@ -1,4 +1,3 @@-use super::history_runtime::native;use super::location_runtime::is_same_document_fragment_navigation;use super::navigation_entry::{history_index, navigation_entry_public_token};use super::navigation_serialize::{@@ -7,6 +6,7 @@ use super::navigation_serialize::{use super::navigation_window::{runtime_window_uses_top_level_history_model, window_history_for_holder,};+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::native_bridge::{NavigationHistoryEntrySeed, NavigationHistorySerializedEntry};use crate::structured_clone::serialize_history_state;use moli_history::{HistoryEntry, HistoryEntryRef, ScrollRestoration};@@ -89,7 +89,7 @@ pub(super) fn build_current_navigation_entry_from_seed<'s>(}.into_ref()});- native::entry_wrapper(scope, owner, entry)+ entry_wrappers::for_window(scope, owner, entry)}pub(super) fn history_entry_seed_for_reload<'s>(diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_surface/runtime.rs b/moli-renderer-v8/src/context_bootstrap/navigation_surface/runtime.rsindex 7c7df668c..54d6257a9 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_surface/runtime.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_surface/runtime.rs@@ -9,6 +9,7 @@ use super::accessors::{install_history_prototype_accessors, install_navigation_prototype_accessors,};use super::*;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::native_bridge::NavigationHistoryEntrySeed;use crate::util::get_private_value;use crate::web_api_interfaces;@@ -82,7 +83,7 @@ pub(in crate::context_bootstrap) fn build_navigation_runtime_state<'s>(let owner = history_window_owner(scope, window);entries.get(index as usize)- .map(|entry| native::entry_wrapper(scope, owner, entry.clone()))+ .map(|entry| entry_wrappers::for_window(scope, owner, entry.clone()))}).unwrap_or_else(|| {build_current_navigation_entry_from_seed(diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_transition_worlds.rs b/moli-renderer-v8/src/context_bootstrap/navigation_transition_worlds.rsindex 7f805ae17..438758ad3 100644--- a/moli-renderer-v8/src/context_bootstrap/navigation_transition_worlds.rs+++ b/moli-renderer-v8/src/context_bootstrap/navigation_transition_worlds.rs@@ -1,4 +1,5 @@-use super::{history_runtime::native, world_wrappers};+use super::world_wrappers;+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::util::v8str;use crate::web_api_interfaces;use moli_webapi_declare::WebApiObject;@@ -29,7 +30,7 @@ pub(super) fn transition_in_realm<'s>(}let scope = &mut v8::ContextScope::new(scope, context);let from = transition.get(scope, v8str(scope, "from").into())?;- let from = native::entry_value_in_realm(scope, from, context);+ let from = entry_wrappers::value_in_realm(scope, from, context);let to = transition.get(scope, v8str(scope, "to").into())?;let to = if let Ok(to) = v8::Local::<v8::Object>::try_from(to) {super::navigation_events::navigation_destination_for_realm(scope, to)?.into()@@ -88,7 +89,7 @@ fn resolve_promise<'s>(};let resolver = unsafe { v8::Local::<v8::PromiseResolver>::cast_unchecked(object) };let context = scope.get_current_context();- let value = native::entry_value_in_realm(scope, args.get(0), context);+ let value = entry_wrappers::value_in_realm(scope, args.get(0), context);let _ = resolver.resolve(scope, value);}diff --git a/moli-renderer-v8/src/context_bootstrap/session_history.rs b/moli-renderer-v8/src/context_bootstrap/session_history.rsindex 6cc8ac01a..c924c0dfd 100644--- a/moli-renderer-v8/src/context_bootstrap/session_history.rs+++ b/moli-renderer-v8/src/context_bootstrap/session_history.rs@@ -4,6 +4,7 @@ use super::navigation_entry::{use super::navigation_window::{runtime_top_window_owner, runtime_window_dispatch_scope, window_history_for_holder,};+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::native_bridge::{JsContextHost, NavigationHistoryEntrySeed, OwnerDispatchScope};use crate::util::context_host_ptr_from_global_bridge;use moli_history::{HistoryEntry, HistoryEntryRef};@@ -370,9 +371,7 @@ pub(super) fn prune_views<'s>(retained.push(entry);} else {// Keep observable wrappers alive until dispose delivery, before pruning the cache.- removed.push(super::history_runtime::native::entry_wrapper(- scope, owner, entry,- ));+ removed.push(entry_wrappers::for_window(scope, owner, entry));}}if retained.len() == old_len {diff --git a/moli-renderer-v8/src/context_bootstrap/shared_event_targets.rs b/moli-renderer-v8/src/context_bootstrap/shared_event_targets.rsindex 5c17d3457..9deee4951 100644--- a/moli-renderer-v8/src/context_bootstrap/shared_event_targets.rs+++ b/moli-renderer-v8/src/context_bootstrap/shared_event_targets.rs@@ -3,6 +3,7 @@//! dispatch still runs once, with one cancellation/propagation state.use super::{history_runtime::native, media_queries};+use crate::context_bootstrap::navigation_entry::wrappers as entry_wrappers;use crate::util::{get_private_object, get_private_value, set_private_value, v8str};const OWNER: &str = "__moliSharedEventTargetOwner";@@ -74,7 +75,7 @@ pub(super) fn target_in_realm<'s>(.map(|navigation| target_in_realm(scope, navigation, context)).and_then(|navigation| navigation.get_creation_context(scope)).unwrap_or(context);- return native::entry_in_realm(scope, owner, context);+ return entry_wrappers::in_realm(scope, owner, context);}let global = context.global(scope);get_private_value(scope, global, WRAPPERS)diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/history_worlds.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/history_worlds.rsindex 4e9f923c3..d87648b68 100644--- a/moli-renderer-v8/src/script_vm/tests/browser_api/history_worlds.rs+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/history_worlds.rs@@ -691,6 +691,102 @@ fn history_worlds_navigation_entries_keep_their_own_wrappers() {);}+#[test]+fn history_worlds_navigation_entry_views_are_collectible_and_rejoin_the_shared_target() {+ let mut vm = new_storage_test_vm("https://example.com/base");+ vm.eval(+ r#"+ globalThis.pageEntry = navigation.currentEntry;+ globalThis.pageDisposes = 0;+ pageEntry.expando = 'page';+ pageEntry.ondispose = () => pageDisposes++;+ navigation.updateCurrentEntry({state: {value: 7}});+ 'ready'+ "#,+ )+ .unwrap();+ let isolated = vm.create_isolated_world("entry-view-gc", false).unwrap();+ vm.eval_in_isolated_context(+ isolated,+ "globalThis.keptEntry = navigation.currentEntry; 'observed'",+ )+ .unwrap();+ let context_ptr = &vm+ .page_isolated_world_contexts+ .context(isolated)+ .unwrap()+ .context as *const _;+ let weak_entry = vm+ .with_context_scope_by_ptr_and_checkpoint_for_test(context_ptr, |scope, _| {+ let global = scope.get_current_context().global(scope);+ let entry = global+ .get(scope, crate::util::v8str(scope, "keptEntry").into())+ .unwrap();+ let entry = v8::Local::<v8::Object>::try_from(entry).unwrap();+ Ok(v8::Weak::new(scope, entry))+ })+ .unwrap();+ assert_eq!(+ vm.eval_in_isolated_context(+ isolated,+ "String(keptEntry === navigation.currentEntry && navigation.entries().includes(keptEntry))",+ )+ .unwrap(),+ "true"+ );+ vm.eval_in_isolated_context(isolated, "keptEntry = null; 'released'")+ .unwrap();+ vm.renderer_document_isolate+ .with_entered_renderer_document_isolate(|isolate| {+ isolate.low_memory_notification();+ Ok(())+ })+ .unwrap();+ vm.with_context_scope_by_ptr_and_checkpoint_for_test(context_ptr, |scope, _| {+ assert!(+ weak_entry.to_local(scope).is_none(),+ "the owning Window must not retain an unobserved entry view"+ );+ Ok(())+ })+ .unwrap();+ assert_eq!(+ vm.eval_in_isolated_context(+ isolated,+ r#"+ globalThis.keptEntry = navigation.currentEntry;+ globalThis.disposeFacts = [];+ keptEntry.addEventListener('dispose', function (event) {+ disposeFacts.push(this === keptEntry, event.target === keptEntry,+ event.currentTarget === keptEntry, event instanceof Event);+ }, {once: true});+ JSON.stringify([+ keptEntry instanceof NavigationHistoryEntry,+ keptEntry === navigation.currentEntry,+ navigation.entries().includes(keptEntry),+ keptEntry.expando === undefined,+ keptEntry.url, keptEntry.index, keptEntry.getState().value+ ])+ "#,+ )+ .unwrap(),+ r#"[true,true,true,true,"https://example.com/base",0,7]"#+ );+ assert_eq!(+ vm.eval("String(navigation.currentEntry === pageEntry)")+ .unwrap(),+ "true"+ );+ vm.eval("history.replaceState({}, '', '#replaced'); 'replaced'")+ .unwrap();+ assert_eq!(vm.eval("String(pageDisposes)").unwrap(), "1");+ assert_eq!(+ vm.eval_in_isolated_context(isolated, "JSON.stringify(disposeFacts)")+ .unwrap(),+ "[true,true,true,true]"+ );+}+#[test]fn history_worlds_navigation_listeners_share_notifications_and_cancellation() {let mut vm = new_storage_test_vm("https://example.com/base");