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 (*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.