use chromiumoxide_cdp::cdp::js_protocol::runtime::ExecutionContextId;
#[derive(Debug, Clone, Default)]
pub struct DOMWorld {
execution_ctx: Option<ExecutionContextId>,
detached: bool,
}
impl DOMWorld {
pub fn main_world() -> Self {
Self {
execution_ctx: None,
detached: false,
}
}
pub fn secondary_world() -> Self {
Self {
execution_ctx: None,
detached: false,
}
}
pub fn execution_context(&self) -> Option<ExecutionContextId> {
self.execution_ctx
}
pub fn set_context(&mut self, ctx: ExecutionContextId) {
self.execution_ctx = Some(ctx);
}
pub fn take_context(&mut self) -> Option<ExecutionContextId> {
self.execution_ctx.take()
}
pub fn is_detached(&self) -> bool {
self.detached
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum DOMWorldKind {
Main,
Secondary,
}
impl Default for DOMWorldKind {
fn default() -> Self {
DOMWorldKind::Main
}
}