Documentation
¶
Index ¶
- func DispatchStartURL(ctx context.Context, devtoolsURL, url string) error
- type BrowserVersion
- type Client
- func (c *Client) Close() error
- func (c *Client) CountPageTargets(ctx context.Context) (int, error)
- func (c *Client) GetBrowserVersion(ctx context.Context) (*BrowserVersion, error)
- func (c *Client) GetHistograms(ctx context.Context, query string) ([]Histogram, error)
- func (c *Client) GetWindowBounds(ctx context.Context) (WindowBounds, error)
- func (c *Client) SetDeviceMetricsOverride(ctx context.Context, width, height int) error
- func (c *Client) SetWindowBoundsMaximized(ctx context.Context) error
- type Histogram
- type HistogramBucket
- type WindowBounds
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BrowserVersion ¶
type BrowserVersion struct {
ProtocolVersion string `json:"protocolVersion"`
Product string `json:"product"`
Revision string `json:"revision"`
UserAgent string `json:"userAgent"`
JsVersion string `json:"jsVersion"`
}
BrowserVersion is the result of a Browser.getVersion CDP call.
We use this struct only to confirm a successful round-trip; callers that just need a liveness probe can ignore the fields. The protocol-version fields are populated for convenience.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a minimal CDP client that communicates over a browser-level DevTools WebSocket connection.
func (*Client) CountPageTargets ¶
CountPageTargets returns the number of open page targets.
func (*Client) GetBrowserVersion ¶
func (c *Client) GetBrowserVersion(ctx context.Context) (*BrowserVersion, error)
GetBrowserVersion sends Browser.getVersion on the browser-level DevTools endpoint. It is a cheap CDP round-trip that proves the WebSocket is connected to a live, CDP-responsive Chromium browser process.
Callers should use this after Dial as a readiness gate: a successful websocket.Dial alone is not enough because a dial can complete against a half-open socket of a killed Chromium, or against a freshly bound TCP listener of a Chromium that has not yet wired up its CDP routes. A Browser.getVersion round-trip rules out both cases.
func (*Client) GetHistograms ¶
GetHistograms sends Browser.getHistograms, a browser-level command that reads Chrome's in-memory UMA histograms without attaching to any page. query is a substring filter on the histogram name; empty returns all.
func (*Client) GetWindowBounds ¶
func (c *Client) GetWindowBounds(ctx context.Context) (WindowBounds, error)
GetWindowBounds queries the OS window bounds for the first page target via Browser.getWindowForTarget. It's a one-shot read; callers that need to wait for the WM to settle should poll this.
func (*Client) SetDeviceMetricsOverride ¶
SetDeviceMetricsOverride sets the viewport dimensions on the first page target found in the browser. It attaches to the target with a flattened session, sends Emulation.setDeviceMetricsOverride, then detaches.
func (*Client) SetWindowBoundsMaximized ¶
SetWindowBoundsMaximized puts the OS window backing the first page target into the maximized state via Browser.setWindowBounds. It is idempotent — invoking it on a window already in maximized state is a no-op.
A mutter-managed window in maximized state auto-tracks RANDR resizes (the WM reflows it to fill the new root). So after a display resize the server only has to make sure the window is in maximized state; mutter does the rest. This replaces the prior approach of restarting chromium so it could re-apply --start-maximized.
We intentionally avoid the explicit-bounds form of setWindowBounds ({left, top, width, height} with windowState:"normal"): once a window is in normal state it stops auto-tracking subsequent RANDR events.
type Histogram ¶
type Histogram struct {
Name string `json:"name"`
Sum int64 `json:"sum"`
Count int64 `json:"count"`
Buckets []HistogramBucket `json:"buckets"`
}
Histogram is a snapshot of a Chrome UMA histogram as returned by Browser.getHistograms. Values are cumulative since browser start and the units follow the UMA definition of the histogram (PageLoad timings are milliseconds). Only buckets with at least one sample are present.
type HistogramBucket ¶
type HistogramBucket struct {
Low int64 `json:"low"`
High int64 `json:"high"`
Count int64 `json:"count"`
}
HistogramBucket is a [Low, High) bucket of a Histogram.
type WindowBounds ¶
WindowBounds is the subset of Browser.getWindowBounds CDP returns that callers care about. For maximized/fullscreen windows the width/height fields reflect the live window size (which the WM aligns with the X root); for normal-state windows they reflect the saved-restore bounds.