bidi

package
v0.0.0-...-cdcaf16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package bidi is a minimal WebDriver BiDi client over WebSocket.

It exists for one thing classic WebDriver cannot express: answering a proxy authentication challenge on Firefox. The HTTP auth dialog is a real window prompt (nsIPrompt_promptUsernameAndPassword), and Get Alert Text answers "no such alert" for it, so the navigation simply times out. BiDi exposes the challenge as an event and lets us supply credentials — the same job server/browser/cdpauth does over CDP for the two Chromium backends.

Only the handful of commands that job needs are implemented; this is not a general BiDi client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallProxyAuth

func InstallProxyAuth(ctx context.Context, s *Session, username, password string, logger browserpkg.Logger) error

InstallProxyAuth answers proxy authentication challenges with the given credentials for the lifetime of the session.

The addIntercept call is not optional and not merely an optimisation: without an intercept registered for the authRequired phase the event still fires, but the request is never held, and continueWithAuth then fails with "no such request". Verified against a proxy requiring Basic auth on Firefox 153 and on camoufox (Firefox 135).

Types

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is a live BiDi connection. It is safe for concurrent use.

func Dial

func Dial(ctx context.Context, wsURL string) (*Session, error)

Dial connects to the WebSocket URL geckodriver reports as the webSocketUrl capability.

func (*Session) Close

func (s *Session) Close() error

Close shuts the connection down. Safe to call more than once.

func (*Session) On

func (s *Session) On(event string, fn func(params json.RawMessage))

On registers a handler for a BiDi event. Handlers run on their own goroutine: answering an event usually means sending a command, and doing that from the read loop would deadlock waiting for a reply only that loop can deliver.

func (*Session) Send

func (s *Session) Send(ctx context.Context, method string, params any) (json.RawMessage, error)

Send issues a command and waits for its reply.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址