pub struct WpeBackend { /* private fields */ }Expand description
Real WebKitGTK 6 backend. Construct on the GTK main thread; all subsequent calls must come from the same thread.
Implementations§
Source§impl WpeBackend
impl WpeBackend
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a backend. Caller must already have initialized GTK on
this thread (via gtk4::init()); production wiring lives in
vs-cli::serve on Linux. Constructing on a non-GTK thread will
panic the first time a WebView operation runs.
Sourcepub fn with_capture_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_capture_dir(self, dir: impl Into<PathBuf>) -> Self
Pin the directory where capture writes PNGs. Defaults to a
system temp subdirectory.
Trait Implementations§
Source§impl Default for WpeBackend
impl Default for WpeBackend
Source§impl Engine for WpeBackend
impl Engine for WpeBackend
Source§fn open(&mut self, url: &str, store: &DataStore) -> EngineResult<PageHandle>
fn open(&mut self, url: &str, store: &DataStore) -> EngineResult<PageHandle>
Open a fresh page navigated to
url, in data store store.Source§fn open_start(
&mut self,
url: &str,
store: &DataStore,
) -> EngineResult<OpenStart>
fn open_start( &mut self, url: &str, store: &DataStore, ) -> EngineResult<OpenStart>
Start opening a page and return without waiting for its first
load, so the engine thread serves other pages meanwhile (a new
page’s web process takes tens of milliseconds to start, all of
it idle on this thread). The default opens synchronously.
Source§fn open_poll(&mut self, ticket: u64) -> Option<EngineResult<PageHandle>>
fn open_poll(&mut self, ticket: u64) -> Option<EngineResult<PageHandle>>
Finish an open that
Engine::open_start left pending: None
while its load is still running, then the page or the error.
Polled from the engine thread between jobs.Navigate an existing page to
url in place, reusing its
web view (and web-content process) instead of creating a new
one. The page handle is unchanged; the document is replaced, so
callers must re-baseline (all refs are fresh). Much cheaper than
open for successive navigations.Source§fn load_html(
&mut self,
page: PageHandle,
url: &str,
html: &str,
) -> EngineResult<()>
fn load_html( &mut self, page: PageHandle, url: &str, html: &str, ) -> EngineResult<()>
Load
html as the page’s document under url: the document
has that URL and origin, but nothing is fetched and no response
headers apply. A test runner uses it to serve a routed main
document for a host the proxy cannot see (loopback on macOS).Source§fn add_init_script(
&mut self,
page: PageHandle,
source: &str,
) -> EngineResult<()>
fn add_init_script( &mut self, page: PageHandle, source: &str, ) -> EngineResult<()>
Run
source at document start in every frame of every later
document in page, before the page’s own scripts. The current
document is not touched (same as Playwright’s addInitScript).
Scripts accumulate in the order they were added and are not
subject to the page’s Content Security Policy.Source§fn enable_webauthn(&mut self, _page: PageHandle) -> EngineResult<()>
fn enable_webauthn(&mut self, _page: PageHandle) -> EngineResult<()>
Install a virtual WebAuthn authenticator on
page: a pure-JS
software authenticator that overrides navigator.credentials
so passkey registration and login work headlessly, with no
platform authenticator and no automation protocol. Applies to
the current document and (where the backend supports it) to
subsequent navigations in the same page.Source§fn close(&mut self, page: PageHandle) -> EngineResult<()>
fn close(&mut self, page: PageHandle) -> EngineResult<()>
Close a page. Idempotent — closing a closed page is a no-op.
Source§fn drop_store(&mut self, key: &str) -> EngineResult<()>
fn drop_store(&mut self, key: &str) -> EngineResult<()>
Discard the isolated data store keyed
key, once its pages are
closed. Unknown keys are a no-op.Source§fn snapshot(&mut self, page: PageHandle) -> EngineResult<Tree>
fn snapshot(&mut self, page: PageHandle) -> EngineResult<Tree>
Snapshot the a11y tree at
page.Source§fn act(
&mut self,
page: PageHandle,
target: ActTarget,
action: Action,
mode: InputMode,
) -> EngineResult<()>
fn act( &mut self, page: PageHandle, target: ActTarget, action: Action, mode: InputMode, ) -> EngineResult<()>
Perform
action on target at page.Source§fn wait(
&mut self,
page: PageHandle,
cond: WaitCondition,
budget: Duration,
) -> EngineResult<()>
fn wait( &mut self, page: PageHandle, cond: WaitCondition, budget: Duration, ) -> EngineResult<()>
Wait for
cond at page until satisfied or budget elapses.Source§fn layout(
&mut self,
page: PageHandle,
refs: &[Ref],
) -> EngineResult<Vec<LayoutBox>>
fn layout( &mut self, page: PageHandle, refs: &[Ref], ) -> EngineResult<Vec<LayoutBox>>
Compute layout boxes for
refs at page.Source§fn download(
&mut self,
page: PageHandle,
source: DownloadSource,
budget: Duration,
) -> EngineResult<Download>
fn download( &mut self, page: PageHandle, source: DownloadSource, budget: Duration, ) -> EngineResult<Download>
Read a file out of
page — either a URL fetched with the page’s
credentials, or a download the page itself initiated and the
capture shim parked. Returns the bytes; the daemon owns where
they land on disk. Read moreSource§fn download_list(
&mut self,
page: PageHandle,
) -> EngineResult<Vec<DownloadEntry>>
fn download_list( &mut self, page: PageHandle, ) -> EngineResult<Vec<DownloadEntry>>
List the download intents the shim has captured on
page,
payloads excluded.Source§fn set_viewport(
&mut self,
page: PageHandle,
viewport: Viewport,
) -> EngineResult<()>
fn set_viewport( &mut self, page: PageHandle, viewport: Viewport, ) -> EngineResult<()>
Set the viewport at
page. Triggers a re-baseline for the next
snapshot.Source§fn capture(
&mut self,
page: PageHandle,
_scope: CaptureScope,
) -> EngineResult<PathBuf>
fn capture( &mut self, page: PageHandle, _scope: CaptureScope, ) -> EngineResult<PathBuf>
Take a screenshot. Returns the path on disk where the image was
written.
Source§fn crash(&mut self, page: PageHandle) -> EngineResult<()>
fn crash(&mut self, page: PageHandle) -> EngineResult<()>
Kill
page’s web content process, to test crash handling.Source§fn drop_data(
&mut self,
page: PageHandle,
x: f64,
y: f64,
data: &DropData,
) -> EngineResult<bool>
fn drop_data( &mut self, page: PageHandle, x: f64, y: f64, data: &DropData, ) -> EngineResult<bool>
Drop
data onto page at view point (x, y) as a native drag
from another application: the page sees trusted dragenter,
dragover and, when its dragover accepts, drop (otherwise
dragleave). Returns whether the drop was accepted.Source§fn set_zoom(&mut self, page: PageHandle, zoom: f64) -> EngineResult<()>
fn set_zoom(&mut self, page: PageHandle, zoom: f64) -> EngineResult<()>
Page zoom: CSS px are drawn
zoom view px wide, so the page lays
out view width / zoom CSS px wide (a mobile layout viewport,
fit to the screen). 1.0 is normal.Read, add to or empty the cookie jar
page uses (its data
store: every page of an isolated session shares it), HttpOnly
cookies included. Returns the jar after the change.Source§fn save_auth(&mut self, page: PageHandle) -> EngineResult<AuthBlob>
fn save_auth(&mut self, page: PageHandle) -> EngineResult<AuthBlob>
Snapshot cookies/storage for
page as an opaque AuthBlob.Source§fn load_auth(&mut self, page: PageHandle, blob: &AuthBlob) -> EngineResult<()>
fn load_auth(&mut self, page: PageHandle, blob: &AuthBlob) -> EngineResult<()>
Apply a previously saved
AuthBlob to page.Source§fn console_entries(
&mut self,
page: PageHandle,
) -> EngineResult<Vec<ConsoleEntry>>
fn console_entries( &mut self, page: PageHandle, ) -> EngineResult<Vec<ConsoleEntry>>
Snapshot the always-captured console ring buffer for
page.
Default impl returns empty (engines without console capture).Source§fn network_entries(
&mut self,
page: PageHandle,
) -> EngineResult<Vec<NetworkEntry>>
fn network_entries( &mut self, page: PageHandle, ) -> EngineResult<Vec<NetworkEntry>>
Snapshot the always-captured network ring buffer for
page.
Default impl returns empty (engines without network capture).Source§fn request_detail(
&mut self,
page: PageHandle,
seq: u64,
) -> EngineResult<Option<RequestDetail>>
fn request_detail( &mut self, page: PageHandle, seq: u64, ) -> EngineResult<Option<RequestDetail>>
Look up the full detail (headers + bodies) for a single
captured network request. Returns
None if the seq isn’t in
the buffer. Default impl returns None.Source§fn eval_js(&mut self, page: PageHandle, expr: &str) -> EngineResult<EvalResult>
fn eval_js(&mut self, page: PageHandle, expr: &str) -> EngineResult<EvalResult>
Evaluate
expr in main world. Default impl returns
EvalResult::Thrown { kind: "NotImplemented", ... }.Source§fn storage(
&mut self,
page: PageHandle,
scope: StorageScope,
) -> EngineResult<Vec<StorageEntry>>
fn storage( &mut self, page: PageHandle, scope: StorageScope, ) -> EngineResult<Vec<StorageEntry>>
List storage entries for the requested scope.
Source§fn scripts(&mut self, page: PageHandle) -> EngineResult<Vec<ScriptEntry>>
fn scripts(&mut self, page: PageHandle) -> EngineResult<Vec<ScriptEntry>>
List scripts loaded by the page.
Source§fn script_source(
&mut self,
page: PageHandle,
seq: u64,
) -> EngineResult<Option<ScriptSource>>
fn script_source( &mut self, page: PageHandle, seq: u64, ) -> EngineResult<Option<ScriptSource>>
Source of one script by
seq. Returns None if the seq isn’t
in the script registry.Source§fn dom(
&mut self,
page: PageHandle,
r: Ref,
extra_props: &[String],
) -> EngineResult<Option<DomDetail>>
fn dom( &mut self, page: PageHandle, r: Ref, extra_props: &[String], ) -> EngineResult<Option<DomDetail>>
Outer HTML + computed styles for a ref. Caller-requested
computed properties land in
extra_props; the engine merges
them with its default property set. Returns None for unknown
refs.Source§fn performance(&mut self, page: PageHandle) -> EngineResult<PerformanceMetrics>
fn performance(&mut self, page: PageHandle) -> EngineResult<PerformanceMetrics>
Web Vitals + heap + DOM stats. Returns zero-filled defaults if
the engine can’t measure them.
Source§fn main_response(
&mut self,
page: PageHandle,
) -> EngineResult<Option<MainResponse>>
fn main_response( &mut self, page: PageHandle, ) -> EngineResult<Option<MainResponse>>
HTTP response of the latest main-frame navigation.
None when
the engine has not recorded one (non-HTTP load, failed load,
engine without support).List cookie store ADD/REMOVE events observed since the page
opened. Engines without a cookie-changed observer (Windows, the
stub) return an empty vec or
ENGINE_UNSUPPORTED via their
capability flag.Source§fn type_text(
&mut self,
page: PageHandle,
text: &str,
mode: InputMode,
) -> EngineResult<()>
fn type_text( &mut self, page: PageHandle, text: &str, mode: InputMode, ) -> EngineResult<()>
Trusted keyboard typing into the focused element. Sends real
per-character key events (KeyDown/KeyUp) so the page sees
isTrusted=true keydown → beforeinput → input, which
rich-text editors (DraftJS/ProseMirror/contenteditable) and
framework-controlled inputs require — the prototype-setter
fill path bypasses their change pipeline. The caller places
the caret first (e.g. vs_click_at). Backends without native
keyboard dispatch fall through to ENGINE_UNSUPPORTED.Source§fn cursor_op(
&mut self,
page: PageHandle,
op: CursorOp,
mode: InputMode,
) -> EngineResult<()>
fn cursor_op( &mut self, page: PageHandle, op: CursorOp, mode: InputMode, ) -> EngineResult<()>
Coordinate-addressed cursor operation. Backends that don’t
implement native input dispatch fall through to the default
ENGINE_UNSUPPORTED here; agents see ! ENGINE_UNSUPPORTED
on the wire and can switch to ref-based vs act instead.Source§fn set_popups(&mut self, page: PageHandle, on: bool) -> EngineResult<()>
fn set_popups(&mut self, page: PageHandle, on: bool) -> EngineResult<()>
Give
page real popup windows: a target="_blank" link or
form, or window.open(), opens a new engine page with an
opener, instead of loading in page. Popups of a popup
inherit the setting. Engines without support keep loading in
place.Source§fn eval_js_in_frame(
&mut self,
page: PageHandle,
frame: &str,
expr: &str,
) -> EngineResult<EvalResult>
fn eval_js_in_frame( &mut self, page: PageHandle, frame: &str, expr: &str, ) -> EngineResult<EvalResult>
Self::eval_js in one subframe of page, including a
cross-origin one the page’s own script cannot reach. frame is
the frame’s URL (the newest frame with it wins), or #N for the
Nth subframe, newest first.Source§fn popup_feed(&mut self) -> Option<Arc<PopupFeed>>
fn popup_feed(&mut self) -> Option<Arc<PopupFeed>>
Where pages with real popups report windows they open and
pages that close themselves. Readable from any thread, so the
daemon learns of a popup without waiting for the engine thread,
which may be busy with the click that opened it. The engine
handle in an event is usable at once.
Source§fn capabilities(&self) -> EngineCapabilities
fn capabilities(&self) -> EngineCapabilities
Capabilities the daemon should advertise for this engine.
Source§fn capture_live(
&mut self,
page: PageHandle,
_max_width: u32,
) -> EngineResult<PathBuf>
fn capture_live( &mut self, page: PageHandle, _max_width: u32, ) -> EngineResult<PathBuf>
Capture a live frame (watch / record) at a reduced width
(
max_width px, 0 = full resolution). Cheaper to produce and
encode than a full-resolution screenshot. The default delegates
to Self::capture; backends that can render a smaller snapshot
override it.Source§fn record_begin(
&mut self,
_page: PageHandle,
_tx: Sender<RecFrame>,
_fps: u32,
_max_width: u32,
) -> EngineResult<()>
fn record_begin( &mut self, _page: PageHandle, _tx: Sender<RecFrame>, _fps: u32, _max_width: u32, ) -> EngineResult<()>
Begin streaming recording frames for
page. While active, the
backend captures a frame at each input step (mouse move,
keystroke, click) and sends it on tx with the cursor position,
so the recorder composites a pointer and encodes smooth motion
without a poller racing the automation. max_width downscales
each frame (0 = full resolution). The default is unsupported so
the daemon can fall back to time-based polling.Source§fn record_end(&mut self, _page: PageHandle) -> EngineResult<()>
fn record_end(&mut self, _page: PageHandle) -> EngineResult<()>
Stop streaming recording frames for
page (drops the sender so
the recorder’s drain loop ends). Idempotent.Auto Trait Implementations§
impl !RefUnwindSafe for WpeBackend
impl !Send for WpeBackend
impl !Sync for WpeBackend
impl !UnwindSafe for WpeBackend
impl Forget for WpeBackend
impl Freeze for WpeBackend
impl Move for WpeBackend
impl Unpin for WpeBackend
impl UnsafeUnpin for WpeBackend
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
Mutably borrows from an owned value. Read more