Skip to main content

Page

Struct Page 

Source
pub struct Page { /* private fields */ }
Expand description

An open page. Closed, with its browser context, when dropped.

Implementations§

Source§

impl Page

Source

pub fn eval(&self, js: &str) -> Result<Value, BrowserError>

Evaluate js in the page (awaiting a promise it returns) and hand back its JSON value — in the document the page is in, once it has arrived there.

Source

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

Wait until the page has nothing left in flight that will finish: every request it made is either complete — its body read, and the completion turn that read it run — or HELD, a request nothing has answered, which stays pending as it would on a network that has not replied; and every file it offered for download has been read out of its blob.

An answered request completes over real time the paused virtual clock does not model: the harness fulfils it from Fetch.requestPaused (see PageSink::event) with a command nothing acknowledges, and the response, the page’s fetch() resolving and the completion turn then take however many of the page’s own event-loop turns they take. So this reads what is in flight from the page itself (__logosHarness.inFlight(): the recorder’s own ledger of every fetch and blob read) and holds each pending request against the held ones, method and URL, until nothing is pending that is not held. Its relay connections are through too: open, every message it sent read by the relay, every message the relay wrote to it handled — so once the page that published settles, a page that heard it settles to having heard it. A page that never gets there is a failure naming what it is still waiting for.

Every verb that drives the page begins and ends here, following the page to every document it asks for on the way (Page::catch_up) — a submitted form’s navigation, which Chrome plans on a task the paused clock holds, is let run first — so a settle ends in the document the page came to rest in. A page nothing drove settles to what reached it from elsewhere — another page’s publish.

Source

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

Click the element sel names, as a visitor would: a trusted press and release at its centre, so a submit button submits and a checkbox toggles.

No mouseMoved precedes the press. A move is a continuous event the renderer aligns to its next frame, and with the page’s clock paused no frame comes: the move is acknowledged only by the input router’s timeout, seconds later. Press and release are discrete and are dispatched at once.

Source

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

Type text into the control sel names, replacing what it held: focus, select all, trusted text insertion (input), then change — the events a visitor’s typing raises.

Source

pub fn press(&self, key: &str) -> Result<(), BrowserError>

Press key on whatever has focus: "Enter", "Escape", "Tab", "Backspace", "Delete", the arrows, "Home", "End", "PageUp", "PageDown", "Space", or one printable character. Names are matched without regard to case.

Source

pub fn press_in(&self, sel: &str, key: &str) -> Result<(), BrowserError>

Focus sel, then press key there.

Source

pub fn focus(&self, sel: &str) -> Result<(), BrowserError>

Move focus to sel (the browser raises focus).

Source

pub fn blur(&self, sel: &str) -> Result<(), BrowserError>

Take focus off sel (the browser raises blur).

Source

pub fn hover(&self, sel: &str) -> Result<(), BrowserError>

The pointer arriving over sel: the mouseover a visitor’s mouse raises there, dispatched on the element and bubbling from it. A trusted pointer move is a continuous input the renderer delivers on its next frame, and with the page’s clock paused no frame comes — the move would reach the page later, whenever the clock next moved — so the event is raised in the page, at once, as the browser would raise it.

Source

pub fn choose(&self, sel: &str, value: &str) -> Result<(), BrowserError>

Pick the option of the <select> at sel whose value (or else whose text) is value, raising input and change.

Source

pub fn submit(&self, sel: &str) -> Result<(), BrowserError>

Submit the form sel names (or the form a submit button at sel belongs to) through requestSubmit, so the page’s submit handlers run and, unless one prevents it, the browser performs the submission.

Source

pub fn drop_file( &self, sel: &str, name: &str, content: &[u8], ) -> Result<Option<DroppedFile>, BrowserError>

Drop a file named name holding content on the element sel names, as a visitor dragging it there from their desktop does: a trusted drag carrying a real file on disk enters the element’s centre, moves over it and drops. The drop reaches the page only when the element accepts drops — something on the page cancels dragover — exactly as for a visitor, and the browser then reads the name, size and content from the file itself and names its type from its name. Answers the file as the browser described it, None when no drop reached the document.

Source

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

The names the page’s module exports, as its host sees them.

Source

pub fn mount( &self, component: &str, parent: Option<&str>, ) -> Result<(), BrowserError>

Mount the component component under the element parent names (the page’s body when None), through the mount entry the page’s host exposes for it — present only when the page was built for a host that mounts it on demand (PageBundle::page_with).

Source

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

Reload the page, as a visitor pressing reload does: the document loads again, the module runs main again, and everything the page kept in browser storage is still there.

Source

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

Both storage areas as the page left them, (area, key, value) — local then session, each sorted by key: the shape semantics::storage answers in.

Source

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

Every frame the page handed its relay, (topic, message), in order — read off the host boundary, where the page publishes, whatever becomes of the frame after.

Source

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

Every navigation of the document the page is in now, in the reference renderer’s spelling (push /x, replace /y): the pushState/replaceState moves made in it, led by load <path> when the page navigated to this document itself — the log semantics::dom keeps per document.

Source

pub fn snapshot(&self) -> Result<Snapshot, BrowserError>

The page now.

Source

pub fn import_trace(&self) -> Result<Vec<HostCall>, BrowserError>

Every call across the host boundary since the page loaded, in order.

Source

pub fn trace_len(&self) -> Result<usize, BrowserError>

How many calls the trace holds — a mark to slice Page::import_trace from.

Source

pub fn advance(&self, ms: u64) -> Result<(), BrowserError>

Move the page’s clock forward ms virtual milliseconds, running every timer that falls due, then settle. The clock does not move otherwise.

Chrome reports the budget spent as its clock reaches the end and pauses the clock there, fencing the page’s timer queues, so work that falls due at that instant can be left behind the fence. The advance ends in run_held_tasks, whose clock moves only once nothing is left to run: every task due by the end has run when this returns. A zero advance is that alone, since Chrome reports no budget spent that it was never given.

Source

pub fn answer( &self, method: &str, path: &str, status: u16, content_type: &str, body: &[u8], ) -> Result<(), BrowserError>

Answer method path with status and body — now for a request the page is waiting on, and from now on for every new one. path is relative to the page’s origin (/api/todo) or a full URL for another origin. Returns once the page has read every answered body.

Source

pub fn pending_requests(&self) -> Vec<(String, String)>

Requests outside the bundle that nothing has answered, as (method, url).

Source

pub fn page_requests(&self) -> Result<Vec<PageRequest>, BrowserError>

The page’s own request table: every request it made, answered or not, in the order it made them — what semantics::dom’s fetch table holds for the same page in process.

Source

pub fn requests(&self) -> Vec<(String, String)>

Every request the page made outside its bundle, answered or not, as (method, url).

Source

pub fn console(&self) -> Vec<ConsoleLine>

What the page logged to its console.

Source

pub fn exceptions(&self) -> Vec<String>

Every uncaught exception, as its description.

Source

pub fn navigations(&self) -> Vec<String>

The URL of every document the main frame has committed, in order.

Source

pub fn navigation_requests(&self) -> Vec<String>

Every navigation the page asked the browser for (a link, a form submission, a script), whether or not it has committed yet.

Source

pub fn journal(&self) -> Vec<JournalEntry>

Every turn the page noted (noteTurn), in order — the journal of the whole visit, across every document the page has loaded.

Source

pub fn submissions(&self) -> Vec<(Option<String>, bool)>

Every form submission the page saw, as (form path, whether its default action was prevented), in order — across every document the page has loaded.

Source

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

The text the page put on the clipboard, in order.

Source

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

The title of every notification the page raised, in order.

Source

pub fn downloads(&self) -> Result<Vec<(String, Option<String>)>, BrowserError>

Every file the page offered for download, as (name, content) — the content is None until the browser has read it out of its blob.

Source

pub fn prerendered_fate(&self) -> Result<(usize, Vec<String>), BrowserError>

Of the elements the document held when parsing finished — before any module ran — how many there were, and the paths of those no longer in the document.

Source

pub fn dom_counters(&self) -> Result<DomCounters, BrowserError>

The live renderer objects after a full garbage collection.

Trait Implementations§

Source§

impl Drop for Page

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !Freeze for Page

§

impl RefUnwindSafe for Page

§

impl Send for Page

§

impl Sync for Page

§

impl Unpin for Page

§

impl UnsafeUnpin for Page

§

impl UnwindSafe for Page

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,