cftbrowser

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
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

func FindCachedBrowser() (string, error)

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

func PlatformKey() (string, error)

PlatformKey returns the CfT platform string for the current OS/arch.

func SystemChromium added in v0.5.8

func SystemChromium() (path, name string, err error)

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.

Jump to

Keyboard shortcuts

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