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 ¶
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 ¶
This section is empty.
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.
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 PlatformKey ¶
PlatformKey returns the CfT platform string for the current OS/arch.
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.