Documentation
¶
Overview ¶
Package browser holds the connection-layer logic for reaching Chrome over CDP: the DevToolsActivePort reader (Path B) and the connection-ladder decision. It is deliberately free of chromedp so it unit-tests without a live browser.
Index ¶
- func CandidatePortFiles() []string
- func EndpointKey(portFile string, port int) string
- func FindPortFile(override string) string
- func HostPort(wsURL string) (string, bool)
- func ParseDevToolsActivePort(content []byte) (port int, wsPath string, err error)
- func WSURLFromPortFile(path string) (string, error)
- type Action
- type Probe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CandidatePortFiles ¶
func CandidatePortFiles() []string
CandidatePortFiles returns the OS-specific locations Chrome writes DevToolsActivePort to (Chrome family), first match wins. Overridable by the caller via CHROME_CDP_PORT_FILE.
func EndpointKey ¶
EndpointKey identifies the debug endpoint a command targets, so the daemon socket and sticky state are keyed to the actual Chrome instance rather than a fixed port. An explicit --port wins (distinct ports get distinct keys); otherwise the key comes from the discovered DevToolsActivePort file, falling back to "default".
func FindPortFile ¶
FindPortFile returns the DevToolsActivePort path to use: an explicit override, else $CHROME_CDP_PORT_FILE, else the first existing OS candidate ("" if none).
func ParseDevToolsActivePort ¶
ParseDevToolsActivePort parses the two-line DevToolsActivePort file (line 1 = port, line 2 = the browser-level ws path).
func WSURLFromPortFile ¶
WSURLFromPortFile reads a DevToolsActivePort file and returns the literal browser-level WebSocket URL to hand to chromedp.NewRemoteAllocator.
Types ¶
type Action ¶
type Action int
Action is the connection-ladder outcome for a given Probe.
func DecideConnection ¶
DecideConnection walks the connection ladder:
- reachable debug endpoint -> Attach (Path B)
- no reachable endpoint, Chrome up -> InstructToggle (use the running session; never shadow it)
- no reachable endpoint, no Chrome -> Launch (Path A) unless --no-launch
- ...with --no-launch -> InstructNoLaunch
type Probe ¶
type Probe struct {
PortFileWS string // ws:// from DevToolsActivePort, or "" if unavailable
WSReachable bool // did a WS connect to PortFileWS succeed?
ChromeRunning bool // is a Chrome process running (possibly without debug)?
NoLaunch bool // the --no-launch flag
}
Probe captures the observable connection state the ladder decides on.