FakeCdpServer class

In-process fake CDP endpoint for tests: serves /json/version, /json/list, and a page-level debugger WebSocket that answers the domains universal_browser_cdp uses.

Canned state is mutable so tests can script the world: axNodes feeds Accessibility.getFullAXTree, evaluateValue is returned verbatim from Runtime.evaluate, and autoScreencast makes Page.startScreencast emit periodic Page.screencastFrame events. Everything the client sends is recorded in methods, inputEvents, and screencastAcks.

Constructors

FakeCdpServer()

Properties

autoScreencast ↔ bool
Whether Page.startScreencast starts the frame-emission timer.
getter/setter pair
axNodes ↔ List<Map<String, Object?>>
Accessibility.getFullAXTree node list (CDP shape).
getter/setter pair
callFunctionOnValue ↔ String?
Value returned by Runtime.callFunctionOn (defaults to evaluateValue).
getter/setter pair
createdTargets → List<String>
Target ids created via Target.createTarget.
final
currentUrl ↔ String
about:blank initially; updated by Page.navigate.
getter/setter pair
emitLifecycleEvents ↔ bool
Whether Page.navigate also emits Page.domContentEventFired and Page.loadEventFired (default true; tests gate it to script slow-loading pages).
getter/setter pair
evaluateException ↔ String?
When set, Runtime.evaluate answers with exceptionDetails whose exception description carries this text — the JS-rejection path (CdpPage.evaluateAsync surfaces it).
getter/setter pair
evaluateHandler ↔ Object? Function(String expression)?
When set, answers Runtime.evaluate instead of evaluateValue; a null result falls back to the default. Tests use this to script hit-target failures, viewport payloads, and window.__mcpActions registries. Returned values reach the driver exactly as returned — real CDP returnByValue semantics.
getter/setter pair
evaluateValue ↔ String
Value returned verbatim by Runtime.evaluate (default: the canned element rect JSON with a passing hit-target check, so clicks resolve).
getter/setter pair
failNextWithError ↔ Map<String, Object?>?
When set, the next request is answered with this error payload.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
httpBase → Uri
HTTP base of the running fake.
no setter
inputEvents → List<Map<String, Object?>>
Recorded Input.* params, prefixed with the method name.
final
methods → List<String>
Received method names, in order.
final
When set, Page.navigate answers with this errorText and emits no Page.frameNavigated — CDP's real navigation-failure shape.
getter/setter pair
networkResponseBody ↔ String
Value returned by Network.getResponseBody (plain text).
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
screencastAcks → List<Map<String, Object?>>
Recorded Page.screencastFrameAck params.
final
screencastActive ↔ bool
Whether the fake is currently screencasting (set by the client).
getter/setter pair
screencastFrameBase64 ↔ String
JPEG payload per emitted screencast frame (4-byte SOI/EOI).
getter/setter pair
screencastFramesEmitted ↔ int
How many Page.screencastFrame events were emitted.
getter/setter pair
screenshotBase64 ↔ String
Payload returned by Page.captureScreenshot.
getter/setter pair
sessions → List<String>
Session ids created via Target.attachToTarget.
final
wsPageUri → Uri
Page-level debugger WebSocket URL.
no setter

Methods

emit(String method, Map<String, Object?> params) → void
Pushes an event to every connected debugger socket.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
start() → Future<Uri>
Starts the HTTP + WebSocket server on an ephemeral loopback port.
stop() → Future<void>
Stops the server and every open socket.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited