Sign in

    mizchi/crater-webdriver-bidi/webdriver does not have a README file

    BidiServer

    pub struct BidiServer {
    config : BidiServerConfig
    server :
    Any
    ?
    // private fields
    }

    BiDi server state

    BidiServer::new

    fn BidiServer::new(config? : BidiServerConfig) -> BidiServer

    Create new BiDi server

    BidiServer::start

    fn BidiServer::start(self : BidiServer) -> Unit

    Start the BiDi server using Deno.serve

    BidiServer::stop

    fn BidiServer::stop(self : BidiServer) -> Unit

    Stop the server

    BidiServerConfig

    pub(all) struct BidiServerConfig {
    host : String
    port : Int
    auth_token : String
    }

    BiDi server configuration

    BidiServerConfig::default

    Default configuration (generates a random auth token)

    BidiServerConfig::web_socket_url

    fn BidiServerConfig::web_socket_url(self : BidiServerConfig) -> String

    CdpHandlerError

    pub enum CdpHandlerError {
    NoSuchElement(selector~ : String)
    InvalidSelector(selector~ : String)
    NavigationFailed(url~ : String, reason~ : String)
    InternalCdpError(message~ : String)
    } derive(
    Debug
    )

    CDP Handler errors

    CdpHandlerError::to_w3c_error

    fn CdpHandlerError::to_w3c_error(self : CdpHandlerError) -> (String, String)

    Convert CdpHandlerError to W3C error format

    CdpSessionManager

    pub struct CdpSessionManager {
    sessions : Map[String,
    CdpSession
    ]
    next_id : Int
    }

    Manages CDP sessions for WebDriver

    CdpSessionManager::close_session

    fn CdpSessionManager::close_session(self : CdpSessionManager, session_id : String) -> Bool

    Close a session

    CdpSessionManager::create_session

    fn CdpSessionManager::create_session(self : CdpSessionManager) -> String

    Create a new CDP session

    CdpSessionManager::create_session_with_id

    fn CdpSessionManager::create_session_with_id(self : CdpSessionManager, session_id : String) -> String

    Recreate a CDP session with a caller-provided session id.

    CdpSessionManager::get_session

    Get a session by ID

    CdpSessionManager::has_session

    fn CdpSessionManager::has_session(self : CdpSessionManager, session_id : String) -> Bool

    Check if a session exists

    CdpSessionManager::list_sessions

    fn CdpSessionManager::list_sessions(self : CdpSessionManager) -> Array[String]

    List all session IDs

    CdpSessionManager::new

    Create a new CDP session manager

    Executor

    pub struct Executor {
    manager : CdpSessionManager
    logging_enabled : Bool
    operation_log : Array[String]
    }

    Execution context with logging and state management

    Executor::clear_log

    fn Executor::clear_log(self : Executor) -> Unit

    Clear operation log

    Executor::close_context

    fn Executor::close_context(self : Executor, context_id : String) ->
    ApiResult
    [String]

    Close a browser context

    Executor::content

    fn Executor::content(self : Executor, page_id : String) ->
    ApiResult
    [String]

    Get page content

    Executor::disable_logging

    fn Executor::disable_logging(self : Executor) -> Unit

    Disable operation logging

    Executor::enable_logging

    fn Executor::enable_logging(self : Executor) -> Unit

    Enable operation logging

    Executor::execute

    Execute an API method and return result This is THE central entry point for all browser operations.

    Executor::execute_json

    fn Executor::execute_json(self : Executor, json : String) -> String

    Execute from JSON-RPC request string

    Executor::get_log

    fn Executor::get_log(self : Executor) -> Array[String]

    Get operation log

    Executor::go_back

    fn Executor::go_back(self : Executor, page_id : String) ->
    ApiResult
    [String]

    Go back in history

    Executor::go_forward

    fn Executor::go_forward(self : Executor, page_id : String) ->
    ApiResult
    [String]

    Go forward in history

    Executor::goto

    fn Executor::goto(self : Executor, page_id : String, url : String) ->
    ApiResult
    [String]

    Navigate to URL

    Executor::new

    fn Executor::new() -> Executor

    Create a new executor

    Executor::new_context

    Create a new browser context

    Executor::new_with_viewport

    fn Executor::new_with_viewport(_width : Int, _height : Int) -> Executor

    Create executor with custom viewport (viewport info stored but not used in pure protocol mode)

    Executor::reload

    fn Executor::reload(self : Executor, page_id : String) ->
    ApiResult
    [String]

    Reload page

    Executor::screenshot

    fn Executor::screenshot(self : Executor, page_id : String) ->
    ApiResult
    [String]

    Get screenshot (DOM tree as text in pure protocol mode)

    Executor::title

    fn Executor::title(self : Executor, page_id : String) ->
    ApiResult
    [String]

    Get page title

    Executor::url

    Get current URL

    await_promise

    fn await_promise(promise :
    Any
    ) -> String

    Await a Promise and return result as String

    decode_base64

    fn decode_base64(base64 : String) -> String

    Decode base64 string

    delete_runtime_handle

    fn delete_runtime_handle(handle_id : String) -> Unit

    Remove handle from current JS handle store (no-op when absent).

    error_text_of

    fn error_text_of(e :
    HttpError
    ) -> String

    Map an @http.HttpError into the BiDi errorText string that network.fetchError / network.responseCompleted payloads expose to the driver.

    The two CORS variants get distinguishing prefixes so a Playwright / WebDriver client can tell a preflight rejection apart from the actual request being blocked:

    • CorsBlocked(reason) -> "CORS: <reason>"
    • PreflightFailed(reason) -> "CORS preflight: <reason>"

    Existing variants retain their Show form so legacy callers see the same errorText as before.

    Reason strings from CorsBlocked, PreflightFailed, and CorsError are sanitized via sanitize_for_log before interpolation to prevent log injection from malicious server-controlled values.

    eval_and_send_async

    fn eval_and_send_async(socket :
    Any
    , request_id : Int, expression : String, ctx_id : String) -> Unit

    Evaluate expression asynchronously and send result via WebSocket

    evaluate_js

    fn evaluate_js(expression : String) -> String

    Evaluate JavaScript expression and return result as JSON (sync)

    evaluate_js_async

    fn evaluate_js_async(expression : String) ->
    Any

    Evaluate JavaScript expression asynchronously (awaits Promise if awaitPromise=true) Returns a Promise (@core.Any) that resolves to JSON string

    generate_auth_token

    fn generate_auth_token() -> String

    get_runtime_anchor_download_attr_by_id

    fn get_runtime_anchor_download_attr_by_id(anchor_id : String) -> String?

    Resolve download attribute value from an anchor identified by id or global symbol.

    get_runtime_anchor_href_by_id

    fn get_runtime_anchor_href_by_id(anchor_id : String) -> String?

    Resolve absolute href from an anchor identified by id or global symbol.

    get_runtime_href_at_point

    fn get_runtime_href_at_point(x : Double, y : Double) -> String?

    Resolve href from element under viewport coordinates.

    get_runtime_iframe_sources

    fn get_runtime_iframe_sources() -> Array[String]

    Collect iframe src values from runtime document.

    get_runtime_inline_navigation_url

    fn get_runtime_inline_navigation_url(attribute_name : String) -> String?

    Resolve data/absolute URL assigned by inline event handlers like onkeydown/onmousedown.

    get_runtime_last_click_href

    fn get_runtime_last_click_href() -> String?

    Resolve href from the most recent synthetic click target.

    get_runtime_shared_node_at_point

    fn get_runtime_shared_node_at_point(x : Double, y : Double) -> String?

    Resolve shared node at viewport point, allocating sharedId if needed.

    get_runtime_shared_node_center_json

    fn get_runtime_shared_node_center_json(shared_id : String) -> String

    Get center coordinate of shared element as JSON string.

    get_runtime_shared_node_href

    fn get_runtime_shared_node_href(shared_id : String) -> String?

    Resolve href attribute from a shared element node.

    get_runtime_url_query_param

    fn get_runtime_url_query_param(url : String, key : String) -> String?

    Extract query parameter value from an URL string.

    handle_element_click

    fn handle_element_click(session :
    CdpSession
    , element_id : Int) -> Result[Unit, CdpHandlerError]

    Handle element click via CDP

    handle_find_element

    fn handle_find_element(session :
    CdpSession
    , strategy : String, value : String) -> Result[Int, CdpHandlerError]

    Handle findElement via CDP

    handle_find_elements

    fn handle_find_elements(session :
    CdpSession
    , strategy : String, value : String) -> Result[Array[Int], CdpHandlerError]

    Handle findElements via CDP

    handle_get_current_url

    fn handle_get_current_url(session :
    CdpSession
    ) -> String

    Handle getCurrentUrl via CDP

    handle_get_element_attribute

    fn handle_get_element_attribute(session :
    CdpSession
    , element_id : Int, name : String) -> Result[String?, CdpHandlerError]

    Handle getElementAttribute via CDP

    handle_get_element_tag_name

    fn handle_get_element_tag_name(session :
    CdpSession
    , element_id : Int) -> Result[String, CdpHandlerError]

    Handle getElementTagName via CDP

    handle_get_element_text

    fn handle_get_element_text(session :
    CdpSession
    , element_id : Int) -> Result[String, CdpHandlerError]

    Handle getElementText via CDP

    handle_get_title

    fn handle_get_title(session :
    CdpSession
    ) -> String

    Handle getTitle via CDP

    handle_navigate

    fn handle_navigate(session :
    CdpSession
    , url : String) -> Result[Unit, CdpHandlerError]

    Handle navigation via CDP

    handle_rpc

    Handle an RPC request and return a response This is the main entry point for processing JSON-RPC requests

    has_runtime_handle

    fn has_runtime_handle(handle_id : String) -> Bool

    Check if runtime handle exists in current JS handle store.

    has_runtime_shared_node

    fn has_runtime_shared_node(shared_id : String) -> Bool

    Check if runtime shared node exists in current JS shared node store.

    input_clear_drag_transfer

    fn input_clear_drag_transfer(drag_transfer_id : String) -> Unit

    input_clear_pointer_event_properties

    fn input_clear_pointer_event_properties() -> Unit

    Clear synthetic pointer event property overrides.

    input_dispatch_drag_event

    fn input_dispatch_drag_event(shared_id : String, event_type : String, x : Double, y : Double, button : Int, buttons : Int, pointer_type : String, ctrl : Bool, alt : Bool, shift : Bool, meta : Bool, related_shared_id : String, drag_transfer_id : String) -> Bool

    input_dispatch_key_action

    fn input_dispatch_key_action(action_type : String, raw_value : String, ctrl : Bool, alt : Bool, shift : Bool, meta : Bool) -> Unit

    Dispatch synthetic keyboard event and keep allEvents in sync for WPT pages.

    input_dispatch_pointer_event

    fn input_dispatch_pointer_event(shared_id : String, event_type : String, x : Double, y : Double, button : Int, buttons : Int, pointer_type : String, ctrl : Bool, alt : Bool, shift : Bool, meta : Bool) -> Unit

    Dispatch synthetic pointer/mouse event.
    fn input_dispatch_pointer_event_with_related(shared_id : String, event_type : String, x : Double, y : Double, button : Int, buttons : Int, pointer_type : String, ctrl : Bool, alt : Bool, shift : Bool, meta : Bool, related_shared_id : String) -> Unit

    input_dispatch_wheel_event

    fn input_dispatch_wheel_event(shared_id : String, x : Double, y : Double, delta_x : Double, delta_y : Double, ctrl : Bool, alt : Bool, shift : Bool, meta : Bool) -> Unit

    Dispatch synthetic wheel event.

    input_drag_transfer_state

    fn input_drag_transfer_state(drag_transfer_id : String) -> String

    input_is_mac_platform

    fn input_is_mac_platform() -> Bool

    Detect whether current runtime should emulate macOS pointer conventions.

    input_is_single_grapheme

    fn input_is_single_grapheme(value : String) -> Bool

    Check whether string contains exactly one grapheme cluster.

    input_now_ms

    fn input_now_ms() -> Double

    Current wall-clock timestamp in milliseconds.

    input_set_pointer_event_properties

    fn input_set_pointer_event_properties(width : Double, height : Double, pressure : Double, tangential_pressure : Double, twist : Double, altitude_angle : Double, azimuth_angle : Double) -> Unit

    Set synthetic pointer event property overrides used by pointer dispatch.

    js_push_synthetic_navigation

    fn js_push_synthetic_navigation(url : String) -> Unit

    Push a synthetic-navigation marker onto the JS realm so the adapter's flushPendingNavigation can mirror it onto currentUrl on the next script.evaluate boundary. Used by server-side pointer-click navigation (input.performActions path), where the in-realm shim click() default action doesn't run. (#208)

    js_set_runtime_context_authorization

    fn js_set_runtime_context_authorization(ctx_id : String, auth_json : String) -> Unit

    Push the per-context Authorization snapshot into the JS realm. The snapshot is consumed by the auto-installed globalThis.__bidiResolveAuth helper that the fetch shim calls before dispatching each outbound request. Mirror of set_runtime_context_cookies.

    js_set_runtime_context_credentials

    fn js_set_runtime_context_credentials(ctx_id : String, creds_json : String) -> Unit

    Push the per-context Digest credentials snapshot into the JS realm. The snapshot shape is { origin: { username, password } }. Consumed by the fetch shim's 401 Digest auto-retry path via the auto-installed globalThis.__bidiResolveCredentials(url) helper.

    Credentials are passed by-value into the JS realm — there is no indirection that would let the page read them ambient-style. The runtime-side helper only returns the matching entry for the request's origin AND only inside the retry path that already has a Digest challenge in hand, so an attacker page on a different origin can't silently extract a stored credential by issuing fetches.

    js_set_runtime_prompt_handlers

    fn js_set_runtime_prompt_handlers(handlers_json : String) -> Unit

    Push the per-context unhandledPromptBehavior snapshot into the JS realm. Read by resolvePromptHandler inside alert/confirm/prompt to decide the synchronous return value. Snapshot shape mirrors the spec dictionary: { alert: "dismiss", confirm: "accept", prompt: "dismiss",default: "dismiss" }. Missing entries default to "dismiss".
    fn navigate_and_send_async(socket :
    Any
    , request_id : Int, ctx_id : String, url : String, navigation_id : String) -> Unit

    MoonBit wrapper around js_navigate_and_send_async. Used by the navigate dispatch when wait=complete is requested for an http(s) URL — instead of the broken sync sync_runtime_page() path, the JS body awaits the page load and emits the BiDi response via socket once the load resolves.

    parse_data_url

    fn parse_data_url(url : String) -> (String, String)?

    Parse data URL and return decoded content Returns (content_type, content) or None if invalid

    parse_method

    reset_paint_provider

    fn reset_paint_provider() -> Unit

    Reset paint provider state on new WebSocket session. Must be called when JS runtime is reset to avoid stale glyph provider.

    reset_runtime_event_buffers

    fn reset_runtime_event_buffers(ctx_id : String) -> Unit

    Reset runtime event buffers/listeners for a specific context.

    runtime_shared_node_is_document

    fn runtime_shared_node_is_document(shared_id : String) -> Bool

    Check if runtime shared node exists and is a document node.

    runtime_shared_node_is_draggable

    fn runtime_shared_node_is_draggable(shared_id : String) -> Bool

    Check if runtime shared node has draggable attribute enabled.

    runtime_shared_node_is_element

    fn runtime_shared_node_is_element(shared_id : String) -> Bool

    Check if runtime shared node exists and is an element node.

    runtime_shared_node_is_shadow_root

    fn runtime_shared_node_is_shadow_root(shared_id : String) -> Bool

    Check if runtime shared node exists and is a shadow root node.

    runtime_write_text_file

    fn runtime_write_text_file(path : String, content : String) -> Unit

    Write UTF-8 text file for synthetic download tests.

    set_runtime_context

    fn set_runtime_context(ctx_id : String) -> Unit

    Set current BiDi context for value serialization helpers.

    set_runtime_context_frames

    fn set_runtime_context_frames(ctx_id : String, frame_ctx_ids : Array[String]) -> Unit

    Set frame window contexts for current runtime context.

    set_runtime_context_locale

    fn set_runtime_context_locale(ctx_id : String, locale : String) -> Unit

    Set runtime navigator.language(s) for a specific context.

    set_runtime_context_network_online

    fn set_runtime_context_network_online(ctx_id : String, is_online : Bool) -> Unit

    set_runtime_context_screen_area

    fn set_runtime_context_screen_area(ctx_id : String, width : Int, height : Int, avail_width : Int, avail_height : Int) -> Unit

    set_runtime_context_screen_orientation

    fn set_runtime_context_screen_orientation(ctx_id : String, orientation_type : String, angle : Int) -> Unit

    set_runtime_context_user_agent

    fn set_runtime_context_user_agent(ctx_id : String, user_agent : String) -> Unit

    Set runtime navigator.userAgent for a specific context.

    set_runtime_context_viewport

    fn set_runtime_context_viewport(ctx_id : String, width : Int, height : Int, device_pixel_ratio : Double) -> Unit

    Set runtime viewport metrics for a specific context.

    sync_runtime_html

    fn sync_runtime_html(html : String, base_url : String, execute_scripts : Bool) -> Unit

    Synchronize HTML content into the JS runtime document.

    sync_runtime_page

    fn sync_runtime_page(url : String) -> Unit

    Synchronize runtime page by URL.

    take_channel_messages_json

    fn take_channel_messages_json() -> String

    Drain queued script channel callback payloads as JSON.

    warmup_glyph_cache

    fn warmup_glyph_cache() -> Unit

    Pre-rasterize common ASCII glyphs. Initializes providers if needed.

    Source Files