Repository navigation
Feat/axe improvements - #147
Conversation
Report axe "incomplete" (needs-review) items separately from violations in scan_page, audit_site and scan_page_matrix, behind includeIncomplete (default true). They never contribute to violation counts or baseline diffs. Add includeSelectors/excludeSelectors on all three scan tools via a shared axeScopeSchemaShape. Selectors are resolved before the scan: axe alone only rejects a scope when the *entire* include set is empty, so one typo among several include selectors silently scanned less than requested and still returned a clean report. Invalid CSS and unmatched includes now fail; an unmatched exclude stays a no-op, since a crawl legitimately visits pages without the excluded widget. Trim scan_page node output through the shared prepareAxeResults path — raw axe nodes carry the any/all/none check arrays and serialized to ~1MB on content-heavy pages. Add maxNodesPerViolation with a "showing X of Y nodes" notice, and report the rule id/impact/help on violation blocks, which previously showed only tags and nodes. Review fixes: - defaultAxeTags did not actually make non-conformance rules opt-in. Axe matches runOnly tags with OR, so 35 best-practice/experimental rules were still selected via their cat.* tags — landmark-one-main and region appeared in default reports. The default is now the wcag*/section508 conformance tags only. The sole rules reachable exclusively through cat.* are duplicate-id and duplicate-id-active, both deprecated in Axe; that caveat is documented rather than claimed to be free. Five experimental rules that also carry a real wcag* tag still run by default, correctly, so the README no longer claims experimental is fully excluded. - Omit the "Incomplete: N" count when includeIncomplete is false; it read as findings dropped from the report. - Run link discovery before the scan in audit_site. A scoped scan that throws on one page previously took the shared catch and silently dropped every descendant reachable only through it. - scan_page_matrix shows "-" rather than "0" when incomplete collection is off. Review round 2: - structuredContent.totalIncomplete is null (not 0) when collection is off, matching the markdown table's "-". - Rejected excluding the five experimental rules that also carry real wcag*/ section508 tags: experimental describes the heuristic's maturity, not the criterion's existence, and two are Section 508. A test pins the five-rule set so the docs fail loudly if axe changes it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
annotateScreenshot (default false) outlines and labels each violating element,
writes a full-page PNG to the output directory as a resource link, then removes
the markers in a finally so the page is left untouched. The overlay is out of
flow and clipped to each element's box so it cannot reflow the page it is
photographing. Capped at 50 elements with the skipped counts always reported.
Review fixes, each reproduced in a real browser first and confirmed by PNG:
- The fixed layer id let cleanup delete a page-owned element with the same id,
permanently mutating the audited page. The id is now per-scan.
- Markers double-scaled under CSS zoom: at 200% root zoom a target at
(40,60,200x80) drew at (80,120,400x160). The layer is measured to derive the
real scale, so markers now land exactly on their targets.
- Axe reports shadow-DOM targets as a single step that is itself an array, so
they were rejected and miscounted as iframe-nested. Now flattened and walked
through element.shadowRoot.
- Multiple rules on one element drew stacked boxes at identical coordinates
with labels hidden underneath. Marks are keyed per element with rule ids
aggregated onto one label.
- Markers were invisible inside a modal dialog regardless of z-index. The layer
now enters the top layer via the popover API, verified to keep correct
geometry on a tall scrolled page.
Known ceiling (ponytail: comment): scale correction is uniform-scale only; a
rotated or skewed ancestor still misplaces markers.
Also excludes .claude/worktrees from vitest discovery.
Review round 2, each reproduced with before/after PNGs:
- Running CSS animations are paused before measurement and exactly those
resumed in cleanup; an animating element drew its ring ~25px off.
- Markers moved into a shadow root with inline-important declarations: page
CSS like div{display:none!important} rendered zero annotations while the
report claimed "Marked 1 of 1".
- Off-canvas elements (left:-9999px) were counted as marked but absent from
the PNG; now intersected with the document box and reported as skipped.
- The rule-id label was clipped invisible on tiny elements by the ring's
overflow:hidden; the label is now a sibling of the ring.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…id-crawl --storage-state and PLAYWRIGHT_MCP_STORAGE_STATE were silently ignored outside --isolated: the persistent (default), CDP and remote factories called newContext() bare or used launchPersistentContext, which has no storageState option. The documented flag produced a fully anonymous audit that looked like a successful run. Review fix — the first guard was too broad. A live probe showed newContext(storageState) genuinely works over connectOverCDP and over a remote Playwright server; only the reused contexts()[0] path cannot. Storage state is now forwarded in isolated, remote, cdpEndpoint+isolated and cdpLaunch+isolated modes, and refused only for the persistent profile and the CDP paths that reuse an existing context. Capability is an appliesStorageState flag declared per factory (abstract on the base) rather than an instanceof check, so a factory that forgets to declare it rejects rather than silently dropping the state. Forwarding the whole contextOptions also fixes --device, --viewport-size and --user-agent, which were being dropped in remote and isolated-CDP modes — a scanner emulating the wrong viewport reports quietly wrong results. audit_site snapshots session cookies before the crawl and reports the first page where one disappears, via a WARNING line plus sessionLoss in the JSON report and structured content. It warns rather than fails: results before the loss are still valid. Review fixes: cookies are scoped to the crawl URLs and keyed on name/domain/path rather than name alone, and sessionLoss.url reports the URL reached after redirects rather than the one requested. Values are still not compared, deliberately, so a rotating CSRF token never reads as a lost session. README gains an "Auditing pages behind a login" section covering the storage-state and interactive routes, including the trap that excludePathPatterns replaces rather than extends the logout default. Review round 2: - The guard validated the wrong factory under --extension: IsolatedContextFactory passed the check while ExtensionContextFactory (which never reads contextOptions) created the context. The factory that creates the context is now the one validated, via exported assertStorageStateSupported. - Session-loss detection moved into the per-page finally with a requested-URL fallback: a logout URL that clears the cookie and then fails to load blamed the next page that happened to load, or nothing at all. - Cookies deleted at their own stated expiry are excluded from the warning (measured __cf_bm at exactly 30.0min); a logout deletes before expiry, so detection is unchanged. Auth-cookie classification via httpOnly/session proxies was rejected after a five-site survey showed both misfire in both directions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds checkTargetSize (SC 2.5.8) and checkFocusObscured (SC 2.4.11), reusing the existing per-stop issues[] mechanism, JSON report, structured summary and markdown preview. Geometry decisions live in exported pure predicates; only measurement happens in page.evaluate. Both implement the exceptions that make the criteria usable rather than a naive width>=24 && height>=24 test, which flags conforming pages: the spacing exception and the inline exception. The obscured check ignores descendants, ancestors and associated labels, so the visually-hidden-input-under-a-label pattern does not report as obscured on every page that uses it. Review fixes, all four reproduced in a real browser against the unmodified source before being changed (5 target-size findings and 2 obscured, of which 3 were false positives and 1 real case was missed; now 2 and 2): - Obscuration was gated behind the pointer-target heuristic, so a focused contenteditable or iframe under an opaque panel was never sampled. SC 2.4.11 applies to anything that receives focus; the gate is now a non-empty box. - A transparent but clickable overlay made a fully visible button report as entirely hidden. Coverage now requires the hit element to actually paint, walking up to the first ancestor that also contains the focused element, because real sticky bars are often a transparent node inside an opaque one. - The inline exception tested display === 'inline', so inline-block links in running text were false violations. Now matches inline-level display values. - Disabled controls counted as spacing neighbours. The pointer-target predicate is now shared between the focused element and the neighbour query so the two cannot drift. Known ceiling (ponytail: comment): an opaque overlay with pointer-events: none is not detected, since hit testing never returns it. That under-reports rather than raising a false alarm. Semi-transparent scrims count as covering. Review round 2 (4 fixed, 1 rejected): - contenteditable regions are now target-size candidates. - The inline exception walks out through inline-level wrappers to the containing block; a link inside <strong> in a sentence was a false violation, and bare-wrapped fixtures prove the walk is not a blanket pass. - paintsOver lets ancestors veto: an opacity:0 ancestor made a transparent overlay count as painting. - meetsSpacingException runs circle-vs-box for every neighbour, removing a branch asymmetry in the pure predicate. - Rejected measuring after ancestor clipping: prototyped in Chromium at 1 true positive to 4 false positives on mundane overflow markup, and the obvious scrollability guard fails on the true positive itself. Documented as a ceiling with the measured cost. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds withRules/disableRules to scan_page, audit_site and scan_page_matrix via a shared axeRuleSchemaShape, with rule ids validated against axe.getRules() so a misspelling fails by name instead of producing an opaque in-page error. Two axe behaviours handled: - withRules and withTags both assign runOnly, so the last call wins. Explicit rule ids take precedence over tags, documented in the schema text, since a schema default makes "user passed tags" indistinguishable from "default". - disableRules does NOT compose with withRules: axe's ruleShouldRun returns on the runOnly.type === 'rule' branch before reading the per-rule enabled flag, so a disabled rule still ran. disableRules is subtracted from the rule list up front, and emptying it errors rather than falling back to the full tag set. Review fixes: - Declare axe-core as a direct dependency, pinned exactly to 4.12.1. It was imported for the rule catalogue while only present transitively, which breaks under pnpm/Yarn PnP and, under npm, could validate against a different build than AxeBuilder injects. An exact pin is the only spec that cannot drift; a test asserts the pin matches the installed version. - Validate rule ids once before the crawl starts. With strategy "provided" an unknown id previously visited every URL, errored each one, and wrote a completed report. Scope selectors stay per-page, since a component legitimately may not exist on every page. Review round 2: - scan_page_matrix validates rule ids before applying any variant. With reloadBetweenVariants the finally block restores viewport/media/zoom but cannot restore page state destroyed by the reload; measured 2028ms of mutation-then-error reduced to 1ms rejection with typed form state intact. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
New tool covering what axe does not: accessible-name quality and DOM-vs-visual
reading order. Built on Playwright's ariaSnapshot({ mode: 'ai' }) plus aria-ref
locators for geometry. No new dependency.
Six checks, each with a false-positive guard: missing name, uninformative name,
filename-as-name, label-in-name mismatch (2.5.3), duplicate names in one
context, and reading-order mismatch (1.3.2). Reading order is deliberately
conservative — siblings are compared only inside a single row or column band, so
genuine 2-D layouts are skipped rather than guessed.
Three bugs found while validating against live sites: ariaSnapshot lists
aria-hidden elements (a systematic false-positive source), innerText counts
clipped sr-only labels as visible, and batching element handles into one
page.evaluate throws across frames.
Review fixes (6 of 8 accepted):
- filename-as-name applied to every named role, so a download link named
logo.png was told to fix its alt text. Restricted to images.
- maxElements sliced the raw ref list before hidden elements were filtered, so a
hidden-heavy page could exhaust the budget and report nothing. The budget now
counts reachable elements, bounded at 2x measured.
- Stale refs each cost a full 1s timeout serially; a fully stale 400-element
audit took ~400s. Refs now resolve in concurrent chunks (~16s worst case).
- role="option" with an empty name bypassed the missing-name check while already
being treated as label-bearing elsewhere.
- Button-like inputs took their visible label from value, so
<input type="submit" value="Send" aria-label="Submit form"> was skipped.
- Duplicate-name used the element ref as the target for non-links, so two Save
buttons on one form were always called ambiguous. Only observable
destinations are compared now.
Rejected with evidence: auditing exposed nodes that lack refs would cost gov.uk
its zero (2 aria-hidden decorative SVGs, never announced) and gain nothing on
the other four sites, and such findings would carry no selector. Documented in
the "does not detect" list instead. The iframe-direction finding was not
reproducible — Playwright inserts the child frame's own root node, measured in
the child — but the same root cause was fixed: an unmeasured parent silently
defaulted to ltr.
Real-site validation held: BBC News 0, gov.uk 0, GitHub 0 findings, Wikipedia
and MDN reporting only true positives.
Review round 2 (all five confirmed against Playwright 1.61.1):
- YAML-quoted snapshot lines (names containing colons, #, braces) were dropped
entirely by the parser, vanishing the element and re-parenting its children.
- Visible-label extraction now walks shadow roots; a web component's label read
as empty and bypassed label-in-name.
- Duplicate-name targets compare resolved hrefs, so /help and its absolute
form no longer count as different destinations.
- aria-hidden inherits across inlined iframe subtrees in the pure layer.
- maxElements is enforced on the final chunk (51 previously analyzed 100).
Real-site regression bar held exactly: BBC 0, gov.uk 0, GitHub 0; Wikipedia
and MDN identical true positives.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (25)
📝 WalkthroughWalkthroughThis PR adds screen-reader auditing, WCAG keyboard target-size and focus-obscuration checks, Axe rule filtering, annotated ChangesBrowser context and storage state
Axe rule controls and scan integration
Authenticated crawling
Keyboard auditing
Screen-reader auditing
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
New Features
scan_page.Bug Fixes
Documentation