Expand description
A real browser as a page tier: headless Chrome, driven over the DevTools protocol.
Browser::launch starts Chrome with --remote-debugging-pipe — the protocol travels over
two pipes the harness owns, so no port is opened and nothing else can attach. Browser::open
serves a PageBundle from a loopback HTTP server and loads it in a fresh target inside a
browser context of its own (no cookies, storage or cache shared with any other page), then
returns a Page once the page’s module has run main and committed its first paint.
What a Page offers is the whole driving surface a page tier needs:
- real input —
Page::click,Page::type_into,Page::pressdispatch trusted mouse and keyboard events through the browser’s input pipeline, so default actions (a submit button submitting, Enter submitting a form) happen exactly as they do for a visitor;Page::chooseandPage::submituse the DOM’s ownchange/requestSubmitpaths; Page::snapshot— the document as a canonical tree, title, URL and focused element;Page::import_trace— every host import the module called and every export the host called, in order, recorded by wrappingWebAssembly.instantiate(the page’s own runtime is untouched);Page::advance— the page’s clock under virtual time: paused from the moment the page is ready, moving only when a test moves it;Page::answer— network stubs: every request outside the bundle is intercepted, answered when a stub matches and otherwise HELD, so an unanswered request stays pending as it would on a network that has not replied;- navigation — a document the page asks the browser for (a link it follows, a form it submits,
a
locationit assigns) is let in only once the document that asked has reported everything it will, and every act, settle and read is made in the document the page came to rest in, never in one half-replaced; Page::eval— anything else, as JavaScript.
One browser serves a whole test binary (shared); every Page is its own target and is
closed when dropped. Every wait has a deadline and fails loudly, naming what it waited for.
Structs§
- Answer
- An answer for a request the page may make:
method pathanswered withstatus, acontent-typeandbody.pathis relative to the page’s origin (/api/todo) or a full URL for another origin. - Browser
- A running headless Chrome.
- Chrome
Launcher - Launches a page in the shared, process-wide Chrome for one scenario, as its project serves it:
the project’s
static/files beside the page and its stylesheets linked from the document’s head, by the rulelargo serveapplies (serve_web::stylesheet_links_for). A page’s layout is its stylesheet’s as much as its markup’s — which element a click lands on depends on it — so a page tested bare is not the page a visitor gets. A launcher with no project serves the page alone. - Console
Line - One console message the page logged.
- DomCounters
- The renderer’s live object counts after a full garbage collection.
- Host
Call - One call across the host boundary, as the recorder saw it. Arguments and results are the decimal form of the raw wasm values (a Text argument is its handle).
- Open
Options - Setup applied before the page’s own scripts run.
- Page
- An open page. Closed, with its browser context, when dropped.
- Page
Bundle - A built page: files by URL path, and the path the browser opens.
- Page
Request - One request in the page’s own request table, as the page asked for it at the host boundary: its method, URL, body and headers as the page wrote them, and the timeout and abort it later asked for.
- Relay
Hub - A relay the pages of one test share: every page opened with it publishes into it and hears what the others publish.
- Snapshot
- The page at one moment, as the browser holds it.
Enums§
- Browser
Error - Why a browser operation failed.
- Call
Kind - Which way a traced call crossed the host boundary.
- DomNode
- One node of a snapshot document. An element carries its attributes sorted by name, and the
two control PROPERTIES a visitor moves —
valueandchecked— only where they differ from what the markup alone says (an untouched<input value="x">has novalueentry; a typed-into one does).
Functions§
- locate_
chrome - The Chrome (or Chromium) binary this machine has:
CHROME_BINwhen it names a file, otherwise the first of the usual names found onPATH. - shared
- The one browser this process shares, launched from
chromeon first use.