browsercheck

package
v0.0.0-...-34312ec Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 26 Imported by: 0 modules, 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

Ported from browser-use/browser-use@dfb6a73 browser_use/browser/local.py

Ported from browser-use/browser-use@dfb6a73 browser_use/repl/session.py

Ported from browser-use/browser-use@dfb6a73 browser_use/ax.py

Package browsercheck drives headless Chrome through a list of steps and reports one FACTORY_GATES line. ParseSteps reads the YAML step list, Run executes it and stops at the first failing step, and Result.Line renders the gate line. The factory browsercheck command in cmd/factory is the caller.

Index

Constants

View Source
const TempPrefix = "factory-browsercheck-"

TempPrefix starts the name of every temp dir a run makes; SweepStale only touches names with it.

Variables

This section is empty.

Functions

func CopyProfile

func CopyProfile(root, dir, dst string) error

CopyProfile copies Local State and one profile directory from a Chrome user-data-dir into dst, without caches, lock files or the other profiles. Symlinks are copied as symlinks.

func LookChrome

func LookChrome(look func(string) (string, error)) (string, error)

LookChrome returns the first Chrome binary found through look, or an error when there is none.

func NewCommand

func NewCommand() *cobra.Command

NewCommand returns `browsercheck`, the command the browser check pack runs. It prints one FACTORY_GATES line and exits non-zero when a step fails or Chrome is missing.

func SkipCopy

func SkipCopy(name string) bool

SkipCopy reports whether a file or dir name is left out of a profile copy.

func SweepStale

func SweepStale(root string, now time.Time)

SweepStale deletes temp dirs left in root by runs that died without cleaning up (SIGKILL, OOM, a crash): a profile copy holds the user's cookies. A dir whose owner still runs stays locked, a dir younger than a minute is skipped, and a dir with no owner file is not ours to judge.

Types

type Conditions

type Conditions struct {
	Ready   bool // document is not loading
	Quiet   bool // no DOM mutation or input event for the quiet window
	Network bool // no fresh in-flight request and none finished within the quiet window
}

Conditions picks which signals Settle waits for.

type Options

type Options struct {
	Steps  []Step
	OutDir string                       // screenshots are written here
	Look   func(string) (string, error) // finds a binary on PATH; os.LookPath when nil
	// Profile is a Chrome user-data-dir whose Local State and Default profile are copied, without
	// caches, into a temp dir for the run. Empty runs with a fresh profile.
	Profile  string
	Secrets  Secrets // values type_secret may type; they never appear in the result
	TempRoot string  // where the run's temp dir goes; os.TempDir() when empty
}

Options configures Run.

type Result

type Result struct {
	Passed  int
	Failed  int
	Message string // empty when every step passed, else why the first failing step failed
}

Result is the outcome of one run.

func Run

func Run(ctx context.Context, o Options) Result

Run executes the steps in headless Chrome and stops at the first failing step. It fails, never passes, when Chrome is missing.

func (Result) Line

func (r Result) Line() string

Line returns the FACTORY_GATES line for the result.

type Secret

type Secret struct {
	Name   string
	Value  string
	Domain string // when set, the value types only on this host or a subdomain of it
}

Secret is a named value a step may type without the value ever being printed.

type Secrets

type Secrets []Secret

Secrets is the set a run may type from.

func LoadSecrets

func LoadSecrets(path string) (Secrets, error)

LoadSecrets reads a YAML map of name to value, or name to {value, domain}.

func (Secrets) Lookup

func (s Secrets) Lookup(name, host string) (string, error)

Lookup returns the value of the secret called name for a page on host. A scoped secret fails closed when host is empty or outside its domain. Errors name secrets, never values.

func (Secrets) Names

func (s Secrets) Names() []string

Names lists the secret names, sorted. The model and the logs see these, never a value.

func (Secrets) Redact

func (s Secrets) Redact(text string) string

Redact replaces every secret value, and common encodings of it, with <secret:name>. It covers the text passed in; it is not a sandbox.

type SettleResult

type SettleResult struct {
	Why  string // "quiet" when every chosen condition held, "cap" when the cap ran out
	Took time.Duration
}

SettleResult says why a Settle call returned and how long it took.

func Settle

func Settle(env settleEnv, c Conditions, cap, quiet, since time.Duration) SettleResult

Settle waits on events, never a fixed sleep: the chosen conditions must hold, bounded by cap. While the document loads the bound grows to navCap. since is when the action began, so DOM quiet from before it does not count; zero means now.

type Step

type Step struct {
	Kind     string // goto, click, fill, type_secret, expect_text, expect_no_console_error or screenshot
	URL      string // goto target
	Selector string // click and fill target
	Value    string // fill value
	Text     string // expect_text needle
	Name     string // screenshot file name without extension, or the secret name for type_secret
}

Step is one parsed browser step.

func ParseSteps

func ParseSteps(data []byte) ([]Step, error)

ParseSteps reads a YAML list of single-key step maps and validates each one.

Jump to

Keyboard shortcuts

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