// Package axe carries the vendored axe-core engine and runs it in a // page a browser drive is already on. The engine is test data: it is // pinned and checksummed in README.md beside it, read by the // accessibility drives, and never part of anything the root package // ships. // // Run, the half that needs a browser, is build-tagged `browser`, as // the harness is, so chromedp stays out of the plain build graph. package axe import ( _ "embed" ) // script is axe.min.js, embedded so Run can hand it to the page as // data. Only this package embeds it: the root package's tree is css/, // js/, icons/ and LICENSE, and TestVendoredAxeIsThePinnedVersion // holds the file to the README's pin. // //go:embed axe.min.js var script string // Script returns the engine's source, for a drive that injects it // into a document of its own (a preview frame, say) rather than the // page Run scans. func Script() string { return script } // defaultTags is the ruleset Scan uses when handed no tags, and it is // not negotiable downwards. WCAG 2.2 AA is cumulative: 2.2 AA means // every A and AA criterion from 2.0, 2.1 and 2.2, so all five tags // have to be named or the older half of the standard silently stops // being checked. // // Deliberately absent: best-practice, experimental and ACT tags. They // are useful advice and they are not the standard the question asked // about; mixing them in would make a failure mean two different // things. var defaultTags = []string{"wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"} // DefaultTags returns the ruleset Scan uses when handed no tags, as a // copy: a caller that appends to or reslices what it gets changes // nothing a later scan reads. func DefaultTags() []string { return append([]string(nil), defaultTags...) } // Violation is one rule that found something: its id, axe's impact // word, the one-line help text, and a selector for every node it // found, so a failure names itself. type Violation struct { ID string Impact string Help string Nodes []string }