Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

refactor(renderer): bind service worker callbacks to window owners

ldm0cde08f79e3e2
diff --git a/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs b/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs
index dd3f3a04b..ede633701 100644
--- a/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs
+++ b/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs
@@ -400,7 +400,7 @@ pub(in crate::context_bootstrap) fn navigator_service_worker_register_callback<'
rv.set(promise.into());
return;
};
- let (request_id, runtime_generation, completion_tx) =
+ let (request_id, document_owner, completion_tx) =
host.register_pending_service_worker_register(scope, resolver, request_context.owner());
host.start_service_worker_runtime(
script_url,
@@ -410,7 +410,7 @@ pub(in crate::context_bootstrap) fn navigator_service_worker_register_callback<'
&request_context,
request_client,
request_id,
- runtime_generation,
+ document_owner,
completion_tx,
);
rv.set(promise.into());
@@ -521,7 +521,7 @@ pub(crate) fn dispatch_service_worker_lifecycle_notification(
scope,
notification.registration.scope_url(),
&notification.storage_key,
- notification.runtime_generation,
+ notification.document_owner,
);
for (owner, registration) in registrations {
let previous_owner_context = owner.enter(scope);
@@ -1174,7 +1174,7 @@ fn navigator_service_worker_unregister_callback<'s>(
rv.set(promise.into());
return;
};
- let (request_id, runtime_generation, completion_tx) = host
+ let (request_id, document_owner, completion_tx) = host
.register_pending_service_worker_unregister(
scope,
resolver,
@@ -1187,13 +1187,13 @@ fn navigator_service_worker_unregister_callback<'s>(
&request_context,
scope_url,
request_id,
- runtime_generation,
+ document_owner,
completion_tx,
),
None => host.unregister_service_worker_control(
&request_context,
request_id,
- runtime_generation,
+ document_owner,
completion_tx,
),
};
diff --git a/moli-renderer-v8/src/lib.rs b/moli-renderer-v8/src/lib.rs
index 8a6189e01..0de98edd2 100644
--- a/moli-renderer-v8/src/lib.rs
+++ b/moli-renderer-v8/src/lib.rs
@@ -108,6 +108,7 @@ pub(crate) mod webidl;
#[cfg(test)]
mod webidl_callback_source_boundary_tests;
mod webidl_iterator;
+mod window_document_identity;
mod window_host;
mod window_webidl_callback;
pub(crate) mod worker;
diff --git a/moli-renderer-v8/src/native_bridge/context_host/core.rs b/moli-renderer-v8/src/native_bridge/context_host/core.rs
index 3bed1bcdc..fdf9d60d0 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/core.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/core.rs
@@ -171,11 +171,14 @@ impl JsContextHost {
},
None,
);
- let main_document_epoch = frame_owner_store
+ let main_owner_snapshot = frame_owner_store
.current_main_owner_snapshot()
- .expect("main frame owner must exist before client projection")
- .document_id
- .0;
+ .expect("main frame owner must exist before client projection");
+ let main_document_owner = FrameDocumentTaskOwner::new(
+ main_owner_snapshot.scheduler_lane_id,
+ main_owner_snapshot.local_window_id,
+ main_owner_snapshot.document_id,
+ );
let service_worker_storage_key = top_level_storage_key
.as_ref()
.map(moli_storage_key::MoliStorageKey::serialized_storage_key)
@@ -189,8 +192,7 @@ impl JsContextHost {
document_url.clone(),
service_worker_storage_key.clone(),
crate::service_worker_runtime::ServiceWorkerClientFrameType::TopLevel,
- Some(main_document_epoch),
- runtime.runtime_reset_generation(),
+ Some(super::WindowDocumentOwner::Frame(main_document_owner)),
service_worker_task_tx.clone(),
)
})
@@ -199,8 +201,7 @@ impl JsContextHost {
document_url,
service_worker_storage_key,
crate::service_worker_runtime::ServiceWorkerClientFrameType::TopLevel,
- Some(main_document_epoch),
- runtime.runtime_reset_generation(),
+ Some(super::WindowDocumentOwner::Frame(main_document_owner)),
service_worker_task_tx.clone(),
)
});
diff --git a/moli-renderer-v8/src/native_bridge/context_host/mod.rs b/moli-renderer-v8/src/native_bridge/context_host/mod.rs
index 2207d67c8..4871fc914 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/mod.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/mod.rs
@@ -160,6 +160,11 @@ mod window_security_tokens;
mod workers;
pub(crate) use window_security_tokens::set_window_security_token;
+#[cfg(test)]
+pub(crate) use crate::window_document_identity::LightweightPopupDocumentId;
+pub(crate) use crate::window_document_identity::{
+ LightweightPopupDocumentOwner, LightweightPopupLocalWindowId, WindowDocumentOwner,
+};
use crate::{
frame_owner_model::FrameDocumentLoadDeliveryTask, runtime::ServiceWorkerControlState,
service_worker_runtime::ServiceWorkerClientId,
@@ -194,11 +199,8 @@ pub(crate) use moli_page_types::{
NavigationActivationSeed, NavigationHistoryEntrySeed, NavigationHistorySerializedEntry,
};
pub(crate) use navigation::{PendingLocationNavigation, PendingTopLevelNavigation};
-#[cfg(test)]
-pub(crate) use popups::LightweightPopupDocumentId;
pub(crate) use popups::{
LightweightPopupClassicScriptFetchTarget, LightweightPopupDocumentFetchTarget,
- LightweightPopupDocumentOwner, LightweightPopupLocalWindowId,
LightweightPopupNavigationTaskToken, PopupClassicScriptLoadApplication,
PopupDocumentLoadApplication, PopupDocumentLoadBodyActivity, active_lightweight_popup_id,
defer_active_lightweight_popup_restore, enter_active_lightweight_popup_scope,
@@ -307,28 +309,6 @@ pub(crate) struct OwnerDispatchRestore<'s> {
previous_popup: v8::Local<'s, v8::Value>,
}
-#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
-pub(crate) enum WindowDocumentOwner {
- Frame(FrameDocumentTaskOwner),
- LightweightPopup(LightweightPopupDocumentOwner),
-}
-
-impl WindowDocumentOwner {
- pub(crate) fn frame_document_owner(self) -> Option<FrameDocumentTaskOwner> {
- match self {
- Self::Frame(owner) => Some(owner),
- Self::LightweightPopup(_) => None,
- }
- }
-
- pub(crate) fn projected_document_epoch(self) -> u64 {
- match self {
- Self::Frame(owner) => owner.document_id.0,
- Self::LightweightPopup(owner) => owner.document_id().as_u64(),
- }
- }
-}
-
/// Exact Document plus the Window dispatch address used by a queued task.
///
/// A `WindowDocumentOwner` alone is not enough for child frames and
@@ -901,7 +881,7 @@ pub(crate) struct JsContextHost {
HashMap<u64, service_workers::PendingServiceWorkerUnregister>,
pending_service_worker_ready: HashMap<u64, service_workers::PendingServiceWorkerReady>,
service_worker_registration_watchers: Vec<service_workers::ServiceWorkerRegistrationWatcher>,
- service_worker_lifecycle_watched_scopes: HashSet<(Url, String, u64)>,
+ service_worker_lifecycle_watched_scopes: HashSet<(Url, String, WindowDocumentOwner)>,
service_worker_popup_clients: HashMap<u64, ServiceWorkerClientId>,
pending_service_worker_clients_open_window_popups:
HashMap<u64, service_workers::PendingServiceWorkerClientsOpenWindowPopup>,
diff --git a/moli-renderer-v8/src/native_bridge/context_host/popups.rs b/moli-renderer-v8/src/native_bridge/context_host/popups.rs
index 84dcb9833..78445490f 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/popups.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/popups.rs
@@ -49,6 +49,9 @@ use crate::{
context_host_ptr_from_global_bridge, get_private_value, set_private_value,
throw_type_error, v8_string, v8str,
},
+ window_document_identity::{
+ LightweightPopupDocumentId, LightweightPopupDocumentOwner, LightweightPopupLocalWindowId,
+ },
};
use anyhow::Result;
use moli_crypto::sha256_hex;
@@ -213,55 +216,6 @@ pub(super) struct PendingLightweightPopupClassicScriptLoad {
cancel_handle: moli_fetch::FetchCancelHandle,
}
-#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
-pub(crate) struct LightweightPopupDocumentId(u64);
-
-impl LightweightPopupDocumentId {
- pub(crate) fn new(value: u64) -> Self {
- Self(value)
- }
-
- pub(crate) fn as_u64(self) -> u64 {
- self.0
- }
-}
-
-#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
-pub(crate) struct LightweightPopupLocalWindowId(u64);
-
-impl LightweightPopupLocalWindowId {
- pub(crate) fn new(value: u64) -> Self {
- Self(value)
- }
-
- pub(crate) fn as_u64(self) -> u64 {
- self.0
- }
-}
-
-#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
-pub(crate) struct LightweightPopupDocumentOwner {
- popup_id: u64,
- document_id: LightweightPopupDocumentId,
-}
-
-impl LightweightPopupDocumentOwner {
- pub(crate) fn new(popup_id: u64, document_id: LightweightPopupDocumentId) -> Self {
- Self {
- popup_id,
- document_id,
- }
- }
-
- pub(crate) fn popup_id(self) -> u64 {
- self.popup_id
- }
-
- pub(crate) fn document_id(self) -> LightweightPopupDocumentId {
- self.document_id
- }
-}
-
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
struct LightweightPopupNavigationId(u64);
diff --git a/moli-renderer-v8/src/native_bridge/context_host/runtime_observable.rs b/moli-renderer-v8/src/native_bridge/context_host/runtime_observable.rs
index ca3bf3e07..477989ba4 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/runtime_observable.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/runtime_observable.rs
@@ -645,8 +645,8 @@ mod tests {
frame_owner_model::LocalWindowId,
native_bridge::context_host::{
WindowExecutionContextRealmRecords, WindowExecutionContextScopedRealmRegistration,
- popups::LightweightPopupLocalWindowId,
},
+ window_document_identity::LightweightPopupLocalWindowId,
};
#[test]
diff --git a/moli-renderer-v8/src/native_bridge/context_host/service_workers.rs b/moli-renderer-v8/src/native_bridge/context_host/service_workers.rs
index 076d6652e..1b7678396 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/service_workers.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/service_workers.rs
@@ -24,7 +24,6 @@ pub(super) fn service_worker_first_party_storage_key(document_url: &Url) -> Stri
pub(crate) struct ServiceWorkerWindowOwner {
dispatch_scope: OwnerDispatchScope,
document_owner: WindowDocumentOwner,
- transport_generation: u64,
}
impl ServiceWorkerWindowOwner {
@@ -39,14 +38,6 @@ impl ServiceWorkerWindowOwner {
pub(crate) fn window_document_owner(self) -> WindowDocumentOwner {
self.document_owner
}
-
- pub(crate) fn document_epoch(self) -> Option<u64> {
- Some(self.document_owner.projected_document_epoch())
- }
-
- pub(crate) fn transport_generation(self) -> u64 {
- self.transport_generation
- }
}
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -139,7 +130,6 @@ impl JsContextHost {
Some(ServiceWorkerWindowOwner {
dispatch_scope,
document_owner,
- transport_generation: self.runtime_reset_generation(),
})
}
@@ -151,8 +141,7 @@ impl JsContextHost {
let owner = self.service_worker_window_owner_for_dispatch_scope(dispatch_scope)?;
Some(crate::types::ServiceWorkerWindowClientTarget {
client_id: self.service_worker_client_id_for_subresource_owner(dispatch_scope),
- document_epoch: owner.document_epoch(),
- transport_generation: owner.transport_generation(),
+ document_owner: owner.window_document_owner(),
})
}
@@ -203,10 +192,7 @@ impl JsContextHost {
(
OwnerDispatchScope::LightweightPopup(popup_id),
WindowDocumentOwner::LightweightPopup(document_owner),
- ) => {
- owner.transport_generation() == self.runtime_reset_generation()
- && document_owner.popup_id() == popup_id
- }
+ ) => document_owner.popup_id() == popup_id,
_ => false,
}
}
@@ -298,11 +284,9 @@ impl JsContextHost {
pending.request_context.owner().document_owner() != Some(retired_owner)
});
- let transport_generation = self.runtime_reset_generation();
let current_window_owner = ServiceWorkerWindowOwner {
dispatch_scope: OwnerDispatchScope::Top,
document_owner: WindowDocumentOwner::Frame(transition.current_owner()),
- transport_generation,
};
let mut rebound_scopes = Vec::new();
self.service_worker_registration_watchers
@@ -315,20 +299,20 @@ impl JsContextHost {
rebound_scopes.push((watcher.scope_url.clone(), watcher.storage_key.clone()));
}
self.service_worker_lifecycle_watched_scopes
- .retain(|(_, _, generation)| *generation == transport_generation);
+ .retain(|(_, _, owner)| *owner != WindowDocumentOwner::Frame(retired_owner));
let mut rebound_watcher_count = 0usize;
for (scope_url, storage_key) in rebound_scopes {
rebound_watcher_count += 1;
if self.service_worker_lifecycle_watched_scopes.insert((
scope_url.clone(),
storage_key.clone(),
- transport_generation,
+ current_window_owner.window_document_owner(),
)) {
self.browser_context_runtime
.watch_service_worker_registration_lifecycle(
scope_url,
storage_key,
- transport_generation,
+ current_window_owner.window_document_owner(),
self.service_worker_task_sender(),
);
}
@@ -336,7 +320,6 @@ impl JsContextHost {
tracing::debug!(
?retired_owner,
current_owner = ?transition.current_owner(),
- transport_generation,
retired_register_resolvers =
register_count - self.pending_service_worker_registers.len(),
retired_unregister_resolvers =
@@ -353,7 +336,7 @@ impl JsContextHost {
) {
let document_url = self.document_url().clone();
let storage_key = self.service_worker_document_storage_key();
- let runtime_generation = self.runtime_reset_generation();
+ let document_owner = WindowDocumentOwner::Frame(transition.current_owner());
let updated = self
.browser_context_runtime
.update_service_worker_client_document(
@@ -361,15 +344,14 @@ impl JsContextHost {
document_url.clone(),
storage_key,
ServiceWorkerClientFrameType::TopLevel,
- Some(transition.current_owner().document_id.0),
- runtime_generation,
+ Some(document_owner),
);
if updated {
tracing::debug!(
retired_owner = ?transition.retired_owner(),
current_owner = ?transition.current_owner(),
client_id = ?self.service_worker_client_id,
- runtime_generation,
+ ?document_owner,
document_url = %document_url,
"updated top-level service worker client in main document owner transaction"
);
@@ -378,7 +360,7 @@ impl JsContextHost {
retired_owner = ?transition.retired_owner(),
current_owner = ?transition.current_owner(),
client_id = ?self.service_worker_client_id,
- runtime_generation,
+ ?document_owner,
document_url = %document_url,
"main document owner transaction could not update its service worker client"
);
@@ -398,7 +380,7 @@ impl JsContextHost {
owner: ServiceWorkerWindowOwner,
) -> (
u64,
- u64,
+ WindowDocumentOwner,
crate::page_task_queue::RendererPageServiceWorkerTaskSender,
) {
let request_id = self.next_service_worker_register_request_id;
@@ -418,12 +400,11 @@ impl JsContextHost {
request_id,
dispatch_scope = ?owner.dispatch_scope(),
window_document_owner = ?owner.window_document_owner(),
- transport_generation = owner.transport_generation(),
"registered owner-bound service worker register resolver"
);
(
request_id,
- owner.transport_generation(),
+ owner.window_document_owner(),
self.service_worker_task_sender(),
)
}
@@ -457,7 +438,7 @@ impl JsContextHost {
owner: ServiceWorkerWindowOwner,
) -> (
u64,
- u64,
+ WindowDocumentOwner,
crate::page_task_queue::RendererPageServiceWorkerTaskSender,
) {
let request_id = self.next_service_worker_register_request_id;
@@ -479,12 +460,11 @@ impl JsContextHost {
request_id,
dispatch_scope = ?owner.dispatch_scope(),
window_document_owner = ?owner.window_document_owner(),
- transport_generation = owner.transport_generation(),
"registered owner-bound service worker unregister resolver"
);
(
request_id,
- owner.transport_generation(),
+ owner.window_document_owner(),
self.service_worker_task_sender(),
)
}
@@ -522,7 +502,6 @@ impl JsContextHost {
request_id,
dispatch_scope = ?owner.dispatch_scope(),
window_document_owner = ?owner.window_document_owner(),
- transport_generation = owner.transport_generation(),
"registered owner-bound service worker ready resolver"
);
request_id
@@ -593,7 +572,7 @@ impl JsContextHost {
request_context: &ServiceWorkerWindowRequestContext,
request_client: crate::network::ResourceRequestClient,
register_request_id: u64,
- register_runtime_generation: u64,
+ register_document_owner: WindowDocumentOwner,
register_completion_tx: crate::page_task_queue::RendererPageServiceWorkerTaskSender,
) {
let creator_secure_context =
@@ -631,7 +610,7 @@ impl JsContextHost {
Some(self.storage_bucket_store()),
update_via_cache,
register_request_id,
- register_runtime_generation,
+ register_document_owner,
register_completion_tx,
);
self.watch_pending_service_worker_ready();
@@ -647,7 +626,7 @@ impl JsContextHost {
request_context.document_url().clone(),
request_context.serialized_storage_key(),
request_id,
- request_context.owner().transport_generation(),
+ request_context.owner().window_document_owner(),
completion_tx,
)
{
@@ -814,20 +793,19 @@ impl JsContextHost {
if self.service_worker_lifecycle_watched_scopes.insert((
scope_url.clone(),
storage_key.clone(),
- owner.transport_generation(),
+ owner.window_document_owner(),
)) {
self.browser_context_runtime
.watch_service_worker_registration_lifecycle(
scope_url,
storage_key,
- owner.transport_generation(),
+ owner.window_document_owner(),
self.service_worker_task_sender(),
);
}
tracing::debug!(
?dispatch_scope,
window_document_owner = ?owner.window_document_owner(),
- transport_generation = owner.transport_generation(),
"registered owner-bound service worker lifecycle watcher"
);
}
@@ -837,13 +815,13 @@ impl JsContextHost {
scope: &mut v8::PinScope<'s, '_>,
scope_url: &Url,
storage_key: &str,
- runtime_generation: u64,
+ document_owner: WindowDocumentOwner,
) -> Vec<(OwnerDispatchScope, v8::Local<'s, v8::Object>)> {
self.compact_service_worker_registration_watchers();
self.service_worker_registration_watchers
.iter()
.filter(|watcher| {
- watcher.owner.transport_generation() == runtime_generation
+ watcher.owner.window_document_owner() == document_owner
&& watcher.scope_url == *scope_url
&& watcher.storage_key == storage_key
})
@@ -857,22 +835,25 @@ impl JsContextHost {
}
fn compact_service_worker_registration_watchers(&mut self) {
- let runtime_generation = self.runtime_reset_generation();
let mut watchers = std::mem::take(&mut self.service_worker_registration_watchers);
watchers.retain(|watcher| {
!watcher.registration.is_empty()
&& self.service_worker_window_owner_is_current(watcher.owner)
});
+ let current_owners = watchers
+ .iter()
+ .map(|watcher| watcher.owner.window_document_owner())
+ .collect::<std::collections::HashSet<_>>();
self.service_worker_registration_watchers = watchers;
self.service_worker_lifecycle_watched_scopes
- .retain(|(_, _, generation)| *generation == runtime_generation);
+ .retain(|(_, _, owner)| current_owners.contains(owner));
}
pub(crate) fn unregister_service_worker_control(
&mut self,
request_context: &ServiceWorkerWindowRequestContext,
request_id: u64,
- runtime_generation: u64,
+ document_owner: WindowDocumentOwner,
completion_tx: crate::page_task_queue::RendererPageServiceWorkerTaskSender,
) -> ServiceWorkerUnregisterStart {
let state = self.service_worker_control_state_for_window_owner(
@@ -883,7 +864,7 @@ impl JsContextHost {
request_context,
state.scope_url(),
request_id,
- runtime_generation,
+ document_owner,
completion_tx,
);
}
@@ -895,7 +876,7 @@ impl JsContextHost {
request_context: &ServiceWorkerWindowRequestContext,
scope_url: &Url,
request_id: u64,
- runtime_generation: u64,
+ document_owner: WindowDocumentOwner,
completion_tx: crate::page_task_queue::RendererPageServiceWorkerTaskSender,
) -> ServiceWorkerUnregisterStart {
self.browser_context_runtime
@@ -903,7 +884,7 @@ impl JsContextHost {
scope_url,
request_context.serialized_storage_key(),
request_id,
- runtime_generation,
+ document_owner,
completion_tx,
)
}
@@ -981,8 +962,7 @@ impl JsContextHost {
let Some(dispatch_scope) = self.service_worker_window_client_owner(target.client_id) else {
tracing::debug!(
client_id = ?target.client_id,
- target_document_epoch = ?target.document_epoch,
- target_generation = target.transport_generation,
+ target_document_owner = ?target.document_owner,
"dropped service worker completion for retired window client"
);
return None;
@@ -992,23 +972,17 @@ impl JsContextHost {
tracing::debug!(
client_id = ?target.client_id,
?dispatch_scope,
- target_document_epoch = ?target.document_epoch,
- target_generation = target.transport_generation,
+ target_document_owner = ?target.document_owner,
"dropped service worker completion for retired window document owner"
);
return None;
};
- if owner.transport_generation() != target.transport_generation
- || owner.document_epoch() != target.document_epoch
- {
+ if owner.window_document_owner() != target.document_owner {
tracing::debug!(
client_id = ?target.client_id,
?dispatch_scope,
window_document_owner = ?owner.window_document_owner(),
- target_document_epoch = ?target.document_epoch,
- current_document_epoch = ?owner.document_epoch(),
- target_generation = target.transport_generation,
- current_generation = owner.transport_generation(),
+ target_document_owner = ?target.document_owner,
"dropped stale service worker window client completion target"
);
return None;
@@ -1031,7 +1005,6 @@ impl JsContextHost {
storage_key,
ServiceWorkerClientFrameType::TopLevel,
None,
- self.runtime_reset_generation(),
),
)
}
@@ -1097,8 +1070,7 @@ impl JsContextHost {
document_url,
storage_key,
ServiceWorkerClientFrameType::TopLevel,
- Some(document_owner.document_id().as_u64()),
- self.runtime_reset_generation(),
+ Some(WindowDocumentOwner::LightweightPopup(document_owner)),
);
return Some(client_id);
}
@@ -1106,8 +1078,7 @@ impl JsContextHost {
document_url,
storage_key,
ServiceWorkerClientFrameType::TopLevel,
- Some(document_owner.document_id().as_u64()),
- self.runtime_reset_generation(),
+ Some(WindowDocumentOwner::LightweightPopup(document_owner)),
self.service_worker_task_sender(),
);
self.service_worker_popup_clients
@@ -1133,8 +1104,7 @@ impl JsContextHost {
document_url,
storage_key,
ServiceWorkerClientFrameType::TopLevel,
- Some(document_owner.document_id().as_u64()),
- self.runtime_reset_generation(),
+ Some(WindowDocumentOwner::LightweightPopup(document_owner)),
)
}
@@ -1144,11 +1114,10 @@ impl JsContextHost {
) -> Option<ServiceWorkerClientId> {
let document_url = self.child_browsing_context_current_url(handle)?;
let storage_key = service_worker_first_party_storage_key(&document_url);
- let runtime_generation = self.runtime_reset_generation();
- let document_epoch = self
+ let document_owner = self
.frame_owner_store
.current_child_document_task_owner(handle)
- .map(|owner| owner.document_id.0)?;
+ .map(WindowDocumentOwner::Frame)?;
let existing_client_id = self
.child_browsing_contexts
.get(&handle)
@@ -1161,8 +1130,7 @@ impl JsContextHost {
document_url.clone(),
storage_key.clone(),
ServiceWorkerClientFrameType::Nested,
- Some(document_epoch),
- runtime_generation,
+ Some(document_owner),
self.service_worker_task_sender(),
)
{
@@ -1174,8 +1142,7 @@ impl JsContextHost {
document_url,
storage_key,
ServiceWorkerClientFrameType::Nested,
- Some(document_epoch),
- runtime_generation,
+ Some(document_owner),
self.service_worker_task_sender(),
);
if let Some(entry) = self.child_browsing_contexts.get_mut(&handle) {
@@ -1206,7 +1173,6 @@ impl JsContextHost {
storage_key,
ServiceWorkerClientFrameType::Nested,
None,
- self.runtime_reset_generation(),
);
if let Some(entry) = self.child_browsing_contexts.get_mut(&handle) {
entry.set_pending_service_worker_client_id(client_id);
diff --git a/moli-renderer-v8/src/page_task_queue/service_worker_tasks.rs b/moli-renderer-v8/src/page_task_queue/service_worker_tasks.rs
index 17da8bff5..e6837fae4 100644
--- a/moli-renderer-v8/src/page_task_queue/service_worker_tasks.rs
+++ b/moli-renderer-v8/src/page_task_queue/service_worker_tasks.rs
@@ -214,14 +214,13 @@ mod tests {
let sender = harness.sender();
let target = ServiceWorkerWindowClientTarget {
client_id: ServiceWorkerClientId::from_u64_for_test(17),
- document_epoch: Some(23),
- transport_generation: 29,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(23),
};
sender
.send_service_worker_unregister(ServiceWorkerUnregisterCompletion {
request_id: 31,
- runtime_generation: 37,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(37),
result: true,
})
.expect("internal callback should enter its typed source");
diff --git a/moli-renderer-v8/src/runtime/browser_context_runtime/service_workers.rs b/moli-renderer-v8/src/runtime/browser_context_runtime/service_workers.rs
index 66759ce66..fe533bffb 100644
--- a/moli-renderer-v8/src/runtime/browser_context_runtime/service_workers.rs
+++ b/moli-renderer-v8/src/runtime/browser_context_runtime/service_workers.rs
@@ -90,7 +90,6 @@ impl RendererBrowserContextRuntime {
storage_key,
ServiceWorkerClientFrameType::TopLevel,
None,
- 0,
)
} else {
self.register_reserved_service_worker_client(
@@ -98,7 +97,6 @@ impl RendererBrowserContextRuntime {
storage_key,
ServiceWorkerClientFrameType::TopLevel,
None,
- 0,
)
};
let reserved_client = RendererReservedServiceWorkerClient::new(self.clone(), client_id);
@@ -375,8 +373,7 @@ impl RendererBrowserContextRuntime {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
completion_tx: crate::page_task_queue::RendererPageServiceWorkerTaskSender,
) -> ServiceWorkerClientId {
self.inner
@@ -385,8 +382,7 @@ impl RendererBrowserContextRuntime {
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
completion_tx,
)
}
@@ -396,8 +392,7 @@ impl RendererBrowserContextRuntime {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
) -> ServiceWorkerClientId {
self.inner
.service_worker_runtime
@@ -405,8 +400,7 @@ impl RendererBrowserContextRuntime {
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
)
}
@@ -415,8 +409,7 @@ impl RendererBrowserContextRuntime {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
) -> ServiceWorkerClientId {
self.inner
.service_worker_runtime
@@ -424,8 +417,7 @@ impl RendererBrowserContextRuntime {
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
)
}
@@ -477,8 +469,7 @@ impl RendererBrowserContextRuntime {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
) -> bool {
self.inner
.service_worker_runtime
@@ -487,8 +478,7 @@ impl RendererBrowserContextRuntime {
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
)
}
@@ -498,8 +488,7 @@ impl RendererBrowserContextRuntime {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
completion_tx: crate::page_task_queue::RendererPageServiceWorkerTaskSender,
) -> bool {
self.inner
@@ -509,8 +498,7 @@ impl RendererBrowserContextRuntime {
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
completion_tx,
)
}
@@ -520,7 +508,7 @@ impl RendererBrowserContextRuntime {
scope_url: &Url,
storage_key: String,
request_id: u64,
- runtime_generation: u64,
+ document_owner: crate::window_document_identity::WindowDocumentOwner,
completion_tx: crate::page_task_queue::RendererPageServiceWorkerTaskSender,
) -> ServiceWorkerUnregisterStart {
self.inner
@@ -529,7 +517,7 @@ impl RendererBrowserContextRuntime {
scope_url,
storage_key,
request_id,
- runtime_generation,
+ document_owner,
completion_tx,
)
}
@@ -588,7 +576,7 @@ impl RendererBrowserContextRuntime {
document_url: Url,
storage_key: String,
request_id: u64,
- runtime_generation: u64,
+ document_owner: crate::window_document_identity::WindowDocumentOwner,
completion_tx: crate::page_task_queue::RendererPageServiceWorkerTaskSender,
) -> bool {
self.inner
@@ -597,7 +585,7 @@ impl RendererBrowserContextRuntime {
document_url,
storage_key,
request_id,
- runtime_generation,
+ document_owner,
completion_tx,
)
}
@@ -606,12 +594,12 @@ impl RendererBrowserContextRuntime {
&self,
scope_url: Url,
storage_key: String,
- runtime_generation: u64,
+ document_owner: crate::window_document_identity::WindowDocumentOwner,
completion_tx: crate::page_task_queue::RendererPageServiceWorkerTaskSender,
) {
self.inner
.service_worker_runtime
- .watch_registration_lifecycle(scope_url, storage_key, runtime_generation, completion_tx)
+ .watch_registration_lifecycle(scope_url, storage_key, document_owner, completion_tx)
}
pub(crate) fn service_worker_controller_for_client(
diff --git a/moli-renderer-v8/src/runtime/page_turn_scheduler.rs b/moli-renderer-v8/src/runtime/page_turn_scheduler.rs
index 83922155a..ab42c8722 100644
--- a/moli-renderer-v8/src/runtime/page_turn_scheduler.rs
+++ b/moli-renderer-v8/src/runtime/page_turn_scheduler.rs
@@ -770,8 +770,7 @@ mod tests {
crate::service_worker_runtime::ServiceWorkerClientId::from_u64_for_test(
order,
),
- document_epoch: Some(order + 1),
- transport_generation: order + 2,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(order + 1),
},
),
}
diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/service_worker.rs b/moli-renderer-v8/src/runtime/page_vm/tests/service_worker.rs
index e5ddd56f7..19d25f945 100644
--- a/moli-renderer-v8/src/runtime/page_vm/tests/service_worker.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/tests/service_worker.rs
@@ -42,7 +42,7 @@ async fn service_worker_internal_body_authorizes_the_exact_root_document() {
.service_worker_task_sender_for_root_for_test(current_root)
.send_service_worker_unregister(ServiceWorkerUnregisterCompletion {
request_id: 47,
- runtime_generation: 53,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(53),
result: false,
})
.expect("current-root callback should enter the stable source");
@@ -94,7 +94,7 @@ async fn service_worker_internal_body_authorizes_the_exact_root_document() {
.service_worker_task_sender_for_root_for_test(stale_root)
.send_service_worker_unregister(ServiceWorkerUnregisterCompletion {
request_id: 59,
- runtime_generation: 61,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(61),
result: true,
})
.expect("stale callback should still enter one discard turn");
@@ -145,8 +145,7 @@ async fn service_worker_client_message_authorizes_root_before_window_client_targ
let current_root = page_vm.document_lifecycle.identity().document;
let stale_target = ServiceWorkerWindowClientTarget {
client_id: ServiceWorkerClientId::from_u64_for_test(u64::MAX - 7),
- document_epoch: Some(u64::MAX - 5),
- transport_generation: u64::MAX - 3,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(u64::MAX - 5),
};
page_vm
diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/service_worker_client_message.rs b/moli-renderer-v8/src/runtime/page_vm/tests/service_worker_client_message.rs
index 72225aae2..d5daaecfb 100644
--- a/moli-renderer-v8/src/runtime/page_vm/tests/service_worker_client_message.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/tests/service_worker_client_message.rs
@@ -432,8 +432,8 @@ navigator.serviceWorker.onmessage = () => {
)?;
assert_eq!(current_target.client_id, target.client_id);
assert_ne!(
- current_target.document_epoch, target.document_epoch,
- "document.open must retire the authorized ServiceWorker client target epoch"
+ current_target.document_owner, target.document_owner,
+ "document.open must retire the authorized ServiceWorker client document owner"
);
assert_eq!(
page_vm
@@ -611,8 +611,8 @@ document.getElementById("service-worker-message-replacement-child").srcdoc =
);
assert_eq!(retired_target.client_id, current_target.client_id);
assert_ne!(
- retired_target.document_epoch, current_target.document_epoch,
- "document epoch must distinguish reused child client ids"
+ retired_target.document_owner, current_target.document_owner,
+ "exact document owner must distinguish reused child client ids"
);
page_vm.vm_mut().eval(
r#"
diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/service_worker_internal.rs b/moli-renderer-v8/src/runtime/page_vm/tests/service_worker_internal.rs
index 29df1901c..3ee8e4f75 100644
--- a/moli-renderer-v8/src/runtime/page_vm/tests/service_worker_internal.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/tests/service_worker_internal.rs
@@ -16,7 +16,7 @@ use crate::{
struct PreparedServiceWorkerLifecycleTarget {
registration: ServiceWorkerRegistrationSnapshot,
- runtime_generation: u64,
+ document_owner: crate::native_bridge::WindowDocumentOwner,
storage_key: String,
}
@@ -33,7 +33,7 @@ navigator.serviceWorker.ready.then(registration => {
"ready-observer-installed"
"#,
)?;
- let (request_id, runtime_generation) = page_vm
+ let (request_id, document_owner) = page_vm
.vm()
.service_worker_ready_request_for_test(crate::native_bridge::OwnerDispatchScope::Top)
.expect("top-level ServiceWorker ready request");
@@ -47,7 +47,7 @@ navigator.serviceWorker.ready.then(registration => {
.service_worker_task_sender_for_root_for_test(root_document)
.send_service_worker_ready(ServiceWorkerReadyCompletion {
request_id,
- runtime_generation,
+ document_owner,
registration: registration.clone(),
})
.expect("ready completion should enter the stable internal source");
@@ -68,7 +68,7 @@ navigator.serviceWorker.ready.then(registration => {
"selected ready completion should resolve the registration binding"
);
- let (watcher_generation, storage_key) = page_vm
+ let (watcher_owner, storage_key) = page_vm
.vm()
.service_worker_lifecycle_watcher_for_test(
crate::native_bridge::OwnerDispatchScope::Top,
@@ -76,12 +76,12 @@ navigator.serviceWorker.ready.then(registration => {
)
.expect("ready registration should install one exact lifecycle watcher");
anyhow::ensure!(
- watcher_generation == runtime_generation,
- "ready request and lifecycle watcher must retain the same transport generation"
+ watcher_owner == document_owner,
+ "ready request and lifecycle watcher must retain the same exact document owner"
);
Ok(PreparedServiceWorkerLifecycleTarget {
registration,
- runtime_generation,
+ document_owner,
storage_key,
})
}
@@ -91,7 +91,7 @@ fn send_updatefound(page_vm: &PageVm, target: &PreparedServiceWorkerLifecycleTar
page_vm
.service_worker_task_sender_for_root_for_test(root_document)
.send_service_worker_lifecycle(ServiceWorkerLifecycleNotification {
- runtime_generation: target.runtime_generation,
+ document_owner: target.document_owner,
storage_key: target.storage_key.clone(),
registration: target.registration.clone(),
events: vec![ServiceWorkerLifecycleClientEvent::UpdateFound],
@@ -118,7 +118,7 @@ navigator.serviceWorker.ready.then(registration => {
"observer-ready"
"#,
)?;
- let (request_id, runtime_generation) = page_vm
+ let (request_id, document_owner) = page_vm
.vm()
.service_worker_ready_request_for_test(crate::native_bridge::OwnerDispatchScope::Top)
.expect("top-level ServiceWorker ready request");
@@ -133,7 +133,7 @@ navigator.serviceWorker.ready.then(registration => {
.service_worker_task_sender_for_root_for_test(current_root)
.send_service_worker_ready(ServiceWorkerReadyCompletion {
request_id,
- runtime_generation,
+ document_owner,
registration,
})
.expect("ready completion should enter the stable internal source");
@@ -462,7 +462,9 @@ fn service_worker_internal_task_rejects_a_real_root_document_replacement() {
.service_worker_task_sender_for_root_for_test(retired_root)
.send_service_worker_unregister(ServiceWorkerUnregisterCompletion {
request_id: u64::MAX - 11,
- runtime_generation: u64::MAX - 7,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(
+ u64::MAX - 7,
+ ),
result: false,
})
.expect("retired-root internal task should remain resident");
diff --git a/moli-renderer-v8/src/runtime/phase_one/mod.rs b/moli-renderer-v8/src/runtime/phase_one/mod.rs
index 5a8530de7..7dba8a46c 100644
--- a/moli-renderer-v8/src/runtime/phase_one/mod.rs
+++ b/moli-renderer-v8/src/runtime/phase_one/mod.rs
@@ -5345,8 +5345,7 @@ globalThis.__outerDocumentWriteScriptContinued = true;
moli_storage_key::MoliStorageKey::first_party_from_url(&final_url, None)
.serialized_storage_key(),
crate::service_worker_runtime::ServiceWorkerClientFrameType::TopLevel,
- None,
- 1,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(1)),
completion_queue.sender(),
);
let (wake_tx, mut wake_rx) = tokio::sync::mpsc::unbounded_channel();
diff --git a/moli-renderer-v8/src/runtime/phase_one/streaming.rs b/moli-renderer-v8/src/runtime/phase_one/streaming.rs
index c11c8336f..1acb3930e 100644
--- a/moli-renderer-v8/src/runtime/phase_one/streaming.rs
+++ b/moli-renderer-v8/src/runtime/phase_one/streaming.rs
@@ -1312,8 +1312,7 @@ mod tests {
moli_storage_key::MoliStorageKey::first_party_from_url(&document_url, None)
.serialized_storage_key(),
crate::service_worker_runtime::ServiceWorkerClientFrameType::TopLevel,
- None,
- 1,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(1)),
completion_queue.sender(),
);
let (wake_tx, mut wake_rx) = tokio::sync::mpsc::unbounded_channel();
diff --git a/moli-renderer-v8/src/script_vm/service_worker_internal_promise_body.rs b/moli-renderer-v8/src/script_vm/service_worker_internal_promise_body.rs
index 479284af5..fc4dac389 100644
--- a/moli-renderer-v8/src/script_vm/service_worker_internal_promise_body.rs
+++ b/moli-renderer-v8/src/script_vm/service_worker_internal_promise_body.rs
@@ -29,13 +29,13 @@ impl ScriptVm {
._context_host
.borrow()
.service_worker_window_owner_is_current(owner);
- if owner.transport_generation() != completion.runtime_generation || !owner_is_current {
+ if owner.window_document_owner() != completion.document_owner || !owner_is_current {
tracing::debug!(
dispatch_scope = ?owner.dispatch_scope(),
document_owner = ?owner.document_owner(),
owner_is_current,
- pending_generation = owner.transport_generation(),
- completion_generation = completion.runtime_generation,
+ pending_document_owner = ?owner.window_document_owner(),
+ completion_document_owner = ?completion.document_owner,
request_id = completion.request_id,
"dropped stale service worker register completion"
);
@@ -74,13 +74,13 @@ impl ScriptVm {
._context_host
.borrow()
.service_worker_window_owner_is_current(owner);
- if owner.transport_generation() != completion.runtime_generation || !owner_is_current {
+ if owner.window_document_owner() != completion.document_owner || !owner_is_current {
tracing::debug!(
dispatch_scope = ?owner.dispatch_scope(),
document_owner = ?owner.document_owner(),
owner_is_current,
- pending_generation = owner.transport_generation(),
- completion_generation = completion.runtime_generation,
+ pending_document_owner = ?owner.window_document_owner(),
+ completion_document_owner = ?completion.document_owner,
request_id = completion.request_id,
"dropped stale service worker ready completion"
);
@@ -120,13 +120,13 @@ impl ScriptVm {
._context_host
.borrow()
.service_worker_window_owner_is_current(owner);
- if owner.transport_generation() != completion.runtime_generation || !owner_is_current {
+ if owner.window_document_owner() != completion.document_owner || !owner_is_current {
tracing::debug!(
dispatch_scope = ?owner.dispatch_scope(),
document_owner = ?owner.document_owner(),
owner_is_current,
- pending_generation = owner.transport_generation(),
- completion_generation = completion.runtime_generation,
+ pending_document_owner = ?owner.window_document_owner(),
+ completion_document_owner = ?completion.document_owner,
request_id = completion.request_id,
"dropped stale service worker unregister completion"
);
diff --git a/moli-renderer-v8/src/script_vm/service_worker_internal_test_support.rs b/moli-renderer-v8/src/script_vm/service_worker_internal_test_support.rs
index b1e0c8e7f..d74dc770e 100644
--- a/moli-renderer-v8/src/script_vm/service_worker_internal_test_support.rs
+++ b/moli-renderer-v8/src/script_vm/service_worker_internal_test_support.rs
@@ -12,20 +12,20 @@ impl ScriptVm {
pub(crate) fn service_worker_ready_request_for_test(
&self,
dispatch_scope: crate::native_bridge::OwnerDispatchScope,
- ) -> Option<(u64, u64)> {
+ ) -> Option<(u64, crate::native_bridge::WindowDocumentOwner)> {
self._context_host
.borrow()
.pending_service_worker_ready_owners_for_test()
.into_iter()
.find(|(_, owner)| owner.dispatch_scope() == dispatch_scope)
- .map(|(request_id, owner)| (request_id, owner.transport_generation()))
+ .map(|(request_id, owner)| (request_id, owner.window_document_owner()))
}
pub(crate) fn service_worker_lifecycle_watcher_for_test(
&self,
dispatch_scope: crate::native_bridge::OwnerDispatchScope,
scope_url: &url::Url,
- ) -> Option<(u64, String)> {
+ ) -> Option<(crate::native_bridge::WindowDocumentOwner, String)> {
self._context_host
.borrow()
.service_worker_registration_watchers_for_test()
@@ -33,7 +33,7 @@ impl ScriptVm {
.find(|(owner, watcher_scope, _)| {
owner.dispatch_scope() == dispatch_scope && watcher_scope == scope_url
})
- .map(|(owner, _, storage_key)| (owner.transport_generation(), storage_key))
+ .map(|(owner, _, storage_key)| (owner.window_document_owner(), storage_key))
}
pub(crate) fn service_worker_internal_window_client_target_for_test(
diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs
index 943c60814..971788650 100644
--- a/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs
+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs
@@ -33,13 +33,11 @@ use super::service_worker_drain::{
fn service_worker_window_client_target_for_test(
client_id: crate::runtime::ServiceWorkerClientId,
- document_epoch: Option<u64>,
- transport_generation: u64,
+ document_owner: crate::native_bridge::WindowDocumentOwner,
) -> crate::types::ServiceWorkerWindowClientTarget {
crate::types::ServiceWorkerWindowClientTarget {
client_id,
- document_epoch,
- transport_generation,
+ document_owner,
}
}
@@ -20189,8 +20187,7 @@ async fn service_worker_window_client_owner_requests_reject_on_stale_page_genera
crate::types::ServiceWorkerClientNavigateRequestCompletion {
target: service_worker_window_client_target_for_test(
crate::runtime::ServiceWorkerClientId::from_u64_for_test(1),
- Some(0),
- stale_generation,
+ crate::native_bridge::WindowDocumentOwner::for_test(stale_generation),
),
request_id: 101,
source_version_id: crate::runtime::ServiceWorkerVersionId::from_u64_for_test(1),
@@ -20208,8 +20205,7 @@ async fn service_worker_window_client_owner_requests_reject_on_stale_page_genera
crate::types::ServiceWorkerClientFocusRequestCompletion {
target: service_worker_window_client_target_for_test(
crate::runtime::ServiceWorkerClientId::from_u64_for_test(1),
- Some(0),
- stale_generation,
+ crate::native_bridge::WindowDocumentOwner::for_test(stale_generation),
),
request_id: 102,
source_version_id: crate::runtime::ServiceWorkerVersionId::from_u64_for_test(1),
@@ -20226,8 +20222,7 @@ async fn service_worker_window_client_owner_requests_reject_on_stale_page_genera
crate::types::ServiceWorkerClientsOpenWindowRequestCompletion {
host: service_worker_window_client_target_for_test(
crate::runtime::ServiceWorkerClientId::from_u64_for_test(1),
- Some(0),
- stale_generation,
+ crate::native_bridge::WindowDocumentOwner::for_test(stale_generation),
),
request_id: 103,
source_version_id: crate::runtime::ServiceWorkerVersionId::from_u64_for_test(1),
@@ -20300,17 +20295,17 @@ async fn service_worker_client_focus_request_marks_current_page_focused() {
)
.await;
- let runtime_generation = vm.document_runtime.runtime_reset_generation();
+ let current_target = vm
+ .service_worker_internal_window_client_target_for_test(
+ crate::native_bridge::OwnerDispatchScope::Top,
+ )
+ .expect("current top-level ServiceWorker client target");
run_service_worker_client_focus_request_task_for_test(
&mut vm,
&loader,
"current Page focus request",
crate::types::ServiceWorkerClientFocusRequestCompletion {
- target: service_worker_window_client_target_for_test(
- crate::runtime::ServiceWorkerClientId::from_u64_for_test(1),
- Some(0),
- runtime_generation,
- ),
+ target: current_target,
request_id: 77,
source_version_id: crate::runtime::ServiceWorkerVersionId::from_u64_for_test(1),
source_run: crate::runtime::RendererServiceWorkerRunIdentity::fresh(),
@@ -20400,17 +20395,17 @@ async fn service_worker_clients_open_window_request_records_popup_activation() {
)
.await;
- let runtime_generation = vm.document_runtime.runtime_reset_generation();
+ let current_target = vm
+ .service_worker_internal_window_client_target_for_test(
+ crate::native_bridge::OwnerDispatchScope::Top,
+ )
+ .expect("current top-level ServiceWorker client target");
run_service_worker_clients_open_window_request_task_for_test(
&mut vm,
&loader,
"current Page openWindow request",
crate::types::ServiceWorkerClientsOpenWindowRequestCompletion {
- host: service_worker_window_client_target_for_test(
- crate::runtime::ServiceWorkerClientId::from_u64_for_test(1),
- Some(0),
- runtime_generation,
- ),
+ host: current_target,
request_id: 88,
source_version_id: crate::runtime::ServiceWorkerVersionId::from_u64_for_test(1),
source_run: crate::runtime::RendererServiceWorkerRunIdentity::fresh(),
@@ -20460,13 +20455,11 @@ async fn service_worker_clients_open_window_request_records_popup_activation() {
assert!(opened.controlled);
let opened_client_id = opened.id;
let opened_exposed_client_id = opened.exposed_id.clone();
- let popup_document_epoch = vm
+ let popup_document_owner = vm
._context_host
.borrow()
.current_lightweight_popup_document_owner(popup_id)
- .expect("openWindow popup document owner")
- .document_id()
- .as_u64();
+ .expect("openWindow popup document owner");
run_service_worker_client_focus_request_task_for_test(
&mut vm,
@@ -20475,8 +20468,7 @@ async fn service_worker_clients_open_window_request_records_popup_activation() {
crate::types::ServiceWorkerClientFocusRequestCompletion {
target: service_worker_window_client_target_for_test(
opened_client_id,
- Some(popup_document_epoch),
- runtime_generation,
+ crate::native_bridge::WindowDocumentOwner::LightweightPopup(popup_document_owner),
),
request_id: 90,
source_version_id: crate::runtime::ServiceWorkerVersionId::from_u64_for_test(1),
@@ -20726,7 +20718,6 @@ async fn service_worker_popup_client_survives_javascript_reopen() {
.current_lightweight_popup_local_window_id(popup_id)
.expect("replacement service worker popup LocalWindow owner");
assert_ne!(replacement_local_window_id, initial_local_window_id);
- let runtime_generation = vm.document_runtime.runtime_reset_generation();
run_service_worker_client_focus_request_task_for_test(
&mut vm,
&loader,
@@ -20734,8 +20725,7 @@ async fn service_worker_popup_client_survives_javascript_reopen() {
crate::types::ServiceWorkerClientFocusRequestCompletion {
target: service_worker_window_client_target_for_test(
popup_client_id,
- Some(initial_document_owner.document_id().as_u64()),
- runtime_generation,
+ crate::native_bridge::WindowDocumentOwner::LightweightPopup(initial_document_owner),
),
request_id: 98,
source_version_id: crate::runtime::ServiceWorkerVersionId::from_u64_for_test(1),
@@ -20766,8 +20756,9 @@ async fn service_worker_popup_client_survives_javascript_reopen() {
crate::types::ServiceWorkerClientFocusRequestCompletion {
target: service_worker_window_client_target_for_test(
popup_client_id,
- Some(replacement_document_owner.document_id().as_u64()),
- runtime_generation,
+ crate::native_bridge::WindowDocumentOwner::LightweightPopup(
+ replacement_document_owner,
+ ),
),
request_id: 100,
source_version_id: crate::runtime::ServiceWorkerVersionId::from_u64_for_test(1),
@@ -20843,17 +20834,17 @@ async fn service_worker_clients_open_window_about_blank_request_creates_no_popup
)
.await;
- let runtime_generation = vm.document_runtime.runtime_reset_generation();
+ let current_target = vm
+ .service_worker_internal_window_client_target_for_test(
+ crate::native_bridge::OwnerDispatchScope::Top,
+ )
+ .expect("current top-level ServiceWorker client target");
run_service_worker_clients_open_window_request_task_for_test(
&mut vm,
&loader,
"about:blank openWindow request",
crate::types::ServiceWorkerClientsOpenWindowRequestCompletion {
- host: service_worker_window_client_target_for_test(
- crate::runtime::ServiceWorkerClientId::from_u64_for_test(1),
- Some(0),
- runtime_generation,
- ),
+ host: current_target,
request_id: 92,
source_version_id: crate::runtime::ServiceWorkerVersionId::from_u64_for_test(1),
source_run: crate::runtime::RendererServiceWorkerRunIdentity::fresh(),
@@ -20928,17 +20919,17 @@ async fn service_worker_clients_open_window_cross_origin_result_stays_null() {
)
.await;
- let runtime_generation = vm.document_runtime.runtime_reset_generation();
+ let current_target = vm
+ .service_worker_internal_window_client_target_for_test(
+ crate::native_bridge::OwnerDispatchScope::Top,
+ )
+ .expect("current top-level ServiceWorker client target");
run_service_worker_clients_open_window_request_task_for_test(
&mut vm,
&loader,
"cross-origin openWindow request",
crate::types::ServiceWorkerClientsOpenWindowRequestCompletion {
- host: service_worker_window_client_target_for_test(
- crate::runtime::ServiceWorkerClientId::from_u64_for_test(1),
- Some(0),
- runtime_generation,
- ),
+ host: current_target,
request_id: 94,
source_version_id: crate::runtime::ServiceWorkerVersionId::from_u64_for_test(1),
source_run: crate::runtime::RendererServiceWorkerRunIdentity::fresh(),
diff --git a/moli-renderer-v8/src/script_vm/tests/mod.rs b/moli-renderer-v8/src/script_vm/tests/mod.rs
index 290e694a4..ec3bb645e 100644
--- a/moli-renderer-v8/src/script_vm/tests/mod.rs
+++ b/moli-renderer-v8/src/script_vm/tests/mod.rs
@@ -3973,7 +3973,7 @@ async fn service_worker_window_requests_bind_and_retire_exact_document_owners()
vm.current_service_worker_task_sender_for_test()
.send_service_worker_ready(crate::types::ServiceWorkerReadyCompletion {
request_id: child_ready_request_id,
- runtime_generation: child_ready_owner.transport_generation(),
+ document_owner: child_ready_owner.window_document_owner(),
registration:
crate::service_worker_runtime::ServiceWorkerRegistrationSnapshot::active_for_binding_test(
ready_scope.clone(),
@@ -4036,7 +4036,7 @@ async fn service_worker_window_requests_bind_and_retire_exact_document_owners()
vm.current_service_worker_task_sender_for_test()
.send_service_worker_register(crate::types::ServiceWorkerRegisterCompletion {
request_id,
- runtime_generation: register_owner.transport_generation(),
+ document_owner: register_owner.window_document_owner(),
result: Err(
crate::service_worker_runtime::ServiceWorkerRegistrationError::type_error(
"forced owner completion",
@@ -4101,7 +4101,7 @@ async fn service_worker_window_requests_bind_and_retire_exact_document_owners()
vm.current_service_worker_task_sender_for_test()
.send_service_worker_register(crate::types::ServiceWorkerRegisterCompletion {
request_id: binding_request_id,
- runtime_generation: binding_owner.transport_generation(),
+ document_owner: binding_owner.window_document_owner(),
result: Ok(registration_snapshot.clone()),
})
.expect("owner-bound child registration should enter the typed Page source");
@@ -4141,7 +4141,7 @@ async fn service_worker_window_requests_bind_and_retire_exact_document_owners()
.expect("child lifecycle listener should install");
vm.current_service_worker_task_sender_for_test()
.send_service_worker_lifecycle(crate::types::ServiceWorkerLifecycleNotification {
- runtime_generation: binding_owner.transport_generation(),
+ document_owner: binding_owner.window_document_owner(),
storage_key: "wrong-partition".to_owned(),
registration: registration_snapshot.clone(),
events: vec![crate::types::ServiceWorkerLifecycleClientEvent::UpdateFound],
@@ -4163,7 +4163,7 @@ async fn service_worker_window_requests_bind_and_retire_exact_document_owners()
);
vm.current_service_worker_task_sender_for_test()
.send_service_worker_lifecycle(crate::types::ServiceWorkerLifecycleNotification {
- runtime_generation: binding_owner.transport_generation(),
+ document_owner: binding_owner.window_document_owner(),
storage_key: lifecycle_storage_key,
registration: registration_snapshot,
events: vec![crate::types::ServiceWorkerLifecycleClientEvent::UpdateFound],
@@ -4330,7 +4330,7 @@ async fn main_document_replacement_rebinds_service_worker_lifecycle_watcher() {
vm.current_service_worker_task_sender_for_test()
.send_service_worker_register(crate::types::ServiceWorkerRegisterCompletion {
request_id,
- runtime_generation: register_owner.transport_generation(),
+ document_owner: register_owner.window_document_owner(),
result: Ok(registration_snapshot.clone()),
})
.expect("main service worker registration should enter the typed Page source");
@@ -4369,7 +4369,7 @@ async fn main_document_replacement_rebinds_service_worker_lifecycle_watcher() {
vm.current_service_worker_task_sender_for_test()
.send_service_worker_lifecycle(crate::types::ServiceWorkerLifecycleNotification {
- runtime_generation: register_owner.transport_generation(),
+ document_owner: register_owner.window_document_owner(),
storage_key: storage_key.clone(),
registration: registration_snapshot.clone(),
events: vec![crate::types::ServiceWorkerLifecycleClientEvent::UpdateFound],
@@ -4390,7 +4390,7 @@ async fn main_document_replacement_rebinds_service_worker_lifecycle_watcher() {
vm.current_service_worker_task_sender_for_test()
.send_service_worker_lifecycle(crate::types::ServiceWorkerLifecycleNotification {
- runtime_generation: rebound_owner.transport_generation(),
+ document_owner: rebound_owner.window_document_owner(),
storage_key,
registration: registration_snapshot,
events: vec![crate::types::ServiceWorkerLifecycleClientEvent::UpdateFound],
@@ -4460,8 +4460,7 @@ async fn service_worker_controller_change_targets_exact_child_document() {
};
let child_target = crate::types::ServiceWorkerWindowClientTarget {
client_id: child_client_id,
- document_epoch: Some(child_owner.document_id.0),
- transport_generation: vm.document_runtime.runtime_reset_generation(),
+ document_owner: crate::native_bridge::WindowDocumentOwner::Frame(child_owner),
};
vm.eval(
r#"
@@ -4574,8 +4573,7 @@ async fn service_worker_controller_change_targets_exact_child_document() {
let replacement_target = crate::types::ServiceWorkerWindowClientTarget {
client_id: replacement_client_id,
- document_epoch: Some(replacement_owner.document_id.0),
- transport_generation: vm.document_runtime.runtime_reset_generation(),
+ document_owner: crate::native_bridge::WindowDocumentOwner::Frame(replacement_owner),
};
vm.current_service_worker_task_sender_for_test()
.send_service_worker_controller_change(
diff --git a/moli-renderer-v8/src/service_worker_runtime/jobs.rs b/moli-renderer-v8/src/service_worker_runtime/jobs.rs
index c3a096732..87bd355d6 100644
--- a/moli-renderer-v8/src/service_worker_runtime/jobs.rs
+++ b/moli-renderer-v8/src/service_worker_runtime/jobs.rs
@@ -44,7 +44,7 @@ pub(crate) struct ServiceWorkerLaunchParams {
#[derive(Clone, Debug)]
pub(super) struct ServiceWorkerRegisterJob {
pub(super) request_id: u64,
- pub(super) runtime_generation: u64,
+ pub(super) document_owner: crate::window_document_identity::WindowDocumentOwner,
pub(super) completion_tx: RendererPageServiceWorkerTaskSender,
}
@@ -60,7 +60,7 @@ impl ServiceWorkerRegisterJob {
.completion_tx
.send_service_worker_register(ServiceWorkerRegisterCompletion {
request_id: self.request_id,
- runtime_generation: self.runtime_generation,
+ document_owner: self.document_owner,
result,
});
}
@@ -255,7 +255,7 @@ mod tests {
let queue = crate::page_task_queue::RendererPageServiceWorkerTestHarness::new();
let mut job = ServiceWorkerPendingRegisterJob::new(vec![ServiceWorkerRegisterJob {
request_id: 1,
- runtime_generation: 1,
+ document_owner: crate::window_document_identity::WindowDocumentOwner::for_test(1),
completion_tx: queue.sender(),
}]);
@@ -289,7 +289,7 @@ mod tests {
#[derive(Clone, Debug)]
pub(super) struct ServiceWorkerUnregisterJob {
pub(super) request_id: u64,
- pub(super) runtime_generation: u64,
+ pub(super) document_owner: crate::window_document_identity::WindowDocumentOwner,
pub(super) completion_tx: RendererPageServiceWorkerTaskSender,
}
@@ -299,7 +299,7 @@ impl ServiceWorkerUnregisterJob {
self.completion_tx
.send_service_worker_unregister(ServiceWorkerUnregisterCompletion {
request_id: self.request_id,
- runtime_generation: self.runtime_generation,
+ document_owner: self.document_owner,
result,
});
}
diff --git a/moli-renderer-v8/src/service_worker_runtime/service.rs b/moli-renderer-v8/src/service_worker_runtime/service.rs
index 526ccb5ff..8a32a3707 100644
--- a/moli-renderer-v8/src/service_worker_runtime/service.rs
+++ b/moli-renderer-v8/src/service_worker_runtime/service.rs
@@ -789,8 +789,9 @@ mod tests {
secure_context: true,
execution_ready: true,
discarded_or_frozen: false,
- document_epoch: Some(0),
- runtime_generation: 0,
+ document_owner: Some(crate::native_bridge::WindowDocumentOwner::for_test(
+ 0,
+ )),
endpoint: ServiceWorkerClientEndpoint::Page(test_completion_sender()),
focused: false,
},
@@ -1073,8 +1074,7 @@ mod tests {
document_url,
storage_key,
frame_type,
- Some(0),
- 0,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(0)),
test_completion_sender(),
)
}
@@ -1090,8 +1090,7 @@ mod tests {
document_url,
storage_key,
frame_type,
- Some(0),
- 0,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(0)),
)
}
@@ -1142,8 +1141,7 @@ mod tests {
secure_context: true,
execution_ready: true,
discarded_or_frozen: false,
- document_epoch: Some(0),
- runtime_generation: 0,
+ document_owner: Some(crate::native_bridge::WindowDocumentOwner::for_test(0)),
endpoint: ServiceWorkerClientEndpoint::Page(test_completion_sender()),
focused: false,
},
@@ -1189,13 +1187,13 @@ mod tests {
ServiceWorkerLifecycleWatcher {
scope_url: scope_url.clone(),
storage_key: registration_storage_key.clone(),
- runtime_generation: 7,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(7),
completion_tx: test_completion_sender(),
},
ServiceWorkerLifecycleWatcher {
scope_url: scope_url.clone(),
storage_key: "different-partition".to_owned(),
- runtime_generation: 8,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(8),
completion_tx: test_completion_sender(),
},
]);
@@ -1207,7 +1205,10 @@ mod tests {
};
assert_eq!(deliveries.len(), 1);
- assert_eq!(deliveries[0].watcher.runtime_generation, 7);
+ assert_eq!(
+ deliveries[0].watcher.document_owner,
+ crate::native_bridge::WindowDocumentOwner::for_test(7)
+ );
assert_ne!(deliveries[0].watcher.storage_key, "different-partition");
}
@@ -1351,7 +1352,7 @@ mod tests {
storage_bucket_store: None,
callbacks: vec![ServiceWorkerRegisterJob {
request_id: 1,
- runtime_generation: 1,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(1),
completion_tx: test_completion_sender(),
}],
}
@@ -1387,7 +1388,7 @@ mod tests {
storage_bucket_store: None,
callbacks: vec![ServiceWorkerRegisterJob {
request_id,
- runtime_generation: 1,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(1),
completion_tx,
}],
};
@@ -1564,7 +1565,7 @@ mod tests {
let mut pending_register_job =
ServiceWorkerPendingRegisterJob::new(vec![ServiceWorkerRegisterJob {
request_id,
- runtime_generation: 1,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(1),
completion_tx,
}]);
pending_register_job.start_current_moli_job();
@@ -1635,7 +1636,7 @@ mod tests {
storage_bucket_store: None,
callbacks: vec![ServiceWorkerRegisterJob {
request_id,
- runtime_generation: 1,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(1),
completion_tx,
}],
},
@@ -2540,8 +2541,7 @@ mod tests {
committed_creation_url.clone(),
ServiceWorkerRegistrationKey::first_party_storage_key_for_url(&committed_creation_url,),
ServiceWorkerClientFrameType::TopLevel,
- Some(3),
- 3,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(3)),
));
let visible = service.query_clients(&ServiceWorkerClientQuery {
@@ -2616,8 +2616,7 @@ mod tests {
reserved_creation_url.clone(),
ServiceWorkerRegistrationKey::first_party_storage_key_for_url(&reserved_creation_url),
ServiceWorkerClientFrameType::TopLevel,
- Some(4),
- 4,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(4)),
));
let visible = service.query_clients(&ServiceWorkerClientQuery {
@@ -2663,7 +2662,6 @@ mod tests {
storage_key.clone(),
ServiceWorkerClientFrameType::TopLevel,
None,
- 0,
);
assert!(service.matching_controller_for_client(client_id).is_none());
@@ -2673,8 +2671,7 @@ mod tests {
document_url,
storage_key,
ServiceWorkerClientFrameType::TopLevel,
- Some(1),
- 1,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(1)),
test_completion_sender(),
)
);
@@ -2685,7 +2682,7 @@ mod tests {
}
#[test]
- fn window_client_completion_target_rotates_when_document_epoch_changes() {
+ fn window_client_completion_target_rotates_with_exact_document_owner() {
let service = new_service_worker_runtime_service();
let document_url = url("https://client-epoch.test/page.html");
let storage_key =
@@ -2694,8 +2691,7 @@ mod tests {
document_url.clone(),
storage_key.clone(),
ServiceWorkerClientFrameType::TopLevel,
- Some(10),
- 7,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(10)),
test_completion_sender(),
);
let initial_target = service
@@ -2712,8 +2708,7 @@ mod tests {
document_url,
storage_key,
ServiceWorkerClientFrameType::TopLevel,
- Some(11),
- 7,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(11)),
));
let replacement_target = service
.inner
@@ -2725,10 +2720,14 @@ mod tests {
.expect("replacement window client target");
assert_eq!(initial_target.client_id, replacement_target.client_id);
- assert_eq!(initial_target.transport_generation, 7);
- assert_eq!(replacement_target.transport_generation, 7);
- assert_eq!(initial_target.document_epoch, Some(10));
- assert_eq!(replacement_target.document_epoch, Some(11));
+ assert_eq!(
+ initial_target.document_owner,
+ crate::native_bridge::WindowDocumentOwner::for_test(10)
+ );
+ assert_eq!(
+ replacement_target.document_owner,
+ crate::native_bridge::WindowDocumentOwner::for_test(11)
+ );
assert_ne!(initial_target, replacement_target);
}
@@ -2745,16 +2744,14 @@ mod tests {
app_page.clone(),
ServiceWorkerRegistrationKey::first_party_storage_key_for_url(&app_page),
ServiceWorkerClientFrameType::TopLevel,
- Some(7),
- 7,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(7)),
app_queue.sender(),
);
service.register_client_with_storage_key(
outside_page.clone(),
ServiceWorkerRegistrationKey::first_party_storage_key_for_url(&outside_page),
ServiceWorkerClientFrameType::TopLevel,
- Some(11),
- 11,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(11)),
outside_queue.sender(),
);
insert_registered_version(
@@ -2775,8 +2772,10 @@ mod tests {
other => panic!("expected controllerchange completion, got {other:?}"),
};
assert_eq!(completion.target.client_id, app_client_id);
- assert_eq!(completion.target.document_epoch, Some(7));
- assert_eq!(completion.target.transport_generation, 7);
+ assert_eq!(
+ completion.target.document_owner,
+ crate::native_bridge::WindowDocumentOwner::for_test(7)
+ );
assert!(!app_queue.has_ready_task());
assert!(!outside_queue.has_ready_task());
@@ -3409,8 +3408,7 @@ mod tests {
&same_origin_creation_url,
),
ServiceWorkerClientFrameType::TopLevel,
- Some(2),
- 2,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(2)),
));
let same_origin_result = service.query_clients(&ServiceWorkerClientQuery {
request_id: 31,
@@ -3442,8 +3440,7 @@ mod tests {
&cross_origin_creation_url,
),
ServiceWorkerClientFrameType::TopLevel,
- Some(3),
- 3,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(3)),
));
let hidden_old_exposed_id = service.query_clients(&ServiceWorkerClientQuery {
request_id: 32,
@@ -3753,24 +3750,21 @@ mod tests {
not_ready_url.clone(),
ServiceWorkerRegistrationKey::first_party_storage_key_for_url(&not_ready_url),
ServiceWorkerClientFrameType::TopLevel,
- Some(21),
- 21,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(21)),
not_ready_queue.sender(),
);
let discarded_client_id = service.register_client_with_storage_key(
discarded_url.clone(),
ServiceWorkerRegistrationKey::first_party_storage_key_for_url(&discarded_url),
ServiceWorkerClientFrameType::TopLevel,
- Some(22),
- 22,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(22)),
discarded_queue.sender(),
);
let ready_client_id = service.register_client_with_storage_key(
ready_url.clone(),
ServiceWorkerRegistrationKey::first_party_storage_key_for_url(&ready_url),
ServiceWorkerClientFrameType::TopLevel,
- Some(23),
- 23,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(23)),
ready_queue.sender(),
);
{
@@ -3818,8 +3812,10 @@ mod tests {
};
assert_eq!(completion.request_id, 51);
assert_eq!(completion.host.client_id, ready_client_id);
- assert_eq!(completion.host.document_epoch, Some(23));
- assert_eq!(completion.host.transport_generation, 23);
+ assert_eq!(
+ completion.host.document_owner,
+ crate::native_bridge::WindowDocumentOwner::for_test(23)
+ );
assert_eq!(completion.source_version_id, version_id);
assert_eq!(completion.source_run, run);
assert_eq!(completion.url, url("https://example.test/app/opened.html"));
@@ -3899,8 +3895,7 @@ mod tests {
secure_context: true,
execution_ready: true,
discarded_or_frozen: false,
- document_epoch: Some(0),
- runtime_generation: 0,
+ document_owner: Some(crate::native_bridge::WindowDocumentOwner::for_test(0)),
endpoint: ServiceWorkerClientEndpoint::Page(test_completion_sender()),
focused: false,
},
@@ -4254,7 +4249,7 @@ mod tests {
for registration_id in [deleted_registration_id, kept_registration_id] {
state.pending_ready_jobs.push(ServiceWorkerReadyJob {
request_id: registration_id.as_u64(),
- runtime_generation: 1,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(1),
completion_tx: test_completion_sender(),
registration_id,
});
@@ -5045,11 +5040,17 @@ self.addEventListener("message", event => {
assert!(register_completion.result.is_ok());
let first_completion = pop_unregister_completion(&mut first_unregister_queue);
assert_eq!(first_completion.request_id, 21);
- assert_eq!(first_completion.runtime_generation, 1);
+ assert_eq!(
+ first_completion.document_owner,
+ crate::native_bridge::WindowDocumentOwner::for_test(1)
+ );
assert!(first_completion.result);
let second_completion = pop_unregister_completion(&mut second_unregister_queue);
assert_eq!(second_completion.request_id, 22);
- assert_eq!(second_completion.runtime_generation, 2);
+ assert_eq!(
+ second_completion.document_owner,
+ crate::native_bridge::WindowDocumentOwner::for_test(2)
+ );
assert!(second_completion.result);
let diagnostics = service.diagnostics_snapshot();
@@ -5101,7 +5102,7 @@ self.addEventListener("message", event => {
let mut state = service.inner.state.lock();
state.pending_ready_jobs.push(ServiceWorkerReadyJob {
request_id: 33,
- runtime_generation: 1,
+ document_owner: crate::native_bridge::WindowDocumentOwner::for_test(1),
completion_tx: test_completion_sender(),
registration_id,
});
@@ -7441,8 +7442,7 @@ self.addEventListener("message", event => {
document_url,
second_storage_key,
ServiceWorkerClientFrameType::TopLevel,
- Some(1),
- 1,
+ Some(crate::native_bridge::WindowDocumentOwner::for_test(1)),
test_completion_sender(),
);
let control = service
@@ -10962,8 +10962,7 @@ self.addEventListener("message", event => {
secure_context: true,
execution_ready: true,
discarded_or_frozen: false,
- document_epoch: Some(0),
- runtime_generation: 0,
+ document_owner: Some(crate::native_bridge::WindowDocumentOwner::for_test(0)),
endpoint: ServiceWorkerClientEndpoint::Page(test_completion_sender()),
focused: false,
},
@@ -11146,8 +11145,7 @@ self.addEventListener("message", event => {
secure_context: true,
execution_ready: true,
discarded_or_frozen: false,
- document_epoch: Some(0),
- runtime_generation: 0,
+ document_owner: Some(crate::native_bridge::WindowDocumentOwner::for_test(0)),
endpoint: ServiceWorkerClientEndpoint::Page(test_completion_sender()),
focused: false,
},
@@ -11763,8 +11761,7 @@ self.addEventListener("message", event => {
secure_context: true,
execution_ready: true,
discarded_or_frozen: false,
- document_epoch: Some(0),
- runtime_generation: 0,
+ document_owner: Some(crate::native_bridge::WindowDocumentOwner::for_test(0)),
endpoint: ServiceWorkerClientEndpoint::Page(client_queue.sender()),
focused: false,
},
@@ -11925,8 +11922,7 @@ self.addEventListener("message", event => {
secure_context: true,
execution_ready: true,
discarded_or_frozen: false,
- document_epoch: Some(0),
- runtime_generation: 0,
+ document_owner: Some(crate::native_bridge::WindowDocumentOwner::for_test(0)),
endpoint: ServiceWorkerClientEndpoint::Page(test_completion_sender()),
focused: false,
},
@@ -13642,8 +13638,7 @@ self.addEventListener("message", event => {
secure_context: true,
execution_ready: true,
discarded_or_frozen: false,
- document_epoch: Some(7),
- runtime_generation: 7,
+ document_owner: Some(crate::native_bridge::WindowDocumentOwner::for_test(7)),
endpoint: ServiceWorkerClientEndpoint::Page(completion_queue.sender()),
focused: false,
},
@@ -13678,8 +13673,10 @@ self.addEventListener("message", event => {
panic!("expected notification action navigate request");
};
assert_eq!(completion.host.client_id, client_id);
- assert_eq!(completion.host.document_epoch, Some(7));
- assert_eq!(completion.host.transport_generation, 7);
+ assert_eq!(
+ completion.host.document_owner,
+ crate::native_bridge::WindowDocumentOwner::for_test(7)
+ );
assert_eq!(completion.url, action_url);
let state = service.inner.state.lock();
let version = state.versions.get(&version_id).unwrap();
diff --git a/moli-renderer-v8/src/service_worker_runtime/service/client_registry.rs b/moli-renderer-v8/src/service_worker_runtime/service/client_registry.rs
index 19bbdcaf7..1240e7a09 100644
--- a/moli-renderer-v8/src/service_worker_runtime/service/client_registry.rs
+++ b/moli-renderer-v8/src/service_worker_runtime/service/client_registry.rs
@@ -5,7 +5,7 @@ impl ServiceWorkerRuntimeService {
pub(crate) fn register_client(
&self,
document_url: Url,
- runtime_generation: u64,
+ document_owner_identity: u64,
completion_tx: RendererPageServiceWorkerTaskSender,
) -> ServiceWorkerClientId {
let storage_key =
@@ -14,8 +14,11 @@ impl ServiceWorkerRuntimeService {
document_url,
storage_key,
ServiceWorkerClientFrameType::TopLevel,
- Some(runtime_generation),
- runtime_generation,
+ Some(
+ crate::window_document_identity::WindowDocumentOwner::for_test(
+ document_owner_identity,
+ ),
+ ),
completion_tx,
)
}
@@ -25,16 +28,14 @@ impl ServiceWorkerRuntimeService {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
completion_tx: RendererPageServiceWorkerTaskSender,
) -> ServiceWorkerClientId {
let client_id = self.register_window_client_with_storage_key(
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
ServiceWorkerClientEndpoint::Page(completion_tx),
);
self.mark_client_execution_ready(client_id);
@@ -46,15 +47,13 @@ impl ServiceWorkerRuntimeService {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
) -> ServiceWorkerClientId {
self.register_reserved_client_with_storage_key_and_bypass(
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
false,
)
}
@@ -64,15 +63,13 @@ impl ServiceWorkerRuntimeService {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
) -> ServiceWorkerClientId {
self.register_reserved_client_with_storage_key_and_bypass(
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
true,
)
}
@@ -82,16 +79,14 @@ impl ServiceWorkerRuntimeService {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
bypass_service_worker: bool,
) -> ServiceWorkerClientId {
self.register_window_client_with_storage_key(
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
ServiceWorkerClientEndpoint::ReservedPage {
bypass_service_worker,
},
@@ -135,8 +130,7 @@ impl ServiceWorkerRuntimeService {
secure_context,
execution_ready: true,
discarded_or_frozen: false,
- document_epoch: None,
- runtime_generation: 0,
+ document_owner: None,
endpoint: ServiceWorkerClientEndpoint::Worker(worker_tx),
focused: false,
},
@@ -191,8 +185,7 @@ impl ServiceWorkerRuntimeService {
secure_context,
execution_ready: false,
discarded_or_frozen: false,
- document_epoch: None,
- runtime_generation: 0,
+ document_owner: None,
endpoint: ServiceWorkerClientEndpoint::PendingWorker,
focused: false,
},
@@ -276,8 +269,7 @@ impl ServiceWorkerRuntimeService {
secure_context,
execution_ready: false,
discarded_or_frozen: false,
- document_epoch: None,
- runtime_generation: 0,
+ document_owner: None,
endpoint: ServiceWorkerClientEndpoint::PendingWorker,
focused: false,
},
@@ -318,8 +310,7 @@ impl ServiceWorkerRuntimeService {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
endpoint: ServiceWorkerClientEndpoint,
) -> ServiceWorkerClientId {
let client_id =
@@ -353,8 +344,7 @@ impl ServiceWorkerRuntimeService {
secure_context: true,
execution_ready: false,
discarded_or_frozen: false,
- document_epoch,
- runtime_generation,
+ document_owner,
endpoint,
focused: false,
},
@@ -425,16 +415,14 @@ impl ServiceWorkerRuntimeService {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
) -> bool {
self.update_client_document_with_storage_key_internal(
client_id,
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
None,
)
}
@@ -445,8 +433,7 @@ impl ServiceWorkerRuntimeService {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
completion_tx: RendererPageServiceWorkerTaskSender,
) -> bool {
self.update_client_document_with_storage_key_internal(
@@ -454,8 +441,7 @@ impl ServiceWorkerRuntimeService {
document_url,
storage_key,
frame_type,
- document_epoch,
- runtime_generation,
+ document_owner,
Some(completion_tx),
)
}
@@ -466,8 +452,7 @@ impl ServiceWorkerRuntimeService {
document_url: Url,
storage_key: String,
frame_type: ServiceWorkerClientFrameType,
- document_epoch: Option<u64>,
- runtime_generation: u64,
+ document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
completion_tx: Option<RendererPageServiceWorkerTaskSender>,
) -> bool {
let current_document_url = service_worker_current_url_for_creation_url(&document_url);
@@ -509,8 +494,7 @@ impl ServiceWorkerRuntimeService {
client.frame_type = frame_type;
client.storage_key = storage_key.clone();
client.execution_ready = true;
- client.document_epoch = document_epoch;
- client.runtime_generation = runtime_generation;
+ client.document_owner = document_owner;
if let Some(completion_tx) = completion_tx {
client.endpoint = ServiceWorkerClientEndpoint::Page(completion_tx);
}
diff --git a/moli-renderer-v8/src/service_worker_runtime/service/fetch_settlement.rs b/moli-renderer-v8/src/service_worker_runtime/service/fetch_settlement.rs
index b72dd922a..d139ca181 100644
--- a/moli-renderer-v8/src/service_worker_runtime/service/fetch_settlement.rs
+++ b/moli-renderer-v8/src/service_worker_runtime/service/fetch_settlement.rs
@@ -1108,8 +1108,7 @@ mod tests {
secure_context: true,
execution_ready: true,
discarded_or_frozen: false,
- document_epoch: Some(0),
- runtime_generation: 0,
+ document_owner: Some(crate::native_bridge::WindowDocumentOwner::for_test(0)),
endpoint: ServiceWorkerClientEndpoint::Page(
crate::page_task_queue::RendererPageServiceWorkerTestHarness::new().sender(),
),
diff --git a/moli-renderer-v8/src/service_worker_runtime/service/registration_jobs.rs b/moli-renderer-v8/src/service_worker_runtime/service/registration_jobs.rs
index 1a866c890..c1eb66b67 100644
--- a/moli-renderer-v8/src/service_worker_runtime/service/registration_jobs.rs
+++ b/moli-renderer-v8/src/service_worker_runtime/service/registration_jobs.rs
@@ -64,7 +64,7 @@ impl ServiceWorkerRuntimeService {
storage_bucket_store: Option<crate::context_bootstrap::SharedStorageBucketStore>,
update_via_cache: ServiceWorkerUpdateViaCache,
register_request_id: u64,
- register_runtime_generation: u64,
+ register_document_owner_identity: u64,
register_completion_tx: RendererPageServiceWorkerTaskSender,
) {
let storage_key =
@@ -83,7 +83,9 @@ impl ServiceWorkerRuntimeService {
storage_bucket_store,
update_via_cache,
register_request_id,
- register_runtime_generation,
+ crate::window_document_identity::WindowDocumentOwner::for_test(
+ register_document_owner_identity,
+ ),
register_completion_tx,
);
}
@@ -103,7 +105,7 @@ impl ServiceWorkerRuntimeService {
storage_bucket_store: Option<crate::context_bootstrap::SharedStorageBucketStore>,
update_via_cache: ServiceWorkerUpdateViaCache,
register_request_id: u64,
- register_runtime_generation: u64,
+ register_document_owner: crate::window_document_identity::WindowDocumentOwner,
register_completion_tx: RendererPageServiceWorkerTaskSender,
) {
let queued_job = ServiceWorkerQueuedRegisterJob {
@@ -125,7 +127,7 @@ impl ServiceWorkerRuntimeService {
storage_bucket_store,
callbacks: vec![ServiceWorkerRegisterJob {
request_id: register_request_id,
- runtime_generation: register_runtime_generation,
+ document_owner: register_document_owner,
completion_tx: register_completion_tx,
}],
};
@@ -326,14 +328,14 @@ impl ServiceWorkerRuntimeService {
&self,
scope_url: &Url,
request_id: u64,
- runtime_generation: u64,
+ document_owner_identity: u64,
completion_tx: RendererPageServiceWorkerTaskSender,
) -> ServiceWorkerUnregisterStart {
self.start_unregistration_with_storage_key(
scope_url,
ServiceWorkerRegistrationKey::storage_key_for_scope_url(scope_url),
request_id,
- runtime_generation,
+ crate::window_document_identity::WindowDocumentOwner::for_test(document_owner_identity),
completion_tx,
)
}
@@ -343,7 +345,7 @@ impl ServiceWorkerRuntimeService {
scope_url: &Url,
storage_key: String,
request_id: u64,
- runtime_generation: u64,
+ document_owner: crate::window_document_identity::WindowDocumentOwner,
completion_tx: RendererPageServiceWorkerTaskSender,
) -> ServiceWorkerUnregisterStart {
self.start_unregistration_job(
@@ -351,7 +353,7 @@ impl ServiceWorkerRuntimeService {
storage_key,
Some(ServiceWorkerUnregisterJob {
request_id,
- runtime_generation,
+ document_owner,
completion_tx,
}),
)
diff --git a/moli-renderer-v8/src/service_worker_runtime/service/registration_lookup.rs b/moli-renderer-v8/src/service_worker_runtime/service/registration_lookup.rs
index a5e4e7b47..d8030982d 100644
--- a/moli-renderer-v8/src/service_worker_runtime/service/registration_lookup.rs
+++ b/moli-renderer-v8/src/service_worker_runtime/service/registration_lookup.rs
@@ -6,7 +6,7 @@ impl ServiceWorkerRuntimeService {
&self,
document_url: Url,
request_id: u64,
- runtime_generation: u64,
+ document_owner_identity: u64,
completion_tx: RendererPageServiceWorkerTaskSender,
) -> bool {
let storage_key =
@@ -15,7 +15,7 @@ impl ServiceWorkerRuntimeService {
document_url,
storage_key,
request_id,
- runtime_generation,
+ crate::window_document_identity::WindowDocumentOwner::for_test(document_owner_identity),
completion_tx,
)
}
@@ -25,7 +25,7 @@ impl ServiceWorkerRuntimeService {
document_url: Url,
storage_key: String,
request_id: u64,
- runtime_generation: u64,
+ document_owner: crate::window_document_identity::WindowDocumentOwner,
completion_tx: RendererPageServiceWorkerTaskSender,
) -> bool {
let current_document_url = service_worker_current_url_for_creation_url(&document_url);
@@ -56,7 +56,7 @@ impl ServiceWorkerRuntimeService {
drop(state);
let _ = completion_tx.send_service_worker_ready(ServiceWorkerReadyCompletion {
request_id,
- runtime_generation,
+ document_owner,
registration: snapshot,
});
return true;
@@ -82,7 +82,7 @@ impl ServiceWorkerRuntimeService {
}
let ready_job = ServiceWorkerReadyJob {
request_id,
- runtime_generation,
+ document_owner,
completion_tx,
registration_id,
};
@@ -94,7 +94,7 @@ impl ServiceWorkerRuntimeService {
&self,
scope_url: Url,
storage_key: String,
- runtime_generation: u64,
+ document_owner: crate::window_document_identity::WindowDocumentOwner,
completion_tx: RendererPageServiceWorkerTaskSender,
) {
self.inner
@@ -104,7 +104,7 @@ impl ServiceWorkerRuntimeService {
.push(ServiceWorkerLifecycleWatcher {
scope_url,
storage_key,
- runtime_generation,
+ document_owner,
completion_tx,
});
}
diff --git a/moli-renderer-v8/src/service_worker_runtime/state.rs b/moli-renderer-v8/src/service_worker_runtime/state.rs
index 6d89f1d70..24a3c2d53 100644
--- a/moli-renderer-v8/src/service_worker_runtime/state.rs
+++ b/moli-renderer-v8/src/service_worker_runtime/state.rs
@@ -820,7 +820,7 @@ impl ServiceWorkerFetchJob {
#[derive(Clone, Debug)]
pub(super) struct ServiceWorkerReadyJob {
pub(super) request_id: u64,
- pub(super) runtime_generation: u64,
+ pub(super) document_owner: crate::window_document_identity::WindowDocumentOwner,
pub(super) completion_tx: RendererPageServiceWorkerTaskSender,
pub(super) registration_id: ServiceWorkerRegistrationId,
}
@@ -831,7 +831,7 @@ impl ServiceWorkerReadyJob {
.completion_tx
.send_service_worker_ready(ServiceWorkerReadyCompletion {
request_id: self.request_id,
- runtime_generation: self.runtime_generation,
+ document_owner: self.document_owner,
registration,
});
}
@@ -841,7 +841,7 @@ impl ServiceWorkerReadyJob {
pub(super) struct ServiceWorkerLifecycleWatcher {
pub(super) scope_url: Url,
pub(super) storage_key: String,
- pub(super) runtime_generation: u64,
+ pub(super) document_owner: crate::window_document_identity::WindowDocumentOwner,
pub(super) completion_tx: RendererPageServiceWorkerTaskSender,
}
@@ -855,7 +855,7 @@ impl ServiceWorkerLifecycleNotificationDelivery {
pub(super) fn send(self) {
let _ = self.watcher.completion_tx.send_service_worker_lifecycle(
ServiceWorkerLifecycleNotification {
- runtime_generation: self.watcher.runtime_generation,
+ document_owner: self.watcher.document_owner,
storage_key: self.watcher.storage_key,
registration: self.registration,
events: self.events,
@@ -962,21 +962,20 @@ pub(super) struct ServiceWorkerClient {
pub(super) secure_context: bool,
pub(super) execution_ready: bool,
pub(super) discarded_or_frozen: bool,
- pub(super) document_epoch: Option<u64>,
- pub(super) runtime_generation: u64,
+ pub(super) document_owner: Option<crate::window_document_identity::WindowDocumentOwner>,
pub(super) endpoint: ServiceWorkerClientEndpoint,
pub(super) focused: bool,
}
impl ServiceWorkerClient {
pub(super) fn window_completion_target(&self) -> Option<ServiceWorkerWindowClientTarget> {
- (self.client_type == ServiceWorkerClientType::Window).then_some(
- ServiceWorkerWindowClientTarget {
- client_id: self.id,
- document_epoch: self.document_epoch,
- transport_generation: self.runtime_generation,
- },
- )
+ if self.client_type != ServiceWorkerClientType::Window {
+ return None;
+ }
+ Some(ServiceWorkerWindowClientTarget {
+ client_id: self.id,
+ document_owner: self.document_owner?,
+ })
}
}
diff --git a/moli-renderer-v8/src/types.rs b/moli-renderer-v8/src/types.rs
index 6f691e507..1fb8bc16d 100644
--- a/moli-renderer-v8/src/types.rs
+++ b/moli-renderer-v8/src/types.rs
@@ -715,7 +715,7 @@ impl AsyncSubresourceFetchEvent {
#[derive(Debug)]
pub(super) struct ServiceWorkerRegisterCompletion {
pub(super) request_id: u64,
- pub(super) runtime_generation: u64,
+ pub(super) document_owner: crate::window_document_identity::WindowDocumentOwner,
pub(super) result: std::result::Result<
crate::service_worker_runtime::ServiceWorkerRegistrationSnapshot,
crate::service_worker_runtime::ServiceWorkerRegistrationError,
@@ -725,22 +725,21 @@ pub(super) struct ServiceWorkerRegisterCompletion {
#[derive(Debug)]
pub(super) struct ServiceWorkerReadyCompletion {
pub(super) request_id: u64,
- pub(super) runtime_generation: u64,
+ pub(super) document_owner: crate::window_document_identity::WindowDocumentOwner,
pub(super) registration: crate::service_worker_runtime::ServiceWorkerRegistrationSnapshot,
}
#[derive(Debug)]
pub(super) struct ServiceWorkerUnregisterCompletion {
pub(super) request_id: u64,
- pub(super) runtime_generation: u64,
+ pub(super) document_owner: crate::window_document_identity::WindowDocumentOwner,
pub(super) result: bool,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(super) struct ServiceWorkerWindowClientTarget {
pub(super) client_id: crate::service_worker_runtime::ServiceWorkerClientId,
- pub(super) document_epoch: Option<u64>,
- pub(super) transport_generation: u64,
+ pub(super) document_owner: crate::window_document_identity::WindowDocumentOwner,
}
#[derive(Debug)]
@@ -835,7 +834,7 @@ pub(super) enum ServiceWorkerLifecycleClientEvent {
#[derive(Debug)]
pub(super) struct ServiceWorkerLifecycleNotification {
- pub(super) runtime_generation: u64,
+ pub(super) document_owner: crate::window_document_identity::WindowDocumentOwner,
pub(super) storage_key: String,
pub(super) registration: crate::service_worker_runtime::ServiceWorkerRegistrationSnapshot,
pub(super) events: Vec<ServiceWorkerLifecycleClientEvent>,
diff --git a/moli-renderer-v8/src/window_document_identity.rs b/moli-renderer-v8/src/window_document_identity.rs
new file mode 100644
index 000000000..3464e62b4
--- /dev/null
+++ b/moli-renderer-v8/src/window_document_identity.rs
@@ -0,0 +1,76 @@
+use crate::frame_owner_model::FrameDocumentTaskOwner;
+
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
+pub(crate) struct LightweightPopupDocumentId(u64);
+
+impl LightweightPopupDocumentId {
+ pub(crate) fn new(value: u64) -> Self {
+ Self(value)
+ }
+
+ pub(crate) fn as_u64(self) -> u64 {
+ self.0
+ }
+}
+
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
+pub(crate) struct LightweightPopupLocalWindowId(u64);
+
+impl LightweightPopupLocalWindowId {
+ pub(crate) fn new(value: u64) -> Self {
+ Self(value)
+ }
+
+ pub(crate) fn as_u64(self) -> u64 {
+ self.0
+ }
+}
+
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
+pub(crate) struct LightweightPopupDocumentOwner {
+ popup_id: u64,
+ document_id: LightweightPopupDocumentId,
+}
+
+impl LightweightPopupDocumentOwner {
+ pub(crate) fn new(popup_id: u64, document_id: LightweightPopupDocumentId) -> Self {
+ Self {
+ popup_id,
+ document_id,
+ }
+ }
+
+ pub(crate) fn popup_id(self) -> u64 {
+ self.popup_id
+ }
+
+ pub(crate) fn document_id(self) -> LightweightPopupDocumentId {
+ self.document_id
+ }
+}
+
+/// Exact identity of one live Window `Document`, independent of its dispatch
+/// address and of any numeric projection used by a transport.
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
+pub(crate) enum WindowDocumentOwner {
+ Frame(FrameDocumentTaskOwner),
+ LightweightPopup(LightweightPopupDocumentOwner),
+}
+
+impl WindowDocumentOwner {
+ pub(crate) fn frame_document_owner(self) -> Option<FrameDocumentTaskOwner> {
+ match self {
+ Self::Frame(owner) => Some(owner),
+ Self::LightweightPopup(_) => None,
+ }
+ }
+
+ #[cfg(test)]
+ pub(crate) fn for_test(identity: u64) -> Self {
+ Self::Frame(FrameDocumentTaskOwner::new(
+ crate::frame_owner_model::FrameSchedulerLaneId(identity),
+ crate::frame_owner_model::LocalWindowId(identity),
+ crate::frame_owner_model::DocumentId(identity),
+ ))
+ }
+}