cdptest

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package cdptest starts a local headless Chrome with its DevTools endpoint open, for tests that exercise the remote-browser sign-in against a real browser. It is test support only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChromePath

func ChromePath() string

ChromePath returns a Chrome/Chromium binary found on PATH, or "".

func StartChrome

func StartChrome(t testing.TB) (wsURL string, kill func())

StartChrome starts a headless Chrome listening for DevTools connections on a free local port and returns its browser WebSocket URL and a function that kills it. The test is skipped when no browser is installed, in -short mode, or when the browser does not come up. The browser is killed when the test ends.

Types

type LossyProxy

type LossyProxy struct {
	// URL is the proxy's ws:// endpoint.
	URL string
	// contains filtered or unexported fields
}

LossyProxy is a DevTools WebSocket proxy in front of a real browser that forwards everything except the replies to the commands chosen by drop: the browser executes those commands, and the client never hears back. It is how a test loses the answer to one specific command.

func NewLossyProxy

func NewLossyProxy(t testing.TB, upstream string, drop func(method string, params json.RawMessage) bool) *LossyProxy

NewLossyProxy starts a proxy to the browser at upstream (its ws:// URL). drop is called for every command the client sends; when it returns true, the reply to that command is not passed back.

func (*LossyProxy) Dropped

func (p *LossyProxy) Dropped() int

Dropped returns how many replies have been withheld so far.

Jump to

Keyboard shortcuts

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