chrome

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 11 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

Package chrome runs one headless Chrome through chromedp for the tools that look at a rendered page: the screenshots and the audits of the dev MCP server (REQ-AI-04) and the audits of `gx fuzz` (REQ-AI-11). The audit uses the vendored axe-core. No node.

Index

Constants

View Source
const (
	AxeVersion = "4.13.0"
	AxeSHA256  = "c24f097bd2f451d4f933e8bc7d8d539f8672a2ebcb5cc9f9f3eec8ca9470a0c1"
)

AxeVersion and AxeSHA256 pin the embedded axe-core build.

Variables

This section is empty.

Functions

func SumAxe

func SumAxe(data []byte) string

SumAxe returns the hex sha256 of an axe-core build.

Types

type AuditNode

type AuditNode struct {
	Target     []string `json:"target"`
	HTML       string   `json:"html"`
	Summary    string   `json:"summary"`
	Foreground string   `json:"foreground,omitempty"`
	Background string   `json:"background,omitempty"`
	Ratio      float64  `json:"ratio,omitempty"`
}

AuditNode is one element that fails a rule. Target is the CSS selector of the element, one entry per shadow root. For the rule color-contrast, Foreground and Background are the colours that axe measured and Ratio is their contrast; they are empty when axe could not measure them.

type AuditOptions added in v0.7.0

type AuditOptions struct {
	// DisableRules are the ids of the axe rules that do not run.
	DisableRules []string
	// ReducedMotion emulates prefers-reduced-motion: reduce, so that a
	// component that ends its transitions under it shows its final
	// colours to axe.
	ReducedMotion bool
}

AuditOptions change one audit. The zero value runs every rule with the motion settings of Chrome.

type AuditOutput

type AuditOutput struct {
	Violations []Violation `json:"violations"`
	// Passes is the number of rules that passed.
	Passes int    `json:"passes"`
	Axe    string `json:"axe"`
}

AuditOutput is the result of one audit.

type Browser

type Browser struct {
	// contains filtered or unexported fields
}

Browser is one headless Chrome. It starts on the first tab. The zero value is ready to use.

func (*Browser) Audit

func (b *Browser) Audit(ctx context.Context, target, selector string, opt AuditOptions) (AuditOutput, error)

Audit runs axe on the page at target. A selector limits the audit to one element: the rules for a whole page, such as the rule for a level-one heading, then do not apply. An empty selector audits the document.

func (*Browser) Close

func (b *Browser) Close()

Close ends Chrome.

func (*Browser) Screenshot

func (b *Browser) Screenshot(ctx context.Context, target string, width, height int) ([]byte, error)

Screenshot returns a PNG of the full page at target. A width or a height of zero is 1280 or 800.

type Violation

type Violation struct {
	ID      string      `json:"id"`
	Impact  string      `json:"impact"`
	Help    string      `json:"help"`
	HelpURL string      `json:"helpUrl"`
	Nodes   []AuditNode `json:"nodes"`
}

Violation is one failed axe rule.

Jump to

Keyboard shortcuts

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