pub struct Page { /* private fields */ }Expand description
An open page. Closed, with its browser context, when dropped.
Implementations§
Source§impl Page
impl Page
Sourcepub fn eval(&self, js: &str) -> Result<Value, BrowserError>
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.
Sourcepub fn settle(&self) -> Result<(), BrowserError>
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.
Sourcepub fn click(&self, sel: &str) -> Result<(), BrowserError>
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.
Sourcepub fn type_into(&self, sel: &str, text: &str) -> Result<(), BrowserError>
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.
Sourcepub fn press(&self, key: &str) -> Result<(), BrowserError>
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.
Sourcepub fn press_in(&self, sel: &str, key: &str) -> Result<(), BrowserError>
pub fn press_in(&self, sel: &str, key: &str) -> Result<(), BrowserError>
Focus sel, then press key there.
Sourcepub fn focus(&self, sel: &str) -> Result<(), BrowserError>
pub fn focus(&self, sel: &str) -> Result<(), BrowserError>
Move focus to sel (the browser raises focus).
Sourcepub fn blur(&self, sel: &str) -> Result<(), BrowserError>
pub fn blur(&self, sel: &str) -> Result<(), BrowserError>
Take focus off sel (the browser raises blur).
Sourcepub fn hover(&self, sel: &str) -> Result<(), BrowserError>
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.
Sourcepub fn choose(&self, sel: &str, value: &str) -> Result<(), BrowserError>
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.
Sourcepub fn submit(&self, sel: &str) -> Result<(), BrowserError>
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.
Sourcepub fn drop_file(
&self,
sel: &str,
name: &str,
content: &[u8],
) -> Result<Option<DroppedFile>, BrowserError>
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.
Sourcepub fn exports(&self) -> Result<Vec<String>, BrowserError>
pub fn exports(&self) -> Result<Vec<String>, BrowserError>
The names the page’s module exports, as its host sees them.
Sourcepub fn mount(
&self,
component: &str,
parent: Option<&str>,
) -> Result<(), BrowserError>
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).
Sourcepub fn reload(&self) -> Result<(), BrowserError>
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.
Sourcepub fn storage(&self) -> Result<Vec<(String, String, String)>, BrowserError>
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.
Sourcepub fn published(&self) -> Result<Vec<(String, String)>, BrowserError>
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.
Sourcepub fn route_ops(&self) -> Result<Vec<String>, BrowserError>
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.
Sourcepub fn snapshot(&self) -> Result<Snapshot, BrowserError>
pub fn snapshot(&self) -> Result<Snapshot, BrowserError>
The page now.
Sourcepub fn import_trace(&self) -> Result<Vec<HostCall>, BrowserError>
pub fn import_trace(&self) -> Result<Vec<HostCall>, BrowserError>
Every call across the host boundary since the page loaded, in order.
Sourcepub fn trace_len(&self) -> Result<usize, BrowserError>
pub fn trace_len(&self) -> Result<usize, BrowserError>
How many calls the trace holds — a mark to slice Page::import_trace from.
Sourcepub fn advance(&self, ms: u64) -> Result<(), BrowserError>
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.
Sourcepub fn answer(
&self,
method: &str,
path: &str,
status: u16,
content_type: &str,
body: &[u8],
) -> Result<(), BrowserError>
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.
Sourcepub fn pending_requests(&self) -> Vec<(String, String)>
pub fn pending_requests(&self) -> Vec<(String, String)>
Requests outside the bundle that nothing has answered, as (method, url).
Sourcepub fn page_requests(&self) -> Result<Vec<PageRequest>, BrowserError>
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.
Sourcepub fn requests(&self) -> Vec<(String, String)>
pub fn requests(&self) -> Vec<(String, String)>
Every request the page made outside its bundle, answered or not, as (method, url).
Sourcepub fn console(&self) -> Vec<ConsoleLine>
pub fn console(&self) -> Vec<ConsoleLine>
What the page logged to its console.
Sourcepub fn exceptions(&self) -> Vec<String>
pub fn exceptions(&self) -> Vec<String>
Every uncaught exception, as its description.
The URL of every document the main frame has committed, in order.
Every navigation the page asked the browser for (a link, a form submission, a script), whether or not it has committed yet.
Sourcepub fn journal(&self) -> Vec<JournalEntry>
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.
Sourcepub fn submissions(&self) -> Vec<(Option<String>, bool)>
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.
Sourcepub fn clipboard(&self) -> Result<Vec<String>, BrowserError>
pub fn clipboard(&self) -> Result<Vec<String>, BrowserError>
The text the page put on the clipboard, in order.
Sourcepub fn notifications(&self) -> Result<Vec<String>, BrowserError>
pub fn notifications(&self) -> Result<Vec<String>, BrowserError>
The title of every notification the page raised, in order.
Sourcepub fn downloads(&self) -> Result<Vec<(String, Option<String>)>, BrowserError>
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.
Sourcepub fn prerendered_fate(&self) -> Result<(usize, Vec<String>), BrowserError>
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.
Sourcepub fn dom_counters(&self) -> Result<DomCounters, BrowserError>
pub fn dom_counters(&self) -> Result<DomCounters, BrowserError>
The live renderer objects after a full garbage collection.
Trait Implementations§
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> 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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.