pub struct PageHandle { /* private fields */ }Implementations§
Source§impl PageHandle
impl PageHandle
pub fn id(&self) -> usize
Sourcepub fn wait_for_pipeline_ready(
&self,
timeout: Duration,
) -> Result<(), BrowserError>
pub fn wait_for_pipeline_ready( &self, timeout: Duration, ) -> Result<(), BrowserError>
Wait for servo’s WebView pipeline to be ready for script evaluation.
After pool.create_page(), servo’s constellation hasn’t finished setting
up the script thread pipeline. Calling evaluate_js_web too early causes
SIGSEGV. This method waits for frame_ready callback from servo, then
verifies pipeline readiness via drain_callbacks.
Uses event-driven notification via notify_new_frame_ready callback
instead of sleep polling.
pub fn drain_callbacks(&self) -> Result<String, BrowserError>
Sourcepub fn evaluate_js(&self, script: &str) -> Result<String, BrowserError>
pub fn evaluate_js(&self, script: &str) -> Result<String, BrowserError>
Evaluate JS with Node API injection (trusted context). Node Realm is eagerly initialized at page creation time (REQ-SEC-002).
Sourcepub fn evaluate_js_web(&self, script: &str) -> Result<String, BrowserError>
pub fn evaluate_js_web(&self, script: &str) -> Result<String, BrowserError>
Evaluate JS without Node API injection — web-only mode.
Public for security verification: tests need to confirm that page-level JS cannot access Node APIs (REQ-SEC-002/003).
Sourcepub fn add_script_to_evaluate_on_new_document(
&self,
source: &str,
) -> Result<(), BrowserError>
pub fn add_script_to_evaluate_on_new_document( &self, source: &str, ) -> Result<(), BrowserError>
Register a script that servo replays on every future document load of this page (CDP Page.addScriptToEvaluateOnNewDocument backing).
Real navigation replay through servo’s UserContentManager: the script is added to the page’s user-content set and executed by the script thread when each new document is created. Takes effect from the next navigation (servo applies user-content updates on reload/navigation).
pub fn take_screenshot( &self, format: ScreenshotFormat, ) -> Result<Vec<u8>, BrowserError>
pub fn page_title(&self) -> Option<String>
pub fn current_url(&self) -> Option<String>
Sourcepub fn servo(&self) -> &Rc<Servo>
pub fn servo(&self) -> &Rc<Servo>
Access the Servo instance for this page (e.g. SiteDataManager, NetworkManager). Used by CDP domain handlers to access cookie/cache/network APIs.
pub fn get_state(&self) -> PageState
pub fn is_alive(&self) -> bool
pub fn permission(&self) -> PermissionGuard
pub fn stealth_profile(&self) -> Option<StealthProfile>
Sourcepub fn webview_state(&self) -> Rc<RefCell<BaoWebViewState>>
pub fn webview_state(&self) -> Rc<RefCell<BaoWebViewState>>
Access the page’s BaoWebViewState for Worker lifecycle management.
Used by BaoRuntime::create_worker to access Worker tracking, channel bridges, and scope states.
@trace REQ-BRW-004 [entity:Worker] [criterion:10]
Sourcepub fn wait_for_selector(
&self,
selector: &str,
timeout: Duration,
) -> Result<(), BrowserError>
pub fn wait_for_selector( &self, selector: &str, timeout: Duration, ) -> Result<(), BrowserError>
Wait for an element matching the selector to appear in the DOM.
Sourcepub fn wait_for_function(
&self,
fn_expression: &str,
timeout: Duration,
) -> Result<(), BrowserError>
pub fn wait_for_function( &self, fn_expression: &str, timeout: Duration, ) -> Result<(), BrowserError>
Wait for a JS function/condition to return a truthy value.
Wait for page navigation to complete (URL change + load complete).
Sourcepub fn click(&self, selector: &str) -> Result<(), BrowserError>
pub fn click(&self, selector: &str) -> Result<(), BrowserError>
Click an element matching the selector.
Sourcepub fn type_text(&self, text: &str) -> Result<(), BrowserError>
pub fn type_text(&self, text: &str) -> Result<(), BrowserError>
Type text into the currently focused element by dispatching key events.
Sourcepub fn fill(&self, selector: &str, value: &str) -> Result<(), BrowserError>
pub fn fill(&self, selector: &str, value: &str) -> Result<(), BrowserError>
Fill a form field identified by selector with the given value.
Sourcepub fn set_content(&self, html: &str) -> Result<(), BrowserError>
pub fn set_content(&self, html: &str) -> Result<(), BrowserError>
Set the page HTML content via document.open/write/close.
Sourcepub fn content(&self) -> Result<String, BrowserError>
pub fn content(&self) -> Result<String, BrowserError>
Get the page HTML content via document.documentElement.outerHTML.
Sourcepub fn set_viewport(&self, width: u32, height: u32) -> Result<(), BrowserError>
pub fn set_viewport(&self, width: u32, height: u32) -> Result<(), BrowserError>
Set viewport size.
Get cookies for the given URLs (or current page URL if empty).
Set a cookie for the given URL.
Delete cookies matching the given name for the given URL.
Sourcepub fn select(
&self,
selector: &str,
values: &[&str],
) -> Result<(), BrowserError>
pub fn select( &self, selector: &str, values: &[&str], ) -> Result<(), BrowserError>
Select options in a
Sourcepub fn press(&self, key: &str) -> Result<(), BrowserError>
pub fn press(&self, key: &str) -> Result<(), BrowserError>
Press a key (e.g. “Enter”, “Tab”, “ArrowDown”).
Sourcepub fn hover(&self, selector: &str) -> Result<(), BrowserError>
pub fn hover(&self, selector: &str) -> Result<(), BrowserError>
Hover over an element matching the selector.
Sourcepub fn focus_element(&self, selector: &str) -> Result<(), BrowserError>
pub fn focus_element(&self, selector: &str) -> Result<(), BrowserError>
Focus an element matching the selector.
Sourcepub fn reload(&self) -> Result<(), BrowserError>
pub fn reload(&self) -> Result<(), BrowserError>
Reload the page.
Sourcepub fn go_back(&self) -> Result<(), BrowserError>
pub fn go_back(&self) -> Result<(), BrowserError>
Navigate back in history.
Sourcepub fn go_forward(&self) -> Result<(), BrowserError>
pub fn go_forward(&self) -> Result<(), BrowserError>
Navigate forward in history.
Sourcepub fn can_go_back(&self) -> bool
pub fn can_go_back(&self) -> bool
Check if back navigation is possible.
Sourcepub fn can_go_forward(&self) -> bool
pub fn can_go_forward(&self) -> bool
Check if forward navigation is possible.
Sourcepub fn take_screenshot_advanced(
&self,
format: ScreenshotFormat,
clip: Option<(f64, f64, f64, f64)>,
full_page: bool,
) -> Result<Vec<u8>, BrowserError>
pub fn take_screenshot_advanced( &self, format: ScreenshotFormat, clip: Option<(f64, f64, f64, f64)>, full_page: bool, ) -> Result<Vec<u8>, BrowserError>
Take screenshot with optional clip region and fullPage mode.
Sourcepub fn dispatch_mouse_event(
&self,
action: MouseButtonAction,
button: MouseButton,
x: f32,
y: f32,
) -> Result<(), BrowserError>
pub fn dispatch_mouse_event( &self, action: MouseButtonAction, button: MouseButton, x: f32, y: f32, ) -> Result<(), BrowserError>
Dispatch a mouse button event at the given page coordinates.
Sourcepub fn dispatch_mouse_move(&self, x: f32, y: f32) -> Result<(), BrowserError>
pub fn dispatch_mouse_move(&self, x: f32, y: f32) -> Result<(), BrowserError>
Dispatch a mouse move event at the given page coordinates.
Sourcepub fn dispatch_key_event(
&self,
state: KeyState,
key: Key,
code: Code,
) -> Result<(), BrowserError>
pub fn dispatch_key_event( &self, state: KeyState, key: Key, code: Code, ) -> Result<(), BrowserError>
Dispatch a keyboard event.
pub fn close(&self) -> Result<(), BrowserError>
Sourcepub fn set_page_global(
&self,
page_global: *mut JSObject,
node_global: *mut JSObject,
)
pub fn set_page_global( &self, page_global: *mut JSObject, node_global: *mut JSObject, )
Store page_global and node_realm_global pointers in PageInner (REQ-SEC-002). Called by runtime_bridge after drain_callbacks populates the per-page HashMap.
Sourcepub fn has_node_realm(&self) -> (bool, bool)
pub fn has_node_realm(&self) -> (bool, bool)
Check whether the Node Realm was successfully created for this page.
Returns (page_global_set, node_realm_set) — both should be true after
inject_node_apis_with_stealth completes successfully.
Trait Implementations§
Source§impl Clone for PageHandle
impl Clone for PageHandle
Source§fn clone(&self) -> PageHandle
fn clone(&self) -> PageHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for PageHandle
impl !Send for PageHandle
impl !Sync for PageHandle
impl !UnwindSafe for PageHandle
impl Freeze for PageHandle
impl Unpin for PageHandle
impl UnsafeUnpin for PageHandle
Blanket Implementations§
Source§impl<T> AsCtxPtr for Twhere
T: ?Sized,
impl<T> AsCtxPtr for Twhere
T: ?Sized,
Source§fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
self’s address as *mut Self for deferred-task / scopeguard /
ref_guard ctx slots. The closures/trampolines deref it as shared
(&*p) — every method they reach is &self post-R-2, so no write
provenance is required; the *mut spelling is purely to match the
existing DerefOnDrop / HasAutoFlush / RefCount ABI.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more