bridge

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 60 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionClick          = "click"
	ActionDoubleClick    = "dblclick"
	ActionType           = "type"
	ActionFill           = "fill"
	ActionPress          = "press"
	ActionFocus          = "focus"
	ActionHover          = "hover"
	ActionSelect         = "select"
	ActionScroll         = "scroll"
	ActionMouseMove      = "mouse-move"
	ActionMouseDown      = "mouse-down"
	ActionMouseUp        = "mouse-up"
	ActionMouseWheel     = "mouse-wheel"
	ActionDrag           = "drag"
	ActionCheck          = "check"
	ActionUncheck        = "uncheck"
	ActionKeyboardType   = "keyboard-type"
	ActionKeyboardInsert = "keyboard-inserttext"
	ActionKeyDown        = "keydown"
	ActionKeyUp          = "keyup"
	ActionScrollIntoView = "scrollintoview"
)
View Source
const (
	WaitNone   = "none"
	WaitLoad   = "load"
	WaitStable = "stable"
)
View Source
const (
	DefaultNetworkBufferSize = bridgeobserve.DefaultNetworkBufferSize
	FilterInteractive        = bridgeobserve.FilterInteractive
)
View Source
const (
	ScreenshotFormatJpeg = page.CaptureScreenshotFormatJpeg
	ScreenshotFormatPng  = page.CaptureScreenshotFormatPng
)
View Source
const (
	MinScale = 0.05
	MaxScale = 4.0
)

MinScale / MaxScale bound the bitmap rescale factor. Anything outside is almost certainly a mistake or a DoS — 50× would ask the renderer for a multi-gigapixel image.

View Source
const DefaultLockTimeout = bridgetabs.DefaultLockTimeout
View Source
const DisableAnimationsCSS = `` /* 406-byte string literal not displayed */

DisableAnimationsCSS is injected to force-disable all CSS animations and transitions.

View Source
const KeepAllQuarantinedProfiles = 0
View Source
const MaxFulfillBodyBytes = 1 << 20 // 1 MiB

MaxFulfillBodyBytes caps the size of a fulfill rule's response body. The HTTP handler enforces this for early 400s; AddRule re-checks so non-HTTP callers (direct bridge users, future ipc) also benefit.

View Source
const MaxRulesPerTab = 100

MaxRulesPerTab caps how many interception rules a single tab may carry. Without a cap an attacker (or runaway agent) could install thousands of rules to consume memory and slow every paused request through a long per-event match loop. The number is generous for legitimate use — typical fixtures have a few rules — and conservative against abuse.

View Source
const TargetTypePage = bridgecdpops.TargetTypePage

Variables

View Source
var (
	ImageBlockPatterns  = bridgecdpops.ImageBlockPatterns
	MediaBlockPatterns  = bridgecdpops.MediaBlockPatterns
	ErrTooManyRedirects = bridgecdpops.ErrTooManyRedirects
	ErrElementOccluded  = bridgecdpops.ErrElementOccluded
	ErrElementHidden    = bridgecdpops.ErrElementHidden
	ErrElementBlocked   = bridgecdpops.ErrElementBlocked
	ErrElementOffscreen = bridgecdpops.ErrElementOffscreen
)
View Source
var (
	ErrDownloadTooLarge = errors.New("download response too large")
	ErrDownloadTimeout  = errors.New("download timed out")
)

Texts match the historical messages so anything still string-matching keeps working.

View Source
var (
	// ErrUnexpectedNavigation indicates an action was expected to keep context stable
	// but the page URL changed.
	ErrUnexpectedNavigation = errors.New("unexpected page navigation")
	// ErrElementStale indicates the targeted DOM/backend node is no longer valid.
	ErrElementStale         = errors.New("element reference is stale")
	ErrInvalidActionRequest = errors.New("invalid action request")
)
View Source
var (
	InteractiveRoles = bridgeobserve.InteractiveRoles
	ContextRoles     = bridgeobserve.ContextRoles
)
View Source
var AdBlockPatterns = []string{

	"*google-analytics.com/*",
	"*googletagmanager.com/*",
	"*googletagservices.com/*",
	"*googlesyndication.com/*",
	"*googleadservices.com/*",
	"*doubleclick.net/*",
	"*facebook.com/tr/*",
	"*facebook.com/plugins/*",
	"*connect.facebook.net/*",
	"*fbcdn.net/*/fbevents.js",
	"*twitter.com/i/adsct",
	"*analytics.twitter.com/*",
	"*static.ads-twitter.com/*",
	"*amazon-adsystem.com/*",
	"*amazontrust.com/*",
	"*adsafeprotected.com/*",
	"*segment.io/*",
	"*segment.com/*",
	"*mixpanel.com/*",
	"*amplitude.com/*",
	"*mxpnl.com/*",
	"*kissmetrics.com/*",
	"*hotjar.com/*",
	"*fullstory.com/*",
	"*heapanalytics.com/*",
	"*mouseflow.com/*",
	"*luckyorange.com/*",
	"*crazyegg.com/*",
	"*pingdom.net/*",
	"*newrelic.com/*",
	"*nr-data.net/*",

	"*doubleclick.net/*",
	"*googleadservices.com/*",
	"*googlesyndication.com/*",
	"*adnxs.com/*",
	"*adsymptotic.com/*",
	"*openx.net/*",
	"*pubmatic.com/*",
	"*rubiconproject.com/*",
	"*adsrvr.org/*",
	"*amazon-adsystem.com/*",
	"*media.net/*",
	"*adtech.de/*",
	"*adzerk.net/*",
	"*criteo.com/*",
	"*criteo.net/*",
	"*casalemedia.com/*",
	"*33across.com/*",
	"*taboola.com/*",
	"*outbrain.com/*",
	"*revcontent.com/*",
	"*zemanta.com/*",
	"*disqus.com/ads/*",

	"*marketo.com/*",
	"*marketo.net/*",
	"*hubspot.com/analytics/*",
	"*pardot.com/*",
	"*leadfeeder.com/*",
	"*clickcease.com/*",
	"*leadforensics.com/*",

	"*platform.twitter.com/widgets/*",
	"*platform.instagram.com/widgets/*",
	"*platform.linkedin.com/widgets/*",
	"*pinterest.com/js/pinit.js",

	"*scorecardresearch.com/*",
	"*quantserve.com/*",
	"*quantcount.com/*",
	"*parsely.com/*",
	"*chartbeat.com/*",
	"*omtrdc.net/*",
	"*optimizely.com/*",
	"*visualwebsiteoptimizer.com/*",
	"*demdex.net/*",
	"*bluekai.com/*",
	"*addthis.com/*",
	"*sharethis.com/*",

	"*cookielaw.org/*",
	"*cookiebot.com/*",
	"*onetrust.com/*",
	"*trustarc.com/*",
	"*usercentrics.com/*",

	"*pixel.gif*",
	"*tracking.gif*",
	"*analytics.gif*",
	"*/tr?*",
	"*/pixel?*",
	"*/collect?*",
}

AdBlockPatterns blocks ad, tracking, and analytics domains for cleaner snapshots

View Source
var BridgeShutdownGracePeriod = 5 * time.Second

Combined grace+term budget stays under docker stop's 10s default while giving Chromium's leveldb-backed Local Storage time to flush. var (not const) so tests can shrink them.

View Source
var ErrBrowserDraining = errors.New("browser restart in progress; retry shortly")
View Source
var ErrSelectorNoMatch = errors.New("selector matched no element")

ErrSelectorNoMatch marks a resolution failure where the selector was valid but matched no element (a client-side "not found"), as distinct from a CDP/transport fault, an unsupported selector kind, or an internal routing error — which must surface as 5xx, not 404. Callers classify with errors.Is.

View Source
var ErrSelectorOutsideScope = errors.New("selector target is outside scope")

ErrSelectorOutsideScope marks a cached ref that still exists but belongs to the background document rather than the active modal subtree. Callers must not treat this as a stale ref or invoke global semantic recovery.

View Source
var ErrTabNotRouted = errors.New("tab has no interception rules registered")

ErrTabNotRouted is returned by Remove when the tab has no rule state registered with the manager — distinct from "tab found, pattern matched nothing" which returns (0, nil). Callers can map this to a 404 to differentiate from a benign no-op removal.

View Source
var ErrTooManyRules = errors.New("too many interception rules on this tab")

ErrTooManyRules is returned by AddRule when a tab already holds MaxRulesPerTab rules and the incoming rule is not a same-pattern replace.

Functions

func AcquireProfileLock added in v0.8.0

func AcquireProfileLock(profileDir string) error

func AnnotateBounds added in v0.13.2

func AnnotateBounds(ctx context.Context, nodes []A11yNode, pageCoords bool, vp ViewportInfo) error

func BackendNodeWithinScope added in v0.15.1

func BackendNodeWithinScope(ctx context.Context, scopeBackendNodeID, targetBackendNodeID int64) (bool, error)

BackendNodeWithinScope reports whether target is the scope node or one of its DOM descendants. It is used to reject stale/background snapshot refs while a modal dialog owns the interaction surface.

func BrowserContextGeneration added in v0.15.1

func BrowserContextGeneration(ctx context.Context) uint64

BrowserContextGeneration numbers browser contexts: each context keeps its own generation for as long as it is tracked, and a context never seen before takes the next one. Crash state is process-global and shared across every instance the process drives, so a crash is only current when its generation matches the browser context the request is being served on — that is what keeps a replaced browser, or a different instance, from answering for someone else's death. Generations are keyed off the context itself rather than a counter the lifecycle paths maintain, so no launch/attach/remote-CDP site can forget to bump one.

func CanonicalActionKind added in v0.9.0

func CanonicalActionKind(kind string) string

func CaptureScreenshot added in v0.13.2

func CaptureScreenshot(ctx context.Context, opts ScreenshotOpts) ([]byte, error)

CaptureScreenshot runs Page.captureScreenshot with the supplied options. Quality is applied only for JPEG; clip and beyondViewport are mutually exclusive (clip wins) — the same rule the handler enforces on input.

When Scale is non-default (not 0 and not 1), the function ensures a clip is passed to CDP — either by reusing the supplied one with Scale multiplied in, or by synthesizing a viewport-covering clip from ViewportWidth/Height. CDP's top-level capture call has no scale parameter outside of clip, so this is the only way to apply a render-time rescale.

func ClampScale added in v0.13.2

func ClampScale(scale float64) float64

func CleanupOrphanedChromeProcesses added in v0.8.2

func CleanupOrphanedChromeProcesses(profileDir string)

Call on startup before launching Chrome.

func ClearChromeSessions

func ClearChromeSessions(profileDir string)

func Click added in v0.8.4

func Click(ctx context.Context, x, y float64) error

func ClickByCoordinate added in v0.8.2

func ClickByCoordinate(ctx context.Context, x, y float64, modifiers int) error

func ClickByNodeID

func ClickByNodeID(ctx context.Context, nodeID int64) error

func ClickElement added in v0.8.4

func ClickElement(ctx context.Context, backendNodeID cdp.BackendNodeID) error

The ID is the backendDOMNodeId from the accessibility tree, NOT a regular DOM nodeId.

func CombineBlockPatterns added in v0.7.7

func CombineBlockPatterns(patterns ...[]string) []string

CombineBlockPatterns merges multiple pattern lists

func CrashSnapshot added in v0.8.0

func CrashSnapshot() map[string]any

CrashSnapshot returns recent crash diagnostics for /health and /metrics.

func DefaultMaxParallel added in v0.7.8

func DefaultMaxParallel() int

func DisableAnimationsOnce

func DisableAnimationsOnce(ctx context.Context) error

DisableAnimationsOnce runs the animation-disabling CSS on the current page (one-shot, for per-request ?noAnimations=true).

func DispatchNamedKey added in v0.8.0

func DispatchNamedKey(ctx context.Context, key string, modifiers int) error

DispatchNamedKey dispatches key with the given CDP modifier bitmask (Alt=1, Ctrl=2, Meta=4, Shift=8). Unrecognised keys with no modifiers fall back to chromedp.KeyEvent (types the key); with modifiers they are dispatched as a shortcut so chords like Ctrl+C / Cmd+A reach the page.

func DispatchNavigation added in v0.15.1

func DispatchNavigation(ctx context.Context, url string) error

func DoubleClickByCoordinate added in v0.8.2

func DoubleClickByCoordinate(ctx context.Context, x, y float64) error

func DoubleClickByNodeID added in v0.8.2

func DoubleClickByNodeID(ctx context.Context, nodeID int64) error

func DragBetweenPoints added in v0.15.1

func DragBetweenPoints(ctx context.Context, x, y, endX, endY float64, button string) error

func DragByNodeID added in v0.8.0

func DragByNodeID(ctx context.Context, nodeID int64, dx, dy int, button string) error

func EnableDialogEvents added in v0.8.3

func EnableDialogEvents(ctx context.Context) error

func EnrichA11yNodesWithDOMMetadata added in v0.11.0

func EnrichA11yNodesWithDOMMetadata(ctx context.Context, nodes []A11yNode) error

EnrichA11yNodesWithDOMMetadata adds DOM-backed descriptor fields used by the semantic structured locator matcher. It is best-effort: per-node CDP failures are skipped so snapshots still work on pages with detached or remote nodes.

func FillByNodeID added in v0.7.7

func FillByNodeID(ctx context.Context, nodeID int64, value string) error

func FillText added in v0.15.1

func FillText(req ActionRequest) (string, bool)

FillText is the one owner of what a fill writes: text, falling back to value, the same tolerance actionSelect has had in the other direction. Both are published request fields and no surface declared which one fill reads, so a caller sending the other spelling wrote nothing and was told it succeeded.

The second return says whether anything was asked for at all, which is not the same as a non-empty answer: a supplied empty string clears the field.

func FormatSnapshotCompact

func FormatSnapshotCompact(nodes []A11yNode) string

func FormatSnapshotCompactDiff added in v0.10.0

func FormatSnapshotCompactDiff(nodes, added, changed, removed []A11yNode) string

func FormatSnapshotText

func FormatSnapshotText(nodes []A11yNode) string

func FrameExecutionContextID added in v0.9.1

func FrameExecutionContextID(ctx context.Context, frameID string) (int64, error)

FrameExecutionContextID returns a Runtime.executionContextId that evaluates in the given frame's document. Safe to call from other packages that need to scope `Runtime.evaluate` / `Runtime.callFunctionOn` to a frame (for example, the /text handler when a frame scope is active). Passes frameID == "" through as a no-op (returns 0, nil) so callers can fall back to the default top-level context without branching.

func FrameMap added in v0.9.1

func FrameMap(tree RawFrameTree) map[string]RawFrame

func FrameOwnerMap added in v0.9.1

func FrameOwnerMap(ctx context.Context, tree RawFrameTree) map[string]int64

func GetResponseBody added in v0.15.1

func GetResponseBody(ctx context.Context, requestID string) (string, bool, error)

func HandleDialog added in v0.8.3

func HandleDialog(ctx context.Context, accept bool, promptText string) error

func HasCrashDiagnostics added in v0.8.0

func HasCrashDiagnostics() bool

HasCrashDiagnostics reports whether any crash events have been recorded.

func Hover added in v0.15.1

func Hover(ctx context.Context, x, y float64) error

Hover is the humanized sibling of Click: the same random-start bezier approach, then the plain hover dispatch instead of press/release.

func HoverByCoordinate added in v0.8.2

func HoverByCoordinate(ctx context.Context, x, y float64) error

func HoverByNodeID

func HoverByNodeID(ctx context.Context, nodeID int64) error

func HoverElement added in v0.15.1

func HoverElement(ctx context.Context, backendNodeID cdp.BackendNodeID) error

The ID is the backendDOMNodeId from the accessibility tree, NOT a regular DOM nodeId.

func IsFulfillContentTypeAllowed added in v0.11.0

func IsFulfillContentTypeAllowed(ct string) bool

IsFulfillContentTypeAllowed reports whether ct is on the safe-list and free of header-injection control bytes. Empty ct returns true — AddRule defaults it to application/json before storing.

func IsOnScreen added in v0.15.1

func IsOnScreen(box BoundingBox, vp ViewportInfo) bool

func IsQuarantinedProfileDir added in v0.15.1

func IsQuarantinedProfileDir(dirName string) bool

func IsResourceTypeValid added in v0.11.0

func IsResourceTypeValid(rt string) bool

IsResourceTypeValid reports whether rt names a known CDP resource category. Empty rt is valid (means "no resource-type filter").

func IsSubmitClick added in v0.15.1

func IsSubmitClick(kind string, req ActionRequest) bool

IsSubmitClick reports whether an action requested the explicit once-only click-submit contract.

func IsTransientURL added in v0.8.6

func IsTransientURL(rawURL, serverPort string) bool

IsTransientURL returns true for URLs that should not be shown in the UI or persisted to session state.

func IsolatedNodeObjectID added in v0.15.1

func IsolatedNodeObjectID(ctx context.Context, backendNodeID int64) (string, error)

IsolatedNodeObjectID converts a backend node id to a JS object handle in the isolated world, so Runtime.callFunctionOn against it cannot be answered by page script that has redefined the DOM methods the call uses.

The rule has one owner in internal/cdptk, the lowest CDP layer, because the same resolution is needed by the clip builder there and this package already depends on it. A second implementation here is how the two capture paths drifted apart before.

func IsolatedNodeObjectIDs added in v0.15.1

func IsolatedNodeObjectIDs(ctx context.Context, backendNodeIDs ...int64) ([]string, error)

IsolatedNodeObjectIDs resolves several nodes against one isolated context, for an operation whose handles are compared in a single call.

func JSClickByBackendNode added in v0.11.0

func JSClickByBackendNode(ctx context.Context, nodeID int64) error

func JSDispatchClickByBackendNode added in v0.13.1

func JSDispatchClickByBackendNode(ctx context.Context, nodeID int64) error

func JSDoubleClickByBackendNode added in v0.11.0

func JSDoubleClickByBackendNode(ctx context.Context, nodeID int64) error

func KillAllPinchtabChrome added in v0.8.2

func KillAllPinchtabChrome() int

Matches both persistent profiles (--user-data-dir=.../profiles/...) and temp profiles (--user-data-dir=.../pinchtab-profile-*). Called on server shutdown — one ps scan, immediate SIGKILL.

func ListenDialogEvents added in v0.8.3

func ListenDialogEvents(ctx context.Context, tabID string, dm *DialogManager, autoAccept bool)

func MarkCleanExit

func MarkCleanExit(profileDir string)

func MintVocabToken added in v0.15.1

func MintVocabToken() string

func ModeFromHeadless added in v0.10.0

func ModeFromHeadless(headless bool) string

func MouseDownByCoordinate added in v0.9.0

func MouseDownByCoordinate(ctx context.Context, x, y float64, button string, modifiers int) error

func MouseMove added in v0.8.4

func MouseMove(ctx context.Context, fromX, fromY, toX, toY float64) error

func MouseMoveByCoordinate added in v0.9.0

func MouseMoveByCoordinate(ctx context.Context, x, y float64) error

func MouseUpByCoordinate added in v0.9.0

func MouseUpByCoordinate(ctx context.Context, x, y float64, button string, modifiers int) error

func MouseWheelByCoordinate added in v0.9.0

func MouseWheelByCoordinate(ctx context.Context, x, y float64, deltaX, deltaY, modifiers int) error
func NavigatePage(ctx context.Context, url string) error
func NavigatePageWithRedirectLimit(ctx context.Context, url string, maxRedirects int) error

func NewInvalidActionRequestError added in v0.15.1

func NewInvalidActionRequestError(msg string) error

func PointerPointForNode added in v0.9.0

func PointerPointForNode(ctx context.Context, nodeID int64, requireTopMost bool) (float64, float64, error)

func ProfileOwnedByRunningPinchtab added in v0.15.1

func ProfileOwnedByRunningPinchtab(profileDir string) (bool, int)

ProfileOwnedByRunningPinchtab reports whether a live pinchtab process holds profileDir via its pinchtab.pid lock. It is the per-directory truth the profiles destructive-route guard falls back to on surfaces that have no orchestrator instance mapping.

func ReadInputValue added in v0.9.0

func ReadInputValue(ctx context.Context, nodeID int64) (string, error)

func RecordCrashForContextTests added in v0.15.1

func RecordCrashForContextTests(ctx context.Context, ev CrashEvent)

RecordCrashForContextTests injects a crash event stamped with the generation of ctx, so tests can stage crashes on a specific browser context.

func RecordCrashForTests added in v0.8.0

func RecordCrashForTests(ev CrashEvent)

RecordCrashForTests injects a crash event for diagnostics tests.

func RefTargetsFromNodes added in v0.9.1

func RefTargetsFromNodes(nodes []A11yNode) map[string]RefTarget

func ResetCrashMonitoringForTests added in v0.8.0

func ResetCrashMonitoringForTests()

ResetCrashMonitoringForTests clears crash diagnostics state.

func ResolveCSSToNodeID added in v0.8.3

func ResolveCSSToNodeID(ctx context.Context, css string) (int64, error)

func ResolveCSSToNodeIDInFrame added in v0.9.1

func ResolveCSSToNodeIDInFrame(ctx context.Context, frameID, css string) (int64, error)

func ResolveTextToNodeID added in v0.8.3

func ResolveTextToNodeID(ctx context.Context, text string) (int64, error)

func ResolveTextToNodeIDInFrame added in v0.9.1

func ResolveTextToNodeIDInFrame(ctx context.Context, frameID, text string) (int64, error)

func ResolveUnifiedSelector added in v0.8.3

func ResolveUnifiedSelector(ctx context.Context, sel selector.Selector, refCache *RefCache) (int64, error)

func ResolveUnifiedSelectorInFrame added in v0.9.1

func ResolveUnifiedSelectorInFrame(ctx context.Context, sel selector.Selector, refCache *RefCache, frameID string) (int64, error)

ResolveUnifiedSelectorInFrame resolves a parsed selector to a backend node ID. Ref selectors still use the ref cache directly; non-ref selectors honor the provided frame scope.

func ResolveUnifiedSelectorWithinNode added in v0.15.1

func ResolveUnifiedSelectorWithinNode(ctx context.Context, sel selector.Selector, refCache *RefCache, scopeBackendNodeID int64) (int64, error)

ResolveUnifiedSelectorWithinNode resolves a selector strictly inside a DOM subtree. Ref selectors are accepted only when their cached backend node is still contained by that subtree; all other supported selectors are evaluated with the scope element as their root.

func ResolveXPathToNodeID added in v0.8.3

func ResolveXPathToNodeID(ctx context.Context, xpath string) (int64, error)

func ResolveXPathToNodeIDInFrame added in v0.9.1

func ResolveXPathToNodeIDInFrame(ctx context.Context, frameID, xpath string) (int64, error)

XPath does not pierce shadow roots: document.evaluate cannot cross a shadow boundary. It resolves through the shared walker for consistency and isolated-world execution, not for shadow support.

func ScrollByCoordinate added in v0.8.6

func ScrollByCoordinate(ctx context.Context, x, y float64, deltaX, deltaY, modifiers int) error

func ScrollByNodeID

func ScrollByNodeID(ctx context.Context, nodeID int64) error

func ScrollIntoViewAndGetBox added in v0.8.3

func ScrollIntoViewAndGetBox(ctx context.Context, nodeID int64) (map[string]any, error)

ScrollIntoViewAndGetBox scrolls the element into view and reports the box it ended up at, in the same top-level viewport space /box and /capture report.

func SelectByNodeID

func SelectByNodeID(ctx context.Context, nodeID int64, value string) error

func SelectValue added in v0.15.1

func SelectValue(req ActionRequest) (string, bool)

SelectValue is FillText with the precedence reversed, and they stay two named functions because the precedence IS the difference — a shared helper taking a preference argument would hide it at both call sites.

Supplied-ness reads HasText, which is inferred from key presence of text OR value, and those are exactly the two fields select reads. So an explicitly supplied empty string is a request to select the `<option value="">` placeholder, not an absent argument.

func SetHumanRandSeed added in v0.8.4

func SetHumanRandSeed(seed int64)

func SetResourceBlocking

func SetResourceBlocking(ctx context.Context, patterns []string) error

func SplitQuarantineName added in v0.15.1

func SplitQuarantineName(dirName string) (profile string, stamp int64, ok bool)

SplitQuarantineName reads a quarantine directory name back into the profile it was made from and the timestamp it carries. It is the one owner of the pattern: the predicate below and the prune both go through it, so a reader cannot drift from what quarantine writes.

func TopmostModalNodeID added in v0.15.1

func TopmostModalNodeID(ctx context.Context, frameID string) (int64, bool, error)

TopmostModalNodeID gives a top-document modal precedence over a caller's current iframe scope. This prevents a stale frame scope from interacting with background content underneath a page-level modal. When the top document has no modal, it falls back to the requested frame.

func TopmostModalNodeIDInFrame added in v0.15.1

func TopmostModalNodeIDInFrame(ctx context.Context, frameID string) (int64, bool, error)

TopmostModalNodeIDInFrame returns the backend node ID of the visually topmost visible modal owner in a frame. A missing dialog is a normal result, not an error. Discovery runs in an isolated world and uses browser hit testing rather than comparing local z-index values, which are not comparable across stacking contexts or the native top layer.

func Type added in v0.8.4

func Type(text string, fast bool) []chromedp.Action

func TypeByNodeID

func TypeByNodeID(ctx context.Context, nodeID int64, text string) error

func TypeWithConfig added in v0.8.4

func TypeWithConfig(text string, fast bool, cfg *Config) []chromedp.Action

func ValidateButtonAction added in v0.15.1

func ValidateButtonAction(kind string, req ActionRequest) error

ValidateButtonAction refuses a button name no pointer action can honour. It is not gated on the action kind, deliberately: the button is normalized inside cdpops for every action that dispatches a press, so a kind list here would have to be kept in step with that set and would leave any kind nobody thought of accepting a misspelling silently. An unrecognised name reached CDP as "left", so a mistyped right-click performed a left-click and reported success.

func ValidateFillAction added in v0.15.1

func ValidateFillAction(kind string, req ActionRequest) error

ValidateFillAction refuses a fill that carries no text under any spelling. That request used to write "" and answer filled:true with len:0 — indistinguishable from clearing a field on purpose, which is why it stayed invisible. Clearing stays available by sending the key explicitly.

func ValidateSubmitAction added in v0.15.1

func ValidateSubmitAction(kind string, req ActionRequest) error

ValidateSubmitAction rejects combinations that cannot preserve exactly-once submit dispatch. Fill's existing submit-via-Enter contract is unchanged.

func WaitForQuietWindow added in v0.13.2

func WaitForQuietWindow(ctx context.Context, quiet, ceiling time.Duration) (time.Duration, error)

func WaitForReadyState added in v0.13.2

func WaitForReadyState(ctx context.Context, ceiling time.Duration) (string, error)

func WaitForTitle

func WaitForTitle(ctx context.Context, timeout time.Duration) (string, error)

func WasUncleanExit

func WasUncleanExit(profileDir string) bool

Types

type A11yNode

type A11yNode = bridgeobserve.A11yNode

func BuildSnapshot

func BuildSnapshot(nodes []RawAXNode, filter string, maxDepth int) ([]A11yNode, map[string]int64)

func DiffSnapshot

func DiffSnapshot(prev, curr []A11yNode) (added, changed, removed []A11yNode)

func TruncateToTokens

func TruncateToTokens(nodes []A11yNode, maxTokens int, format string) ([]A11yNode, bool)

type ActionFunc

type ActionFunc func(ctx context.Context, req ActionRequest) (map[string]any, error)

type ActionRecord

type ActionRecord struct {
	Timestamp  time.Time `json:"timestamp"`
	Method     string    `json:"method"`
	Endpoint   string    `json:"endpoint"`
	URL        string    `json:"url"`
	TabID      string    `json:"tabId"`
	DurationMs int64     `json:"durationMs"`
	Status     int       `json:"status"`
}

type ActionRequest

type ActionRequest struct {
	TabID    string `json:"tabId"`
	Kind     string `json:"kind"`
	Ref      string `json:"ref,omitempty"`
	Selector string `json:"selector,omitempty"`

	// Text/Value use omitempty, and HasText records that one of them was
	// SUPPLIED, for the same reason X/Y do below: an empty fill is a
	// legitimate request to clear the field, so absent and empty must not
	// share a representation. While they did, `fill` could not refuse a
	// request whose text never arrived — it wrote "" and answered
	// filled:true, len:0 — and its read-back verification, gated on a
	// non-empty Text, switched itself off in exactly that case. Re-marshaling
	// without omitempty would re-introduce "text":"" and make every forwarded
	// request look supplied.
	Text    string `json:"text,omitempty"`
	Value   string `json:"value,omitempty"`
	HasText bool   `json:"hasText,omitempty"`

	Key    string `json:"key"`
	NodeID int64  `json:"nodeId"`

	// X/Y use omitempty so that re-marshaling an ActionRequest without
	// explicit coordinates (e.g. when the tab-scoped handler forwards to
	// the generic one) doesn't spuriously re-introduce "x":0, "y":0. The
	// ActionRequest.UnmarshalJSON code infers HasXY from the presence of
	// these keys, so preserving omission is what makes "use current
	// pointer" work for mouse-down/up after a prior mouse-move. HasXY is
	// still marshaled (with omitempty) when it was explicitly set, which
	// preserves the explicit-click-at-(0,0) case through the round-trip.
	X      float64 `json:"x,omitempty"`
	Y      float64 `json:"y,omitempty"`
	HasXY  bool    `json:"hasXY,omitempty"`
	Button string  `json:"button,omitempty"`
	Mode   string  `json:"mode,omitempty"`

	// FrameW/FrameH are the pixel dimensions of the screencast frame the caller
	// mapped the coordinates against (the dashboard maps a click to frame-pixel
	// space). When set, X/Y are scaled from that frame space into the live CSS
	// viewport before dispatch, so a HiDPI frame (e.g. 2x the CSS viewport) does
	// not land clicks at twice their intended position. Zero means X/Y are
	// already CSS pixels.
	FrameW float64 `json:"frameW,omitempty"`
	FrameH float64 `json:"frameH,omitempty"`

	// Modifiers is the CDP key-modifier bitmask (Alt=1, Ctrl=2, Meta=4, Shift=8)
	// held during a press, enabling keyboard chords such as Ctrl+C or Shift+Arrow.
	Modifiers int `json:"modifiers,omitempty"`

	// ScrollX/ScrollY use omitempty for the same reason X/Y do: UnmarshalJSON
	// infers HasScroll from the presence of these keys, so a re-marshal that
	// re-introduced "scrollX":0 would turn every bare scroll into an explicit
	// zero and refuse it. The explicit zero survives the omission because
	// HasScroll is itself marshaled and the decoder ORs it back in — that is
	// what keeps an explicit zero from decaying into the default 120px step.
	ScrollX int `json:"scrollX,omitempty"`
	ScrollY int `json:"scrollY,omitempty"`

	HasScroll bool `json:"hasScroll,omitempty"`
	// DeltaX/DeltaY are the wheel spelling; ScrollX/ScrollY remain for compatibility.
	DeltaX   int  `json:"deltaX,omitempty"`
	DeltaY   int  `json:"deltaY,omitempty"`
	HasDelta bool `json:"hasDelta,omitempty"`
	DragX    int  `json:"dragX"`
	DragY    int  `json:"dragY"`

	// A drag's destination. ToSelector takes the same unified selector vocabulary as
	// Selector and the handler resolves it to ToNodeID; HasToXY separates an absent
	// destination from the legitimate one at (0,0).
	ToSelector string  `json:"toSelector,omitempty"`
	ToNodeID   int64   `json:"toNodeId,omitempty"`
	ToX        float64 `json:"toX,omitempty"`
	ToY        float64 `json:"toY,omitempty"`
	HasToXY    bool    `json:"hasToXY,omitempty"`

	WaitNav bool   `json:"waitNav"`
	Fast    bool   `json:"fast"`
	Owner   string `json:"owner"`
	// Submit is an explicit opt-in to a terminal action. Fill dispatches Enter
	// after filling; click uses one DOM click and lets the handler observe a
	// bounded post-submit state. Ordinary clicks retain their normal delivery.
	Submit bool `json:"submit,omitempty"`

	// DismissBanners, when true and combined with WaitNav, runs a best-effort
	// cookie/consent-banner dismissal pass after a click that triggered a
	// navigation. Bridge layer ignores this field; the handler reads it and
	// invokes the dismissal helper post-action. No effect on actions that
	// don't trigger navigation.
	DismissBanners bool `json:"dismissBanners,omitempty"`
	// DismissKnownInterstitials requests the conservative, catalog-backed
	// pre-action pass. Unlike DismissBanners it never removes generic overlays.
	DismissKnownInterstitials bool `json:"dismissKnownInterstitials,omitempty"`

	// Humanize, when set, overrides the per-instance `humanize` default for
	// this action only. nil = use the configured default. true forces the
	// bezier/jitter/pre-press-sleep code path; false forces the raw
	// straight-to-target dispatch.
	Humanize *bool `json:"humanize,omitempty"`

	// AutoSwitch, when explicitly set to false, disables the popup-aware
	// auto-switch behavior on click actions. nil or true = on (default). When
	// on, a click that opens a new tab adopts + focuses it and surfaces the
	// new tab ID on the response as "switchedToTab". Only click/dblclick
	// honor this field.
	AutoSwitch *bool `json:"autoSwitch,omitempty"`

	// DialogAction arms a one-shot dialog auto-handler before the action
	// executes. Used when clicking a button/link that opens a JS dialog
	// (alert/confirm/prompt). Values: "accept" or "dismiss". When set, the
	// dialog is handled automatically without a second HTTP call.
	DialogAction string `json:"dialogAction,omitempty"`
	// DialogText is the optional prompt text used when DialogAction is
	// "accept" on a prompt() dialog.
	DialogText string `json:"dialogText,omitempty"`

	// Browser specifies which browser to use for this request (e.g. "chrome",
	// "cloak", "ghost-chrome"). Validated against configured + registry
	// browsers. Recorded on route metadata but does not change actual
	// routing yet.
	Browser string `json:"browser,omitempty"`

	Vocab string `json:"vocab,omitempty"`
}

ActionRequest defines the parameters for a browser action.

Element targeting uses a unified selector string that supports multiple strategies via prefix detection (see the selector package):

"e5"              → ref from snapshot
"css:#login"      → CSS selector (explicit)
"#login"          → CSS selector (auto-detected)
"xpath://div"     → XPath expression
"text:Submit"     → text content match
"find:login btn"  → semantic / natural-language query
"role:button Save" → role/name locator
"label:Email"     → form control by label
"testid:submit"   → test id locator
"last:button"     → positional selector wrapper

For backward compatibility, the legacy Ref and Selector (CSS) fields are still accepted. Call NormalizeSelector() to merge them into the unified Selector field.

func (*ActionRequest) NormalizeSelector added in v0.8.3

func (r *ActionRequest) NormalizeSelector()

NormalizeSelector merges legacy Ref and Selector (CSS) fields into the unified Selector field. After calling this, only Selector needs to be inspected for element targeting. The method is idempotent.

Priority: Ref > Selector (if both are set, Ref wins).

func (*ActionRequest) UnmarshalJSON added in v0.9.0

func (r *ActionRequest) UnmarshalJSON(data []byte) error

type AnalyticsReport

type AnalyticsReport struct {
	TotalActions   int            `json:"totalActions"`
	Last24h        int            `json:"last24h"`
	CommonHosts    map[string]int `json:"commonHosts"`
	TopEndpoints   map[string]int `json:"topEndpoints,omitempty"`
	RepeatPatterns []string       `json:"repeatPatterns,omitempty"`
	Suggestions    []string       `json:"suggestions,omitempty"`
}

type BoundingBox added in v0.13.2

type BoundingBox = bridgeobserve.BoundingBox

func ElementBorderBox added in v0.15.1

func ElementBorderBox(ctx context.Context, backendNodeID int64) (BoundingBox, bool)

type Bridge

type Bridge struct {
	AllocCtx      context.Context
	AllocCancel   context.CancelFunc
	BrowserCtx    context.Context
	BrowserCancel context.CancelFunc
	Config        *config.RuntimeConfig
	URLReader     URLReader
	IdMgr         *ids.Manager
	*TabManager
	StealthBundle *stealth.Bundle
	Actions       map[string]ActionFunc
	Locks         *LockManager
	Dialogs       *DialogManager
	LogStore      *ConsoleLogStore
	// contains filtered or unexported fields
}

func New

func New(allocCtx, browserCtx context.Context, cfg *config.RuntimeConfig) *Bridge

func (*Bridge) AddRouteRule added in v0.11.0

func (b *Bridge) AddRouteRule(tabID string, rule RouteRule) error

Replaces an existing rule with the same Pattern. The first call for a tab enables CDP Fetch interception.

func (*Bridge) AddScriptToEvaluateOnNewDocument added in v0.14.0

func (b *Bridge) AddScriptToEvaluateOnNewDocument(ctx context.Context, source string) (string, error)

The script is evaluated before any page scripts run.

func (*Bridge) AddTabRemovedHook added in v0.14.0

func (b *Bridge) AddTabRemovedHook(fn func(tabID string))

AddTabRemovedHook registers an external per-tab cleanup that must survive a TabManager swap. It records the hook on the bridge and applies it to the current TabManager; wireTabManager re-applies all recorded hooks after a launch/reinit/remote-CDP path replaces the TabManager. Shadows the embedded TabManager.AddTabRemovedHook so external callers always go through here.

func (*Bridge) AvailableActions

func (b *Bridge) AvailableActions() []string

func (*Bridge) BrowserContext

func (b *Bridge) BrowserContext() context.Context

func (*Bridge) CallFunctionOnNode added in v0.14.0

func (b *Bridge) CallFunctionOnNode(ctx context.Context, backendNodeID int64, functionDecl string, args []map[string]any, result any) error

func (*Bridge) CanClearCache added in v0.9.0

func (b *Bridge) CanClearCache(ctx context.Context) (bool, error)

CanClearCache checks if the browser cache can be cleared. This is a legacy CDP method that always returns true in modern Chrome.

func (*Bridge) CancelAutoClose added in v0.11.0

func (b *Bridge) CancelAutoClose(tabID string)

func (*Bridge) CaptureScreenshot added in v0.14.0

func (b *Bridge) CaptureScreenshot(ctx context.Context, format string, quality int, clip *cdptk.ScreenshotClip) ([]byte, error)

CaptureScreenshot is the provider-aware entry point used across the BridgeAPI (screencast polling, recorder, annotated capture). It delegates to the shared package-level CaptureScreenshot engine so every provider gets the same rendering path, gated by b.Config.CaptureAllowActivation (default true).

func (*Bridge) Cleanup added in v0.8.2

func (b *Bridge) Cleanup()

Cleanup releases browser resources and removes temporary profile directories. Must be called on shutdown to prevent Chrome process and disk leaks.

func (*Bridge) CleanupSavedStateBackup added in v0.9.0

func (b *Bridge) CleanupSavedStateBackup()

func (*Bridge) ClearCache added in v0.9.0

func (b *Bridge) ClearCache(ctx context.Context) error

ClearCache clears the browser's HTTP disk cache. This affects all origins and does not require an active tab.

func (*Bridge) ClearConsoleLogs added in v0.8.5

func (b *Bridge) ClearConsoleLogs(tabID string)

func (*Bridge) ClearCookies added in v0.11.0

func (b *Bridge) ClearCookies(ctx context.Context) error

ClearCookies clears all browser cookies. This affects all origins and does not require an active tab.

func (*Bridge) ClearErrorLogs added in v0.8.5

func (b *Bridge) ClearErrorLogs(tabID string)

func (*Bridge) ClearSavedState added in v0.9.0

func (b *Bridge) ClearSavedState()

func (*Bridge) CloseTab added in v0.9.1

func (b *Bridge) CloseTab(tabID string) error

func (*Bridge) ContinueRequest added in v0.14.0

func (b *Bridge) ContinueRequest(ctx context.Context, requestID string) error

func (*Bridge) ContinueWithAuth added in v0.14.0

func (b *Bridge) ContinueWithAuth(ctx context.Context, requestID, username, password string) error

func (*Bridge) CreateTab added in v0.9.1

func (b *Bridge) CreateTab(url string) (string, context.Context, context.CancelFunc, error)

func (*Bridge) CreateTabInBrowserContext added in v0.15.1

func (b *Bridge) CreateTabInBrowserContext(url, browserContextID string) (string, context.Context, context.CancelFunc, error)

func (*Bridge) CurrentTitle added in v0.14.0

func (b *Bridge) CurrentTitle(ctx context.Context) (string, error)

func (*Bridge) CurrentURL added in v0.14.0

func (b *Bridge) CurrentURL(ctx context.Context) (string, error)

func (*Bridge) DescribeNode added in v0.14.0

func (b *Bridge) DescribeNode(ctx context.Context, backendNodeID int64) (*NodeInfo, error)

func (*Bridge) DisableFetch added in v0.14.0

func (b *Bridge) DisableFetch(ctx context.Context) error

func (*Bridge) DownloadURL added in v0.14.0

func (b *Bridge) DownloadURL(ctx context.Context, dlURL string, opts DownloadOpts) (*DownloadResult, error)

func (*Bridge) EnableFetchWithAuth added in v0.14.0

func (b *Bridge) EnableFetchWithAuth(ctx context.Context) error

func (*Bridge) EnableNetwork added in v0.14.0

func (b *Bridge) EnableNetwork(ctx context.Context) error

func (*Bridge) EnsureBrowser added in v0.14.0

func (b *Bridge) EnsureBrowser(cfg *config.RuntimeConfig) error

func (*Bridge) Evaluate added in v0.14.0

func (b *Bridge) Evaluate(ctx context.Context, expression string, result any, opts EvalOpts) error

func (*Bridge) EvaluateInFrame added in v0.14.0

func (b *Bridge) EvaluateInFrame(ctx context.Context, frameID string, expression string, result any, opts EvalOpts) error

If frameID is empty, behaves like Evaluate.

func (*Bridge) Execute added in v0.7.8

func (b *Bridge) Execute(ctx context.Context, tabID string, task func(ctx context.Context) error) error

If TabManager is not initialized, the task runs directly.

func (*Bridge) ExecuteAction

func (b *Bridge) ExecuteAction(ctx context.Context, kind string, req ActionRequest) (map[string]any, error)

func (*Bridge) FingerprintRotateActive added in v0.8.6

func (b *Bridge) FingerprintRotateActive(tabID string) bool

func (*Bridge) FocusTab added in v0.9.1

func (b *Bridge) FocusTab(tabID string) error

func (*Bridge) GetAggregatedMemoryMetrics added in v0.7.7

func (b *Bridge) GetAggregatedMemoryMetrics() (*MemoryMetrics, error)

func (*Bridge) GetBrowserMemoryMetrics added in v0.7.7

func (b *Bridge) GetBrowserMemoryMetrics() (*MemoryMetrics, error)

func (*Bridge) GetConsoleLogs added in v0.8.5

func (b *Bridge) GetConsoleLogs(tabID string, limit int) []LogEntry

func (*Bridge) GetCookies added in v0.14.0

func (b *Bridge) GetCookies(ctx context.Context, urls []string) ([]CookieData, error)

func (*Bridge) GetCrashLogs added in v0.7.7

func (b *Bridge) GetCrashLogs() []string

GetCrashLogs returns recent crash information from Chrome's preferences

func (*Bridge) GetDialogManager added in v0.8.3

func (b *Bridge) GetDialogManager() *DialogManager

func (*Bridge) GetDocumentReadyState added in v0.13.0

func (b *Bridge) GetDocumentReadyState(tabID string) (string, error)

func (*Bridge) GetErrorLogs added in v0.8.5

func (b *Bridge) GetErrorLogs(tabID string, limit int) []ErrorEntry

func (*Bridge) GetMemoryMetrics added in v0.7.7

func (b *Bridge) GetMemoryMetrics(tabID string) (*MemoryMetrics, error)

func (*Bridge) GetRawCookies added in v0.14.0

func (b *Bridge) GetRawCookies(ctx context.Context) ([]RawCookie, error)

func (*Bridge) GoBack added in v0.14.0

func (b *Bridge) GoBack(ctx context.Context) (bool, error)

func (*Bridge) GoForward added in v0.14.0

func (b *Bridge) GoForward(ctx context.Context) (bool, error)

func (*Bridge) InitActionRegistry

func (b *Bridge) InitActionRegistry()

func (*Bridge) InjectNoAnimations

func (b *Bridge) InjectNoAnimations(ctx context.Context) error

InjectNoAnimations adds a persistent script (via CDP) that disables CSS animations on every document load. Used when BRIDGE_NO_ANIMATIONS=true.

func (*Bridge) IsNetworkIdle added in v0.13.0

func (b *Bridge) IsNetworkIdle(tabID string) (bool, bool)

func (*Bridge) ListRouteRules added in v0.11.0

func (b *Bridge) ListRouteRules(tabID string) ([]RouteRule, error)

func (*Bridge) ListTargets added in v0.9.1

func (b *Bridge) ListTargets() ([]TabTarget, error)

func (*Bridge) ListenAuthRequired added in v0.14.0

func (b *Bridge) ListenAuthRequired(ctx context.Context, handler func(requestID string, isAuth bool))

The handler callback receives isAuth=true for AuthRequired events and false for RequestPaused events.

func (*Bridge) ListenNetworkEvents added in v0.14.0

func (b *Bridge) ListenNetworkEvents(ctx context.Context, handler NetworkEventHandler)

func (*Bridge) Lock

func (b *Bridge) Lock(tabID, owner string, ttl time.Duration) error

func (*Bridge) MonitorCrashes added in v0.7.7

func (b *Bridge) MonitorCrashes(handler CrashHandler)

MonitorCrashes listens for browser and tab crashes

func (*Bridge) Navigate added in v0.14.0

func (b *Bridge) Navigate(ctx context.Context, url string, params NavigateParams) (*NavigateResult, error)

func (*Bridge) NetworkMonitor added in v0.8.3

func (b *Bridge) NetworkMonitor() *NetworkMonitor

func (*Bridge) PrintToPDF added in v0.14.0

func (b *Bridge) PrintToPDF(ctx context.Context, params PDFParams) ([]byte, error)

func (*Bridge) Reload added in v0.14.0

func (b *Bridge) Reload(ctx context.Context) error

func (*Bridge) RemoveRouteRule added in v0.11.0

func (b *Bridge) RemoveRouteRule(tabID, pattern string) (int, error)

Removes all rules when pattern is empty. Returns the count removed.

func (*Bridge) ResolveSelectorToNodeID added in v0.14.0

func (b *Bridge) ResolveSelectorToNodeID(ctx context.Context, raw string) (int64, error)

ResolveSelectorToNodeID finds a DOM node by a unified selector string and returns its NodeID. Supports CSS (default), XPath (xpath: prefix or // auto-detect), and text (text: prefix).

func (*Bridge) RestartBrowser added in v0.9.0

func (b *Bridge) RestartBrowser(cfg *config.RuntimeConfig) error

RestartBrowser performs a soft restart: drains in-flight requests, tears down browser contexts, and re-initializes via EnsureBrowser.

func (*Bridge) RestartStatus added in v0.9.0

func (b *Bridge) RestartStatus() (bool, time.Duration)

func (*Bridge) RestoreState

func (b *Bridge) RestoreState()

func (*Bridge) ResumeTabHandoff added in v0.9.0

func (b *Bridge) ResumeTabHandoff(tabID string) error

func (*Bridge) RunningBrowser added in v0.14.0

func (b *Bridge) RunningBrowser() (string, bool)

func (*Bridge) SaveState

func (b *Bridge) SaveState()

func (*Bridge) ScheduleAutoClose added in v0.11.0

func (b *Bridge) ScheduleAutoClose(tabID string)

func (*Bridge) SetBrowserContexts added in v0.7.7

func (b *Bridge) SetBrowserContexts(allocCtx context.Context, allocCancel context.CancelFunc, browserCtx context.Context, browserCancel context.CancelFunc)

func (*Bridge) SetCookie added in v0.14.0

func (b *Bridge) SetCookie(ctx context.Context, params SetCookieParams) error

func (*Bridge) SetDeviceMetricsOverride added in v0.14.0

func (b *Bridge) SetDeviceMetricsOverride(ctx context.Context, params DeviceMetricsOverrideParams) error

func (*Bridge) SetEmulatedMedia added in v0.14.0

func (b *Bridge) SetEmulatedMedia(ctx context.Context, feature, value string) error

func (*Bridge) SetExtraHTTPHeaders added in v0.14.0

func (b *Bridge) SetExtraHTTPHeaders(ctx context.Context, headers map[string]string) error

func (*Bridge) SetFetchPauseSuppressed added in v0.14.0

func (b *Bridge) SetFetchPauseSuppressed(tabID string, v bool)

func (*Bridge) SetFileInputFiles added in v0.14.0

func (b *Bridge) SetFileInputFiles(ctx context.Context, backendNodeID int64, paths []string) error

func (*Bridge) SetFingerprintRotateActive added in v0.8.6

func (b *Bridge) SetFingerprintRotateActive(tabID string, active bool)

func (*Bridge) SetGeolocation added in v0.14.0

func (b *Bridge) SetGeolocation(ctx context.Context, lat, lng, accuracy float64) error

func (*Bridge) SetLocaleOverride added in v0.14.0

func (b *Bridge) SetLocaleOverride(ctx context.Context, locale string) error

func (*Bridge) SetNetworkConditions added in v0.14.0

func (b *Bridge) SetNetworkConditions(ctx context.Context, params NetworkConditions) error

func (*Bridge) SetRawCookie added in v0.14.0

func (b *Bridge) SetRawCookie(ctx context.Context, params RawSetCookieParams) error

func (*Bridge) SetTabHandoff added in v0.9.0

func (b *Bridge) SetTabHandoff(tabID, reason string, timeout time.Duration) error

func (*Bridge) SetTimezoneOverride added in v0.14.0

func (b *Bridge) SetTimezoneOverride(ctx context.Context, timezoneID string) error

func (*Bridge) SetUserAgentOverride added in v0.14.0

func (b *Bridge) SetUserAgentOverride(ctx context.Context, params UserAgentOverrideParams) error

SetUserAgentOverride refuses an empty UserAgent rather than forwarding it. An empty string is not "leave it alone" at the CDP layer: Emulation.setUserAgentOverride applies it, so the tab then advertises an empty navigator.userAgent and sends a blank User-Agent header — louder than whatever it replaced, on the path whose purpose is to be quieter. The guard lives here because this is an exported BridgeAPI method: the implementation is what covers future callers and any other implementation of the interface, not the one handler that calls it today.

It does not make an empty override unreachable everywhere: internal/stealth's launch path builds emulation.SetUserAgentOverride(persona.UserAgent) directly. That path needs no guard for a checked reason — BuildPersona reduces the version first and ReducedBrowserVersion falls back, so persona.UserAgent cannot be empty — so do not add a second copy of this check there.

func (*Bridge) SetViewport added in v0.14.0

func (b *Bridge) SetViewport(ctx context.Context, params ViewportParams) error

func (*Bridge) Snapshot added in v0.14.0

func (b *Bridge) Snapshot(ctx context.Context, tabID string, filter string, params ContentParams) (*SnapshotResult, error)

ctx must already be a tab-scoped chromedp context; tabID is for bookkeeping only. ContentParams is accepted but ignored by the base Bridge (IDPI scanning is the adapter's responsibility).

func (*Bridge) StartNetworkCapture added in v0.8.3

func (b *Bridge) StartNetworkCapture(tabCtx context.Context, tabID string) error

func (*Bridge) StartScreencast added in v0.14.0

func (b *Bridge) StartScreencast(ctx context.Context, opts ScreencastOpts) (*ScreencastStream, error)

StartScreencast begins streaming screencast frames. The caller must call Close on the returned ScreencastStream when done. The bridge picks event-driven (Page.startScreencast) or polling (CaptureScreenshot on a ticker) based on the browser's CapEventScreencast capability and headless mode. Polling is used for headless browsers and providers whose CDP proxy does not support Page.startScreencast (e.g. Cloak).

func (*Bridge) StealthStatus added in v0.8.6

func (b *Bridge) StealthStatus() *stealth.Status

func (*Bridge) TabContext added in v0.9.1

func (b *Bridge) TabContext(tabID string) (*TabHandle, string, error)

func (*Bridge) TabHandoffState added in v0.9.0

func (b *Bridge) TabHandoffState(tabID string) (TabHandoffState, bool)

func (*Bridge) TabLockInfo

func (b *Bridge) TabLockInfo(tabID string) *LockInfo

func (*Bridge) Text added in v0.14.0

func (b *Bridge) Text(ctx context.Context, tabID string, params ContentParams) (*TextResult, error)

ctx must already be a tab-scoped chromedp context; tabID is for bookkeeping only. ContentParams is accepted but ignored by the base Bridge (IDPI scanning is the adapter's responsibility).

func (*Bridge) Unlock

func (b *Bridge) Unlock(tabID, owner string) error

func (*Bridge) WaitVisible added in v0.14.0

func (b *Bridge) WaitVisible(ctx context.Context, selector string) error

type BridgeAPI

type BridgeAPI interface {
	BrowserContext() context.Context
	TabContext(tabID string) (ctx *TabHandle, resolvedID string, err error)
	ListTargets() ([]TabTarget, error)
	CreateTab(url string) (tabID string, ctx context.Context, cancel context.CancelFunc, err error)
	CloseTab(tabID string) error
	FocusTab(tabID string) error

	// ScheduleAutoClose (re)arms the per-tab idle close timer when the
	// lifecycle policy is "close_idle". No-op otherwise.
	ScheduleAutoClose(tabID string)
	CancelAutoClose(tabID string)

	GetRefCache(tabID string) *RefCache
	SetRefCache(tabID string, cache *RefCache)
	DeleteRefCache(tabID string)

	ExecuteAction(ctx context.Context, kind string, req ActionRequest) (map[string]any, error)
	AvailableActions() []string

	// Execute runs a task for a tab with per-tab sequential execution
	// and cross-tab bounded parallelism. If not supported, runs directly.
	Execute(ctx context.Context, tabID string, task func(ctx context.Context) error) error

	TabLockInfo(tabID string) *LockInfo
	Lock(tabID, owner string, ttl time.Duration) error
	Unlock(tabID, owner string) error

	EnsureBrowser(cfg *config.RuntimeConfig) error
	RestartBrowser(cfg *config.RuntimeConfig) error
	// RunningBrowser reports the provider of the live browser process, or
	// ("", false) when nothing is running. EnsureBrowser ignores the requested
	// config once initialized, so handlers use this to reject explicit
	// browser params that the running process cannot honor.
	RunningBrowser() (string, bool)
	StealthStatus() *stealth.Status

	GetMemoryMetrics(tabID string) (*MemoryMetrics, error)
	GetBrowserMemoryMetrics() (*MemoryMetrics, error)
	GetAggregatedMemoryMetrics() (*MemoryMetrics, error)

	GetCrashLogs() []string

	NetworkMonitor() *NetworkMonitor

	AddRouteRule(tabID string, rule RouteRule) error
	RemoveRouteRule(tabID, pattern string) (int, error)
	ListRouteRules(tabID string) ([]RouteRule, error)

	GetDialogManager() *DialogManager

	GetConsoleLogs(tabID string, limit int) []LogEntry
	ClearConsoleLogs(tabID string)
	GetErrorLogs(tabID string, limit int) []ErrorEntry
	ClearErrorLogs(tabID string)

	Navigate(ctx context.Context, url string, params NavigateParams) (*NavigateResult, error)

	Snapshot(ctx context.Context, tabID string, filter string, params ContentParams) (*SnapshotResult, error)

	Text(ctx context.Context, tabID string, params ContentParams) (*TextResult, error)

	ClearCache(ctx context.Context) error
	CanClearCache(ctx context.Context) (bool, error)

	ClearCookies(ctx context.Context) error

	Evaluate(ctx context.Context, expression string, result any, opts EvalOpts) error

	// CallFunctionOnNode resolves a backend node ID to a Runtime object,
	// then calls the given JavaScript function on it. args may be nil.
	// The result is unmarshaled from the CDP returnByValue response.
	CallFunctionOnNode(ctx context.Context, backendNodeID int64, functionDecl string, args []map[string]any, result any) error

	// EvaluateInFrame evaluates a JavaScript expression in the given
	// frame's execution context. If frameID is empty, behaves like Evaluate.
	EvaluateInFrame(ctx context.Context, frameID string, expression string, result any, opts EvalOpts) error

	DescribeNode(ctx context.Context, backendNodeID int64) (*NodeInfo, error)

	CaptureScreenshot(ctx context.Context, format string, quality int, clip *cdptk.ScreenshotClip) ([]byte, error)

	StartScreencast(ctx context.Context, opts ScreencastOpts) (*ScreencastStream, error)

	SetViewport(ctx context.Context, params ViewportParams) error
	SetGeolocation(ctx context.Context, lat, lng, accuracy float64) error
	SetEmulatedMedia(ctx context.Context, feature, value string) error

	SetNetworkConditions(ctx context.Context, params NetworkConditions) error
	SetExtraHTTPHeaders(ctx context.Context, headers map[string]string) error
	GetCookies(ctx context.Context, urls []string) ([]CookieData, error)
	SetCookie(ctx context.Context, params SetCookieParams) error

	CurrentURL(ctx context.Context) (string, error)
	CurrentTitle(ctx context.Context) (string, error)

	PrintToPDF(ctx context.Context, params PDFParams) ([]byte, error)

	SetFileInputFiles(ctx context.Context, nodeID int64, paths []string) error
	ResolveSelectorToNodeID(ctx context.Context, selector string) (int64, error)

	DownloadURL(ctx context.Context, dlURL string, opts DownloadOpts) (*DownloadResult, error)

	EnableFetchWithAuth(ctx context.Context) error
	DisableFetch(ctx context.Context) error
	ListenAuthRequired(ctx context.Context, handler func(requestID string, isAuth bool))
	ContinueWithAuth(ctx context.Context, requestID, username, password string) error
	ContinueRequest(ctx context.Context, requestID string) error
	// SetFetchPauseSuppressed toggles per-tab suppression of the proxy-auth
	// listener's blanket ContinueRequest while the credentials handler owns
	// request-pause dispatch. Declared here (not probed) so decorated bridges
	// forward it instead of silently dropping the suppression contract.
	SetFetchPauseSuppressed(tabID string, v bool)

	GoBack(ctx context.Context) (didNavigate bool, err error)
	GoForward(ctx context.Context) (didNavigate bool, err error)
	Reload(ctx context.Context) error

	WaitVisible(ctx context.Context, selector string) error

	EnableNetwork(ctx context.Context) error
	ListenNetworkEvents(ctx context.Context, handler NetworkEventHandler)

	SetRawCookie(ctx context.Context, params RawSetCookieParams) error
	GetRawCookies(ctx context.Context) ([]RawCookie, error)

	SetUserAgentOverride(ctx context.Context, params UserAgentOverrideParams) error
	SetLocaleOverride(ctx context.Context, locale string) error
	SetTimezoneOverride(ctx context.Context, timezoneID string) error
	SetDeviceMetricsOverride(ctx context.Context, params DeviceMetricsOverrideParams) error
	AddScriptToEvaluateOnNewDocument(ctx context.Context, source string) (string, error)
}

type CaptureOpts added in v0.13.2

type CaptureOpts struct {
	Image              ScreenshotOpts
	Filter             string // snapshot filter ("" or FilterInteractive)
	MaxDepth           int    // -1 for full tree
	ScopeBackendNodeID int64  // optional snapshot subtree scope
	ScopeFrameID       string // optional frame-scoped capture
	DisableAnimations  bool

	// Wait controls the lifecycle wait before the capture window opens.
	// Empty (or "none") skips the wait. "load" polls document.readyState
	// until it reaches "complete" (2s ceiling). "stable" waits for
	// Page.lifecycleEvent quiescence — 250ms of silence, 750ms ceiling.
	Wait string

	// WithBounds populates BoundingBox + Visible on every snapshot node that
	// has a non-zero backend node id. Adds one DOM.getBoxModel round trip
	// per node (~5ms each).
	WithBounds bool
}

type Config added in v0.8.4

type Config struct {
	Rand *rand.Rand
}

type ConsoleLogStore added in v0.8.5

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

ConsoleLogStore manages console/error logs across all tabs.

func NewConsoleLogStore added in v0.8.5

func NewConsoleLogStore(maxLines int) *ConsoleLogStore

NewConsoleLogStore creates a new log store with the given max lines per tab.

func (*ConsoleLogStore) AddConsoleLog added in v0.8.5

func (s *ConsoleLogStore) AddConsoleLog(tabID string, entry LogEntry)

AddConsoleLog adds a console log entry for a tab.

func (*ConsoleLogStore) AddErrorLog added in v0.8.5

func (s *ConsoleLogStore) AddErrorLog(tabID string, entry ErrorEntry)

AddErrorLog adds an error log entry for a tab.

func (*ConsoleLogStore) ClearConsoleLogs added in v0.8.5

func (s *ConsoleLogStore) ClearConsoleLogs(tabID string)

ClearConsoleLogs clears console logs for a tab.

func (*ConsoleLogStore) ClearErrorLogs added in v0.8.5

func (s *ConsoleLogStore) ClearErrorLogs(tabID string)

ClearErrorLogs clears error logs for a tab.

func (*ConsoleLogStore) GetConsoleLogs added in v0.8.5

func (s *ConsoleLogStore) GetConsoleLogs(tabID string, limit int) []LogEntry

GetConsoleLogs returns console logs for a tab. If limit > 0, returns at most limit entries.

func (*ConsoleLogStore) GetErrorLogs added in v0.8.5

func (s *ConsoleLogStore) GetErrorLogs(tabID string, limit int) []ErrorEntry

GetErrorLogs returns error logs for a tab. If limit > 0, returns at most limit entries.

func (*ConsoleLogStore) RemoveTab added in v0.8.5

func (s *ConsoleLogStore) RemoveTab(tabID string)

RemoveTab removes all logs for a tab (call on tab close).

type ContentParams added in v0.14.0

type ContentParams struct {
	ContentGuard *contentguard.Scanner
	MaxDepth     int // max AX tree depth for snapshots; 0 or -1 means unlimited
	SkipMetadata bool
}

type CookieData added in v0.14.0

type CookieData = runtimetypes.CookieData

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

type CrashEvent added in v0.7.7

type CrashEvent struct {
	Time       time.Time `json:"time"`
	TargetID   string    `json:"targetId,omitempty"`
	TabID      string    `json:"tabId,omitempty"`
	URL        string    `json:"url,omitempty"`
	Reason     string    `json:"reason"`
	LastError  string    `json:"lastError,omitempty"`
	Generation uint64    `json:"-"`
}

CrashEvent contains information about a crash. Generation identifies the browser context that was live when the crash was recorded; it is internal to the liveness lookup and never appears in /health or /metrics output.

func CrashForBrowserContext added in v0.15.1

func CrashForBrowserContext(ctx context.Context) (CrashEvent, bool)

CrashForBrowserContext returns the most recent crash recorded for the browser context the caller is serving, if any. Crashes from a browser that has since been replaced belong to an earlier generation and are not reported, so a recovered browser stops answering for its predecessor's death.

type CrashHandler added in v0.7.7

type CrashHandler func(event CrashEvent)

CrashHandler is called when a crash is detected

type DeviceMetricsOverrideParams added in v0.14.0

type DeviceMetricsOverrideParams struct {
	Width             int64
	Height            int64
	DeviceScaleFactor float64
	Mobile            bool
	ScreenWidth       int64
	ScreenHeight      int64
}

type DialogManager added in v0.8.3

type DialogManager = bridgetabs.DialogManager

func NewDialogManager added in v0.8.3

func NewDialogManager() *DialogManager

type DialogResult added in v0.8.3

type DialogResult = bridgetabs.DialogResult

func HandlePendingDialog added in v0.8.3

func HandlePendingDialog(ctx context.Context, tabID string, dm *DialogManager, accept bool, promptText string) (*DialogResult, error)

type DialogState added in v0.8.3

type DialogState = bridgetabs.DialogState

type DownloadOpts added in v0.14.0

type DownloadOpts = runtimetypes.DownloadOpts

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

type DownloadResult added in v0.14.0

type DownloadResult = runtimetypes.DownloadResult

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

type ErrDialogBlocking added in v0.10.0

type ErrDialogBlocking struct {
	DialogType    string
	DialogMessage string
}

ErrDialogBlocking is returned when a click action is blocked by a JavaScript dialog (alert/confirm/prompt) and no --dialog-action was provided.

func (*ErrDialogBlocking) Error added in v0.10.0

func (e *ErrDialogBlocking) Error() string

type ErrorEntry added in v0.8.5

type ErrorEntry struct {
	Timestamp time.Time `json:"timestamp"`
	Message   string    `json:"message"`
	Type      string    `json:"type,omitempty"`
	URL       string    `json:"url,omitempty"`
	Line      int64     `json:"line,omitempty"`
	Column    int64     `json:"column,omitempty"`
	Stack     string    `json:"stack,omitempty"`
}

ErrorEntry represents an uncaught error/exception.

type EvalOpts added in v0.14.0

type EvalOpts = runtimetypes.EvalOpts

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

type ExecutorStats added in v0.7.8

type ExecutorStats = bridgetabs.ExecutorStats

type FrameContext added in v0.14.0

type FrameContext = bridgeobserve.FrameContext

func FetchFrameContext added in v0.14.0

func FetchFrameContext(ctx context.Context) (FrameContext, error)

type FrameElementMeta added in v0.9.1

type FrameElementMeta struct {
	TagName string `json:"tagName"`
	ID      string `json:"id,omitempty"`
	Name    string `json:"name,omitempty"`
	Title   string `json:"title,omitempty"`
	Src     string `json:"src,omitempty"`
}

func ResolveFrameElementMetaInFrame added in v0.9.1

func ResolveFrameElementMetaInFrame(ctx context.Context, sel selector.Selector, frameID string) (FrameElementMeta, error)

type FrameScope added in v0.9.1

type FrameScope struct {
	FrameID   string `json:"frameId,omitempty"`
	FrameURL  string `json:"frameUrl,omitempty"`
	FrameName string `json:"frameName,omitempty"`
	OwnerRef  string `json:"ownerRef,omitempty"`
}

func (FrameScope) Active added in v0.9.1

func (s FrameScope) Active() bool

type Instance

type Instance struct {
	ID             string          `json:"id"`            // Hash-based ID: inst_XXXXXXXX
	ProfileID      string          `json:"profileId"`     // Hash-based profile ID: prof_XXXXXXXX
	ProfileName    string          `json:"profileName"`   // Human-readable profile name (for display only)
	Port           string          `json:"port"`          // Internal: instance port
	URL            string          `json:"url,omitempty"` // Canonical base URL for bridge-backed instances
	Mode           string          `json:"mode"`          // API mode: "headless" or "headed"
	Headless       bool            `json:"headless"`      // Mode: headless vs headed
	Status         string          `json:"status"`        // Status: starting/running/stopping/stopped/error
	StartTime      time.Time       `json:"startTime"`
	Error          string          `json:"error,omitempty"`      // Error message if status=error
	Attached       bool            `json:"attached"`             // True if attached rather than locally launched
	AttachType     string          `json:"attachType,omitempty"` // "cdp" or "bridge" for attached instances
	CdpURL         string          `json:"cdpUrl,omitempty"`     // CDP WebSocket URL (for CDP-attached instances)
	SecurityPolicy *SecurityPolicy `json:"securityPolicy,omitempty"`

	Browser string `json:"browser,omitempty"`

	// FallbackFrom/FallbackReason: omitempty keeps successful-launch
	// Instance JSON byte-identical to pre-P2.4a output.
	FallbackFrom   string `json:"fallbackFrom,omitempty"`
	FallbackReason string `json:"fallbackReason,omitempty"`
}

func (Instance) MarshalJSON added in v0.10.0

func (i Instance) MarshalJSON() ([]byte, error)

type InstanceTab

type InstanceTab struct {
	ID         string `json:"id"`         // Runtime tab ID (raw CDP target ID on this branch)
	InstanceID string `json:"instanceId"` // Hash-based instance ID: inst_XXXXXXXX
	URL        string `json:"url"`
	Title      string `json:"title"`
}

type LockInfo

type LockInfo = bridgetabs.LockInfo

type LockManager

type LockManager = bridgetabs.LockManager

func NewLockManager

func NewLockManager() *LockManager

type LogEntry added in v0.8.5

type LogEntry struct {
	Timestamp time.Time `json:"timestamp"`
	Level     string    `json:"level"`
	Message   string    `json:"message"`
	Source    string    `json:"source,omitempty"`
}

LogEntry represents a single console log entry.

type MemoryMetrics added in v0.7.7

type MemoryMetrics = bridgeobserve.MemoryMetrics
type NavigateParams struct {
	MaxRedirects int
	// DispatchOnly sends Page.navigate and returns after Chrome accepts it,
	// without waiting for load/ready state. The caller must poll the explicit
	// tab for readiness. This is used for headed background tabs whose SPA load
	// event can remain pending indefinitely without ever activating the window.
	DispatchOnly       bool
	AllowInternal      bool
	TrustedProxyCIDRs  []net.IPNet
	TrustedResolvedIPs []net.IP
	IDPIGuard          idpi.Guard
	// NoEscalate makes a static-first bridge return *StaticEscalateError
	// instead of internally escalating to Chrome. Handlers use it to defer
	// the Chrome launch until the static path has proven insufficient.
	NoEscalate bool
	// SkipStatic bypasses the static-first attempt entirely (the handler
	// already ran it via NoEscalate and is escalating).
	SkipStatic bool
}
type NavigateResult struct {
	TabID string
	URL   string
	Title string
	Route *browserops.RouteMetadata
}

type NetworkBuffer added in v0.8.3

type NetworkBuffer = bridgeobserve.NetworkBuffer

func NewNetworkBuffer added in v0.8.3

func NewNetworkBuffer(size int) *NetworkBuffer

type NetworkConditions added in v0.14.0

type NetworkConditions = runtimetypes.NetworkConditions

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

type NetworkEntry added in v0.8.3

type NetworkEntry = bridgeobserve.NetworkEntry

type NetworkEventHandler added in v0.14.0

type NetworkEventHandler struct {
	OnRequestWillBeSent func(frameID, requestID string, resourceType string)
	OnResponseReceived  func(requestID string, remoteIPAddress string)
}

type NetworkFilter added in v0.8.3

type NetworkFilter = bridgeobserve.NetworkFilter

type NetworkMonitor added in v0.8.3

type NetworkMonitor = bridgeobserve.NetworkMonitor

func NewNetworkMonitor added in v0.8.3

func NewNetworkMonitor(bufferSize int) *NetworkMonitor

type NodeInfo added in v0.14.0

type NodeInfo = runtimetypes.NodeInfo

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

type OrchestratorService

type OrchestratorService interface {
	RegisterHandlers(mux *http.ServeMux)
	Launch(name, port string, headless bool, extensionPaths []string) (*Instance, error)
	Stop(id string) error
	StopProfile(name string) error
	List() []Instance
	Logs(id string) (string, error)
	FirstRunningURL() string
	AllTabs() []InstanceTab
	FindInstanceByTab(tabID string) (*Instance, bool)
	ScreencastURL(instanceID, tabID string) string
	Shutdown()
	ForceShutdown()
}

type PDFParams added in v0.14.0

type PDFParams = runtimetypes.PDFParams

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

type PairedResult added in v0.13.2

type PairedResult struct {
	URL        string
	Title      string
	CapturedAt time.Time
	DurationMs int64

	FrameID   string
	LoaderID  string
	DomEpoch  string
	Navigated bool

	ImageBytes  []byte
	ImageFormat string // "jpeg" or "png"

	// Viewport metadata captured alongside the image. CoordinateSpace is
	// "viewport" by default, "document" when ImageOpts.BeyondViewport is true,
	// and "clip" for selector-clipped captures. Bounding boxes are expressed in
	// the named space.
	Viewport        ViewportInfo
	CoordinateSpace string
	Clip            *page.Viewport

	Filter string
	Nodes  []A11yNode
	Refs   map[string]int64
}

func PairedCapture added in v0.13.2

func PairedCapture(ctx context.Context, opts CaptureOpts) (*PairedResult, error)

PairedCapture runs a screenshot and an accessibility snapshot under the same chromedp context. The atomicity guarantee is "no main-frame navigation between the two CDP calls" — checked by comparing the main frame's loaderId before and after the capture window. opts.Wait == "stable" adds a Page.lifecycleEvent quiet-window wait before the window opens. opts.WithBounds populates a viewport-, document-, or clip-relative BoundingBox per snapshot node via DOM.getBoxModel. Residual risk: in-document churn (React re-renders, IntersectionObserver mutations) is not detected — wait:stable reduces but does not eliminate it.

type ProfileInfo

type ProfileInfo struct {
	ID                string    `json:"id,omitempty"`
	Name              string    `json:"name"`
	Path              string    `json:"path,omitempty"`
	PathExists        bool      `json:"pathExists,omitempty"`
	Created           time.Time `json:"created"`
	LastUsed          time.Time `json:"lastUsed"`
	DiskUsage         int64     `json:"diskUsage"`
	Running           bool      `json:"running"`
	Temporary         bool      `json:"temporary,omitempty"`   // ephemeral instance profiles (auto-generated)
	Quarantined       bool      `json:"quarantined,omitempty"` // corrupted profiles renamed aside by quarantine
	Source            string    `json:"source,omitempty"`
	ChromeProfileName string    `json:"chromeProfileName,omitempty"`
	AccountEmail      string    `json:"accountEmail,omitempty"`
	AccountName       string    `json:"accountName,omitempty"`
	HasAccount        bool      `json:"hasAccount,omitempty"`
	UseWhen           string    `json:"useWhen,omitempty"`
	Description       string    `json:"description,omitempty"`
}

type ProfileService

type ProfileService interface {
	RegisterHandlers(mux *http.ServeMux)
	List() ([]ProfileInfo, error)
	Create(name string) error
	Import(name, sourcePath string) error
	Reset(name string) error
	Delete(name string) error
	Logs(name string, limit int) []ActionRecord
	Analytics(name string) AnalyticsReport
	RecordAction(profile string, record ActionRecord)
}

type QuarantineRemoval added in v0.15.1

type QuarantineRemoval struct {
	Path  string
	Bytes int64
}

func PruneQuarantinedProfiles added in v0.15.1

func PruneQuarantinedProfiles(profileDir, justCreated string, keep int) ([]QuarantineRemoval, error)

PruneQuarantinedProfiles keeps the newest `keep` quarantined siblings of one profile and removes the rest, returning what it reclaimed. It carries the AUTOMATIC retention policy — a keep count of zero or less means keep everything — which is why the on-demand reclaim below does not go through it: there is no keep value that means "remove them all", so remove-all is expressed by asking removeQuarantinedProfiles for an unranked selection rather than by a sentinel keep count. Both end at the same deleter.

It is not the only code that can remove a quarantine directory: DELETE /profiles/{id} resolves an id through the profile listing — where a quarantine appears under its own id — and calls ProfileManager.Delete, which removes the directory by name with neither guard. That route is authenticated and audit-logged and is arguably the reclaim a user wants, so the distinction to preserve is which deleter is scoped, not which one exists. TestOnlyOneFunctionRemovesADirectoryUnderTheProfilesBase is the census of that set.

A user who names a profile exactly "<other profile>.quarantine-<digits>" is indistinguishable on disk from a real quarantine; nothing here can tell them apart, and what bounds the exposure is the sibling scope. See TestPruneOnlyReachesALookalikeThroughItsNamesakeAndStillKeepsTheNewest.

justCreated is excluded by PATH, not by being newest: quarantine may proceed while a dying browser still holds the directory, so the one entry that can still be written to must survive a same-second timestamp tie.

func ReclaimQuarantinedProfiles added in v0.15.1

func ReclaimQuarantinedProfiles(baseDir, only string) ([]QuarantineRemoval, error)

ReclaimQuarantinedProfiles removes the quarantined directories a reclaim selects, on demand and with no retention policy: this is the half PruneQuarantinedProfiles cannot express, and it stays reachable when quarantineKeep is set to keep everything.

func ReclaimableQuarantinedProfiles added in v0.15.1

func ReclaimableQuarantinedProfiles(baseDir, only string) ([]QuarantineRemoval, error)

ReclaimableQuarantinedProfiles reports what a reclaim would remove and what it would free, removing nothing. It is the dry run the bare command depends on.

type RawAXNode

type RawAXNode = bridgeobserve.RawAXNode

func FetchAXTree added in v0.8.0

func FetchAXTree(ctx context.Context) ([]RawAXNode, error)

func FilterAXNodesByFrame added in v0.14.0

func FilterAXNodesByFrame(nodes []RawAXNode, frameID string) []RawAXNode

FilterAXNodesByFrame keeps only nodes whose FrameID matches frameID; an empty frameID returns nodes unchanged. Shared by paired capture and the handler snapshot/annotated-screenshot flows so frame-scoped filtering cannot drift.

func FilterSubtree

func FilterSubtree(nodes []RawAXNode, scopeBackendID int64) []RawAXNode

type RawAXProp

type RawAXProp = bridgeobserve.RawAXProp

type RawAXValue

type RawAXValue = bridgeobserve.RawAXValue

type RawCookie added in v0.14.0

type RawCookie struct {
	Name     string  `json:"name"`
	Value    string  `json:"value"`
	Domain   string  `json:"domain"`
	Path     string  `json:"path"`
	Expires  float64 `json:"expires"`
	Secure   bool    `json:"secure"`
	HTTPOnly bool    `json:"httpOnly"`
	SameSite string  `json:"sameSite"`
}

type RawFrame added in v0.9.1

type RawFrame = bridgeobserve.RawFrame

type RawFrameTree added in v0.9.1

type RawFrameTree = bridgeobserve.RawFrameTree

func FetchFrameTree added in v0.9.1

func FetchFrameTree(ctx context.Context) (RawFrameTree, error)

type RawSetCookieParams added in v0.14.0

type RawSetCookieParams struct {
	Name     string
	Value    string
	Domain   string
	Path     string
	Secure   bool
	HTTPOnly bool
	SameSite string // "Strict", "Lax", "None", or ""
}

RawSetCookieParams holds parameters for setting a cookie via CDP network domain, used by state.go to restore cookies from state files without importing cdproto.

type RefBook added in v0.15.1

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

RefBook gives each backend DOM node a stable ref within a DOM epoch: a node keeps the ref it was first assigned, and an unseen node gets the next number. This is what makes a ref denote a node rather than a row index, so the same node keeps its ref across a change of filter, depth, selector, token budget or republish. Refs are therefore sparse in a filtered view. A node with a zero backend id carries no identity: alongside resolvable nodes it gets a fresh ref every read and is never resolvable, so its instability is harmless; a snapshot made entirely of such nodes is a statically fetched page whose refs are kept stable per element by the static browser itself and are preserved untouched.

func NewRefBook added in v0.15.1

func NewRefBook() *RefBook

func (*RefBook) Rebind added in v0.15.1

func (b *RefBook) Rebind(nodes []A11yNode) map[string]int64

Rebind stamps each node with its stable ref and returns the ref→backend-node map for the resolvable nodes. A snapshot carrying no resolvable node is a statically fetched page: the static browser already keeps each ref stable per element, so its refs are left untouched — renumbering them against this book's counter would put them out of step with the static browser's own ref→element map and resolve a later action to the wrong element.

type RefCache

type RefCache struct {
	Refs     map[string]int64
	Targets  map[string]RefTarget
	Nodes    []A11yNode
	DomEpoch string
	Book     *RefBook
}

func EpochRefs added in v0.15.1

func EpochRefs(prev *RefCache, nodes []A11yNode) *RefCache

EpochRefs rebinds nodes against the tab's DOM-epoch ref book and returns the RefCache to publish. When the nodes share a backend node with the prior epoch it carries that epoch's book and vocab token, so a node keeps its ref across filter, depth, selector and republish reads and the superseded-vocabulary guard does not fire. When they share none — a fresh document — it starts a new epoch: a book numbering from e0 and a fresh vocab token.

func (*RefCache) Lookup added in v0.9.1

func (c *RefCache) Lookup(ref string) (RefTarget, bool)

Lookup answers whether a ref names a node that can be acted on. A zero backend node id is not such a node, so an entry carrying one is reported as absent — this is the single owner of that invariant, which is why neither resolveRef restates it.

Both maps need the check, and for different reasons. RefTargetsFromNodes already skips zero-id nodes, but the ghost-chrome static-snapshot route writes Targets directly and deliberately stores a zero alongside a zero in Refs: those refs exist so an agent can read a statically fetched page, before anything has escalated to Chrome and given them real node ids. Zero there means "a known ref with no live node yet", which is a third state, not a defect — the snapshot keeps returning those refs, and only resolution refuses them.

type RefTarget added in v0.9.1

type RefTarget struct {
	BackendNodeID  int64  `json:"backendNodeId"`
	FrameID        string `json:"frameId,omitempty"`
	FrameURL       string `json:"frameUrl,omitempty"`
	FrameName      string `json:"frameName,omitempty"`
	ChildFrameID   string `json:"childFrameId,omitempty"`
	ChildFrameURL  string `json:"childFrameUrl,omitempty"`
	ChildFrameName string `json:"childFrameName,omitempty"`
}

type RouteAction added in v0.11.0

type RouteAction string
const (
	RouteActionContinue RouteAction = "continue"
	RouteActionAbort    RouteAction = "abort"
	RouteActionFulfill  RouteAction = "fulfill"
)

type RouteManager added in v0.11.0

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

RouteManager tracks active per-tab interception rules. It enables CDP fetch interception lazily when the first rule is added and disables it when the last rule is removed.

func NewRouteManager added in v0.11.0

func NewRouteManager(allowedDomainsFn func() []string) *RouteManager

NewRouteManager constructs a RouteManager. allowedDomainsFn, when non-nil, is called at fulfill-time to decide whether the matched URL host is allowed to receive a fabricated response body (security.allowedDomains boundary). Pass nil to disable that check.

func (*RouteManager) AddRule added in v0.11.0

func (rm *RouteManager) AddRule(ctx context.Context, tabID string, rule RouteRule) error

AddRule installs (or replaces, by Pattern) a rule for the given tab.

func (*RouteManager) List added in v0.11.0

func (rm *RouteManager) List(tabID string) []RouteRule

func (*RouteManager) Remove added in v0.11.0

func (rm *RouteManager) Remove(ctx context.Context, tabID string, pattern string) (int, error)

Remove deletes rules matching pattern. Empty pattern removes all rules for the tab. Returns the number of rules removed. When the last rule is removed, the listener context is cancelled and CDP fetch interception is disabled.

func (*RouteManager) RemoveTab added in v0.11.0

func (rm *RouteManager) RemoveTab(tabID string)

RemoveTab drops all rule state for a tab without issuing CDP calls. It is the cleanup hook fired by TabManager when a tab closes (manual close, eviction, auto-close, or Chrome reporting the target gone). When the tab's chromedp context is already canceled, fetch.Disable would fail anyway — canceling the listener context is the only meaningful step. Without this hook, perTab[tabID] and its cancel func would leak; if Chrome ever reused the target id, a stale entry would be found.

func (*RouteManager) SetFetchAuthCoordination added in v0.14.0

func (rm *RouteManager) SetFetchAuthCoordination(proxyAuthActive func() bool, setPauseSuppressed func(tabID string, v bool))

SetFetchAuthCoordination wires the proxy-auth coordination callbacks: the gate reporting whether proxy credentials are configured, and the per-tab pause-suppression setter on the owning Bridge.

type RouteRule added in v0.11.0

type RouteRule struct {
	Pattern      string      `json:"pattern"`
	Action       RouteAction `json:"action"`
	Body         string      `json:"body,omitempty"`
	ContentType  string      `json:"contentType,omitempty"`
	Status       int         `json:"status,omitempty"`
	ResourceType string      `json:"resourceType,omitempty"`

	// Method, when non-empty, narrows matches to the given HTTP method
	// (case-insensitive). Empty Method matches any method, with one exception:
	// fulfill rules skip OPTIONS preflights by default — fulfilling preflights
	// can break or bypass CORS, so the operator must explicitly set
	// Method="OPTIONS" to opt in.
	Method string `json:"method,omitempty"`
	// contains filtered or unexported fields
}

RouteRule describes a single interception rule for a tab.

Pattern matching semantics (deliberately asymmetric, mirrors the user-facing CLI ergonomics):

  • No wildcards in Pattern → SUBSTRING match against the request URL. "tracker.io" matches "https://tracker.io/x" and "https://x?ref=tracker.io".

  • Pattern contains '*' or '?' → ANCHORED full-URL glob match. "*.png" compiles to "^.*\.png$" and matches URLs ending in .png. "*api*" matches any URL containing "api". To get substring-style matching with a wildcard, wrap the pattern in '*'s on both sides.

The asymmetry is intentional: bare strings are the common "block-this-domain" case where substring is what users mean; wildcards are the structural case (extension, host shape) where anchored full-URL is what they mean. ResourceType, when set, narrows matches to a specific CDP resource category (e.g. "script", "xhr", "image").

type ScreencastOpts added in v0.14.0

type ScreencastOpts = runtimetypes.ScreencastOpts

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

type ScreencastStream added in v0.14.0

type ScreencastStream = runtimetypes.ScreencastStream

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

type ScreenshotClip added in v0.14.0

type ScreenshotClip = page.Viewport

func ScreenshotClipForNode added in v0.14.0

func ScreenshotClipForNode(ctx context.Context, nodeID int64) (*ScreenshotClip, error)

ScreenshotClipForNode returns a page-coordinate clip for a backend node ID. Handlers use this bridge-owned helper so CDP details stay out of the handler layer.

type ScreenshotFormat added in v0.14.0

type ScreenshotFormat = page.CaptureScreenshotFormat

type ScreenshotOpts added in v0.13.2

type ScreenshotOpts struct {
	Format         page.CaptureScreenshotFormat
	Quality        int
	Clip           *page.Viewport
	BeyondViewport bool

	// Scale rescales the rendered output bitmap. 1 (or 0) = native. 0.5
	// halves the image in each axis (quarter of the pixels). Applied via
	// CDP's clip.scale; when no Clip is otherwise set we synthesize one
	// covering the viewport so the parameter takes effect.
	Scale float64

	// ViewportWidth/ViewportHeight are used only when Scale != 1 and Clip is
	// nil — to build a viewport-covering clip. Callers fetch these from
	// observe.FetchLayout (or similar) before invoking CaptureScreenshot.
	ViewportWidth  float64
	ViewportHeight float64

	// DisableActivation suppresses the Page.bringToFront call that wakes a
	// backgrounded tab's compositor before capturing (the inverse of
	// instanceDefaults.captureAllowActivation, default true — so the zero
	// value here is the safe/reliable default even if a caller forgets to
	// set it). When true, capture relies solely on focus emulation and never
	// raises the tab in the operator's browser, accepting that a background
	// tab's capture may then block until the caller's deadline.
	DisableActivation bool
}

ScreenshotOpts mirrors the subset of page.CaptureScreenshot parameters the callers (HandleScreenshot, PairedCapture) need to coordinate on.

type SecurityPolicy added in v0.9.1

type SecurityPolicy struct {
	AllowedDomains []string `json:"allowedDomains,omitempty"`
}

type SessionState

type SessionState struct {
	Tabs    []TabState `json:"tabs"`
	SavedAt string     `json:"savedAt"`
}

type SetCookieParams added in v0.14.0

type SetCookieParams = runtimetypes.SetCookieParams

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

type SnapshotResult added in v0.14.0

type SnapshotResult struct {
	Nodes       []A11yNode
	Refs        map[string]int64
	Targets     map[string]RefTarget
	URL         string
	Title       string
	Truncated   bool
	Hint        string
	IDPIWarning string
	Route       *browserops.RouteMetadata
}

SnapshotResult is the bridge-level response from a snapshot operation. It carries the rich A11yNode tree (not the simpler browserops.SnapshotNode) together with ref-cache data so that handlers can store it via SetRefCache without needing to call CDP directly.

type StaticEscalateError added in v0.14.0

type StaticEscalateError struct {
	Quality int
	Reason  string
	Route   *browserops.RouteMetadata
}

StaticEscalateError signals that the static-first path cannot serve a navigate (NavigateParams.NoEscalate mode) and the caller should launch Chrome and retry with SkipStatic. Route carries the static attempt's metadata so the caller can merge it with the Chrome attempt.

func (*StaticEscalateError) Error added in v0.14.0

func (e *StaticEscalateError) Error() string

type TabEntry

type TabEntry struct {
	Ctx                   context.Context
	Cancel                context.CancelFunc
	Accessed              bool
	CDPID                 string // raw CDP target ID
	CreatedAt             time.Time
	LastUsed              time.Time
	Policy                TabPolicyState
	Watching              bool
	ConsoleCaptureEnabled bool
	// contains filtered or unexported fields
}

type TabExecutor added in v0.7.8

type TabExecutor = bridgetabs.TabExecutor

func NewTabExecutor added in v0.7.8

func NewTabExecutor(maxParallel int) *TabExecutor

type TabHandle added in v0.14.0

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

TabHandle wraps a chromedp-enriched context, providing an opaque return type from TabContext(). Handlers receive *TabHandle instead of a raw context.Context, signaling that the context should only be passed to Bridge methods — not to chromedp directly.

TabHandle fully implements context.Context, delegating all methods (including Value) to the underlying CDP context.

func NewTabHandle added in v0.14.0

func NewTabHandle(cdpCtx context.Context) *TabHandle

func (*TabHandle) Deadline added in v0.14.0

func (h *TabHandle) Deadline() (time.Time, bool)

func (*TabHandle) Done added in v0.14.0

func (h *TabHandle) Done() <-chan struct{}

func (*TabHandle) Err added in v0.14.0

func (h *TabHandle) Err() error

func (*TabHandle) Value added in v0.14.0

func (h *TabHandle) Value(key any) any

type TabHandoffState added in v0.9.0

type TabHandoffState struct {
	Status        string    `json:"status"`
	Reason        string    `json:"reason,omitempty"`
	PausedAt      time.Time `json:"pausedAt"`
	LastUpdatedAt time.Time `json:"lastUpdatedAt"`
	ExpiresAt     time.Time `json:"expiresAt,omitempty"`
}

TabHandoffState tracks manual handoff pauses per tab.

type TabLimitError added in v0.7.8

type TabLimitError struct {
	Current int
	Max     int
}

TabLimitError is returned when a new tab cannot be created because the configured limit has been reached and the eviction policy is "reject". HTTP handlers should map this to 429 Too Many Requests.

func (*TabLimitError) Error added in v0.7.8

func (e *TabLimitError) Error() string

type TabLogs added in v0.8.5

type TabLogs struct {
	Console []LogEntry
	Errors  []ErrorEntry
	// contains filtered or unexported fields
}

TabLogs holds console and error logs for a single tab.

type TabManager

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

func NewTabManager

func NewTabManager(browserCtx context.Context, cfg *config.RuntimeConfig, idMgr *ids.Manager, logStore *ConsoleLogStore, onTabSetup TabSetupFunc) *TabManager

func (*TabManager) AccessedTabIDs added in v0.6.2

func (tm *TabManager) AccessedTabIDs() map[string]bool

AccessedTabIDs returns the set of tab IDs that were accessed this session.

func (*TabManager) AddTabRemovedHook added in v0.14.0

func (tm *TabManager) AddTabRemovedHook(fn func(tabID string))

AddTabRemovedHook registers a per-tab cleanup callback fired alongside the route/log/executor cleanup whenever a tracked tab is removed. Multiple hooks may be registered; each must be best-effort and must not panic.

func (*TabManager) CancelAutoClose added in v0.11.0

func (tm *TabManager) CancelAutoClose(tabID string)

CancelAutoClose stops the per-tab idle close timer if any. Safe to call when no timer is armed; bumps the generation so an already-fired-but-not-yet-run callback will recognise itself as stale.

func (*TabManager) CleanStaleTabs

func (tm *TabManager) CleanStaleTabs(ctx context.Context, interval time.Duration)

func (*TabManager) ClearFrameScope added in v0.9.1

func (tm *TabManager) ClearFrameScope(tabID string)

func (*TabManager) CloseTab

func (tm *TabManager) CloseTab(tabID string) error

func (*TabManager) CreateTab

func (tm *TabManager) CreateTab(url string) (string, context.Context, context.CancelFunc, error)

func (*TabManager) CreateTabInBrowserContext added in v0.15.1

func (tm *TabManager) CreateTabInBrowserContext(url, browserContextID string) (string, context.Context, context.CancelFunc, error)

func (*TabManager) DeleteRefCache

func (tm *TabManager) DeleteRefCache(tabID string)

func (*TabManager) EnsureConsoleCapture added in v0.8.6

func (tm *TabManager) EnsureConsoleCapture(tabID string)

func (*TabManager) Execute added in v0.7.8

func (tm *TabManager) Execute(ctx context.Context, tabID string, task func(ctx context.Context) error) error

Execute runs a task for a tab through the TabExecutor, ensuring per-tab sequential execution with cross-tab parallelism bounded by the semaphore. If the TabExecutor has not been initialized, the task runs directly.

func (*TabManager) Executor added in v0.7.8

func (tm *TabManager) Executor() *TabExecutor

Executor returns the underlying TabExecutor (may be nil).

func (*TabManager) FocusTab added in v0.8.2

func (tm *TabManager) FocusTab(tabID string) error

func (*TabManager) GetFrameScope added in v0.9.1

func (tm *TabManager) GetFrameScope(tabID string) (FrameScope, bool)

func (*TabManager) GetRefCache

func (tm *TabManager) GetRefCache(tabID string) *RefCache

func (*TabManager) GetTabPolicyState added in v0.8.4

func (tm *TabManager) GetTabPolicyState(tabID string) (TabPolicyState, bool)

func (*TabManager) ListTargets

func (tm *TabManager) ListTargets() ([]*target.Info, error)

func (*TabManager) ListTargetsWithContext added in v0.7.7

func (tm *TabManager) ListTargetsWithContext(ctx context.Context) ([]*target.Info, error)

ListTargetsWithContext is like ListTargets but uses a custom context for timeout control.

func (*TabManager) RegisterTab

func (tm *TabManager) RegisterTab(tabID string, ctx context.Context)

func (*TabManager) RegisterTabWithCancel added in v0.7.8

func (tm *TabManager) RegisterTabWithCancel(tabID, rawCDPID string, ctx context.Context, cancel context.CancelFunc)

RegisterTabWithCancel registers a tab ID with its context and cancel function.

func (*TabManager) ResolveTabByIndex added in v0.8.2

func (tm *TabManager) ResolveTabByIndex(index int) (string, string, string, error)

ResolveTabByIndex resolves a 1-based tab index to a tab ID.

func (*TabManager) ScheduleAutoClose added in v0.11.0

func (tm *TabManager) ScheduleAutoClose(tabID string)

ScheduleAutoClose (re)arms the per-tab idle close timer when the lifecycle policy is "close_idle". Idempotent: any prior timer for the tab is stopped first. Safe to call from handler goroutines.

func (*TabManager) SetDialogManager added in v0.8.3

func (tm *TabManager) SetDialogManager(dm *DialogManager)

func (*TabManager) SetFrameScope added in v0.9.1

func (tm *TabManager) SetFrameScope(tabID string, scope FrameScope)

func (*TabManager) SetNetworkMonitor added in v0.9.0

func (tm *TabManager) SetNetworkMonitor(nm *NetworkMonitor)

func (*TabManager) SetOnAfterClose added in v0.11.0

func (tm *TabManager) SetOnAfterClose(fn func())

SetOnAfterClose registers a callback fired whenever a tracked tab is removed from the manager — manual /close, eviction, auto-close lifecycle timer, or Chrome reporting the target gone (e.g. user closing it in a headed window). Used by the parent Bridge to persist session state immediately rather than waiting for graceful shutdown.

func (*TabManager) SetRefCache

func (tm *TabManager) SetRefCache(tabID string, cache *RefCache)

func (*TabManager) SetRouteManager added in v0.11.0

func (tm *TabManager) SetRouteManager(rm *RouteManager)

SetRouteManager registers the per-bridge RouteManager so the cleanup path can drop a tab's interception state when the tab closes (mirrors the network-monitor / log-store / executor cleanup hooks in tab_cleanup.go).

func (*TabManager) SetTabPolicyState added in v0.8.4

func (tm *TabManager) SetTabPolicyState(tabID string, state TabPolicyState)

func (*TabManager) StartBrowserGuards added in v0.8.4

func (tm *TabManager) StartBrowserGuards()

func (*TabManager) TabContext

func (tm *TabManager) TabContext(tabID string) (context.Context, string, error)

type TabPolicyState added in v0.8.4

type TabPolicyState struct {
	CurrentURL string
	Threat     bool
	Blocked    bool
	Reason     string
	UpdatedAt  time.Time
}

func EvaluateTabPolicy added in v0.8.4

func EvaluateTabPolicy(rawURL string, cfg config.IDPIConfig, allowedDomains []string) TabPolicyState

type TabSetupFunc

type TabSetupFunc func(ctx context.Context, tabID string) error

type TabState

type TabState struct {
	ID            string `json:"id"`
	URL           string `json:"url"`
	Title         string `json:"title"`
	Status        string `json:"status,omitempty"`
	HandoffReason string `json:"handoffReason,omitempty"`
}

type TabTarget added in v0.14.0

type TabTarget struct {
	TargetID         string `json:"targetId"`
	URL              string `json:"url"`
	Title            string `json:"title"`
	Type             string `json:"type"`
	BrowserContextID string `json:"browserContextId,omitempty"`
}

type TextResult added in v0.14.0

type TextResult struct {
	Text        string
	URL         string
	Title       string
	Truncated   bool
	IDPIWarning string
	Route       *browserops.RouteMetadata
}

type URLReader added in v0.9.0

type URLReader func(ctx context.Context) (string, error)

URLReader is used by guards to read the current tab URL from an action context.

type UserAgentOverrideParams added in v0.14.0

type UserAgentOverrideParams struct {
	UserAgent      string
	Platform       string
	AcceptLanguage string
}

type ViewportInfo added in v0.13.2

type ViewportInfo = bridgeobserve.ViewportInfo

func FetchLayout added in v0.13.2

func FetchLayout(ctx context.Context) (ViewportInfo, error)

type ViewportParams added in v0.14.0

type ViewportParams = runtimetypes.ViewportParams

Construct ScreencastStream via runtimetypes.NewScreencastStreamWithDone (the bridge screencast loop owns and closes the done channel itself).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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