Documentation
¶
Overview ¶
Package cftbrowser downloads and caches Chrome for Testing binaries from Google's official API (https://googlechromelabs.github.io/chrome-for-testing/).
Index ¶
- Constants
- Variables
- func EnsureBrowser(ctx context.Context, onProgress ProgressFunc) (string, error)
- func FindCachedBrowser() (string, error)
- func IsSupported() bool
- func Platform() string
- func PlatformKey() (string, error)
- func SystemChromium() (path, name string, err error)
- type ProgressEvent
- type ProgressFunc
Constants ¶
const ( StateStarted = "started" StateDownloading = "downloading" StateFinished = "finished" StateFailed = "failed" )
Progress states, in the order a ProgressFunc sees them: one started, any number of downloading, then exactly one finished or failed.
Variables ¶
var SystemChromiumNames = []string{"chromium", "chromium-browser", "google-chrome"}
SystemChromiumNames is the order a system browser is looked up on PATH on a platform Chrome for Testing publishes no build for (linux/arm64): Chromium under its upstream and its Debian/Ubuntu names, then Google Chrome.
Functions ¶
func EnsureBrowser ¶
func EnsureBrowser(ctx context.Context, onProgress ProgressFunc) (string, error)
EnsureBrowser downloads and caches Chrome for Testing if not already present. Returns the path to the chrome binary.
On a platform Chrome for Testing publishes no build for (linux/arm64) it downloads nothing: it returns the system browser SystemChromium resolves, logs which binary that is, and fails naming the lookup order when none is installed.
onProgress may be nil. Without it, progress is printed as text to progressOut (stderr), never stdout — the `vigolium doctor --fix` rendering. With it, the text is suppressed and the caller gets one started event, then downloading events, then exactly one finished or failed event; the caller owns the rendering.
func FindCachedBrowser ¶
FindCachedBrowser looks for an already-downloaded Chrome for Testing binary without making any network requests. Returns the binary path or an error.
func IsSupported ¶
func IsSupported() bool
IsSupported returns true if the current OS/arch has Chrome for Testing builds.
func Platform ¶ added in v0.5.8
func Platform() string
Platform names the host as "goos/goarch", the spelling messages use.
func PlatformKey ¶
PlatformKey returns the CfT platform string for the current OS/arch.
func SystemChromium ¶ added in v0.5.8
SystemChromium resolves the first of SystemChromiumNames on PATH and returns its path and the name that matched. The error names the lookup order when none resolves.
Types ¶
type ProgressEvent ¶ added in v0.5.3
type ProgressEvent struct {
State string // StateStarted, StateDownloading, StateFinished or StateFailed
Version string // CfT version, once the version index answered
Bytes int64 // archive bytes downloaded so far (finished: the archive size; 0 on a cache hit)
Total int64 // archive size from Content-Length, 0 when unknown
Err error // set on StateFailed
}
ProgressEvent is one step of an EnsureBrowser call, for callers that render provisioning themselves (the scan runner turns it into an ETA line and a scan.setup event).
type ProgressFunc ¶ added in v0.5.3
type ProgressFunc func(ProgressEvent)
ProgressFunc receives EnsureBrowser's progress. Called on the calling goroutine; downloading events arrive at most once per 5% of the archive.