Skip to main content

PageHandle

Struct PageHandle 

Source
pub struct PageHandle { /* private fields */ }

Implementations§

Source§

impl PageHandle

Source

pub fn id(&self) -> usize

Source

pub fn navigate(&self, url: &str) -> Result<(), BrowserError>

Source

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.

Source

pub fn drain_callbacks(&self) -> Result<String, BrowserError>

Source

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).

Source

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).

Source

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).

Source

pub fn take_screenshot( &self, format: ScreenshotFormat, ) -> Result<Vec<u8>, BrowserError>

Source

pub fn page_title(&self) -> Option<String>

Source

pub fn current_url(&self) -> Option<String>

Source

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.

Source

pub fn get_state(&self) -> PageState

Source

pub fn is_alive(&self) -> bool

Source

pub fn permission(&self) -> PermissionGuard

Source

pub fn stealth_profile(&self) -> Option<StealthProfile>

Source

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]

Source

pub fn wait_for_selector( &self, selector: &str, timeout: Duration, ) -> Result<(), BrowserError>

Wait for an element matching the selector to appear in the DOM.

Source

pub fn wait_for_function( &self, fn_expression: &str, timeout: Duration, ) -> Result<(), BrowserError>

Wait for a JS function/condition to return a truthy value.

Source

pub fn wait_for_navigation(&self, timeout: Duration) -> Result<(), BrowserError>

Wait for page navigation to complete (URL change + load complete).

Source

pub fn click(&self, selector: &str) -> Result<(), BrowserError>

Click an element matching the selector.

Source

pub fn type_text(&self, text: &str) -> Result<(), BrowserError>

Type text into the currently focused element by dispatching key events.

Source

pub fn fill(&self, selector: &str, value: &str) -> Result<(), BrowserError>

Fill a form field identified by selector with the given value.

Source

pub fn set_content(&self, html: &str) -> Result<(), BrowserError>

Set the page HTML content via document.open/write/close.

Source

pub fn content(&self) -> Result<String, BrowserError>

Get the page HTML content via document.documentElement.outerHTML.

Source

pub fn set_viewport(&self, width: u32, height: u32) -> Result<(), BrowserError>

Set viewport size.

Source

pub fn cookies( &self, urls: &[String], ) -> Result<Vec<Cookie<'static>>, BrowserError>

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.

Source

pub fn select( &self, selector: &str, values: &[&str], ) -> Result<(), BrowserError>

Select options in a