@a11y-pulse/skip-link-audit 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -84,6 +84,8 @@ type SkipLinkResult = {
84
84
  tabIndex: number;
85
85
  passed: boolean;
86
86
  failureReason: "target-missing" | "activation-no-effect" | null;
87
+ /** PNG bytes of the focused skip link, clipped and padded. Only captured when it failed. */
88
+ screenshot?: Uint8Array;
87
89
  }>;
88
90
  summary: {
89
91
  found: number;
@@ -104,9 +106,11 @@ When no candidate is found, `skipLinks` is empty and the summary is zeros. Landm
104
106
 
105
107
  Activation uses a real Enter keypress rather than a synthetic click, so the keyboard path is the one being checked.
106
108
 
109
+ A failed skip link is focused again and screenshotted, so a link that only appears on focus is visible in the evidence.
110
+
107
111
  ## Adaptors
108
112
 
109
- The audit itself is framework-agnostic: it drives a page through an **adaptor**, a small interface of primitives (evaluate JS in the page, press Tab, press Enter) that the audit calls without knowing which browser automation library is behind it.
113
+ The audit itself is framework-agnostic: it drives a page through an **adaptor**, a small interface of primitives (evaluate JS in the page, press Tab, press Enter, take a screenshot) that the audit calls without knowing which browser automation library is behind it.
110
114
 
111
115
  [`@a11y-pulse/browser-adaptor`](../browser-adaptor) ships two implementations, `PuppeteerAdaptor` and `PlaywrightAdaptor`. Other environments (Selenium, WebDriver) can be supported by implementing the same interface, exported as `SkipLinkAuditAdaptor` (aliased as `BrowserAdaptor` from the package root).
112
116
 
@@ -119,6 +123,8 @@ The audit itself is framework-agnostic: it drives a page through an **adaptor**,
119
123
  | `disposeRef(ref)` | Releases a handle previously returned by `evaluateHandle`. |
120
124
  | `pressTab()` | Presses the Tab key, advancing focus to the next focusable element. |
121
125
  | `pressEnter()` | Presses the Enter key, activating the focused element. |
126
+ | `screenshotClip(clip, scale?)` | Screenshots the `clip` region of the page, in document coordinates, at `scale` bitmap pixels per CSS pixel, and returns PNG bytes. |
127
+ | `screenshotClipScale` | Optional. The scale for evidence screenshots. Defaults to 1. |
122
128
  | `ensureFocusReporting()` | Ensures the page reports focus for its lifetime, in particular that `document.hasFocus()` works and `:focus` styles apply even when the page is not the foreground tab/window. Must not throw. |
123
129
 
124
130
  ### Writing a new adaptor
@@ -130,7 +136,7 @@ import type { SkipLinkAuditAdaptor } from "@a11y-pulse/skip-link-audit";
130
136
 
131
137
  class MyFrameworkAdaptor implements SkipLinkAuditAdaptor {
132
138
  // ...implement evaluate, evaluateHandle, disposeRef, pressTab,
133
- // pressEnter, and ensureFocusReporting for your framework
139
+ // pressEnter, screenshotClip, and ensureFocusReporting for your framework
134
140
  }
135
141
  ```
136
142
 
@@ -144,6 +150,12 @@ Use [`@a11y-pulse/browser-adaptor`'s `src/adaptors/puppeteer.ts`](../browser-ada
144
150
  - **Closed shadow roots** are opaque; a skip link inside one is invisible to the scan.
145
151
  - **Landmarks and headings** that satisfy 2.4.1 without a skip link are out of scope by design.
146
152
 
153
+ ## Known false positives
154
+
155
+ Cases where the audit reports a problem that is not one. Each says which bucket it lands in: `incomplete` asks for a human to check, `violations` claims a failure.
156
+
157
+ - **Skip links that move focus slowly** (`violations`). The audit waits 250ms (`activationPollMs`) for focus to arrive. A skip link that only moves focus after a longer smooth-scroll animation is reported as having no effect.
158
+
147
159
  ## Releasing
148
160
 
149
161
  Releases are managed in the [A11y-Pulse/audits](https://github.com/A11y-Pulse/audits) monorepo with [Changesets](https://github.com/changesets/changesets). Publishing uses [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/) (OIDC). There is no long-lived `NPM_TOKEN`.
package/dist/adaptor.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Rect } from "@a11y-pulse/browser-adaptor";
1
2
  /**
2
3
  * An element handle in the page. This type is adaptor-specific and is opaque to the audit.
3
4
  */
@@ -27,6 +28,13 @@ export interface SkipLinkAuditAdaptor {
27
28
  * Activate the focused element via a real Enter keypress.
28
29
  */
29
30
  pressEnter(): Promise<void>;
31
+ /**
32
+ * Screenshot a clipped region of the page defined by `clip`, in document coordinates, at `scale`
33
+ * bitmap pixels per CSS pixel. This function must return PNG bytes.
34
+ */
35
+ screenshotClip(clip: Rect, scale?: number): Promise<Uint8Array>;
36
+ /** Device scale factor for evidence screenshots. Defaults to 1. */
37
+ readonly screenshotClipScale?: number;
30
38
  /**
31
39
  * Ensure the page reports focus for its lifetime. In particular, `document.hasFocus()` must
32
40
  * function correctly and :focus styles must be applied, even when the page is not the foreground.
package/dist/audit.d.ts CHANGED
@@ -30,6 +30,8 @@ export type SkipLinkProbe = {
30
30
  probeTabStop(): Promise<TabStopProbe>;
31
31
  focusHandle(ref: ElementRef): Promise<void>;
32
32
  isFocusInsideTarget(fragment: string): Promise<boolean>;
33
+ /** Focus the element and screenshot it, so a link that only appears on focus is visible. */
34
+ screenshotFocused(ref: ElementRef): Promise<Uint8Array>;
33
35
  disposeRef(ref: ElementRef): Promise<void>;
34
36
  };
35
37
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/audit.ts
2
+ import { captureElementScreenshot } from "@a11y-pulse/browser-adaptor";
2
3
  import { getSelector, truncateHtml } from "@a11y-pulse/browser-adaptor/dom";
3
4
 
4
5
  // src/browser-scripts.ts
@@ -74,6 +75,8 @@ function focusScript(el) {
74
75
  // src/audit.ts
75
76
  var DEFAULT_CANDIDATE_LIMIT = 3;
76
77
  var DEFAULT_ACTIVATION_POLL_MS = 250;
78
+ var SCREENSHOT_CLIP_BUFFER = 10;
79
+ var SCREENSHOT_SETTLE_MS = 33;
77
80
  function resolveOptions(options) {
78
81
  return {
79
82
  candidateLimit: options.candidateLimit ?? DEFAULT_CANDIDATE_LIMIT,
@@ -108,7 +111,8 @@ async function runSkipLinkLoop(probe, options) {
108
111
  fragment: found.fragment,
109
112
  tabIndex: found.tabIndex,
110
113
  passed: false,
111
- failureReason: "target-missing"
114
+ failureReason: "target-missing",
115
+ screenshot: await probe.screenshotFocused(found.handle)
112
116
  });
113
117
  continue;
114
118
  }
@@ -125,7 +129,8 @@ async function runSkipLinkLoop(probe, options) {
125
129
  fragment: found.fragment,
126
130
  tabIndex: found.tabIndex,
127
131
  passed: passed2,
128
- failureReason: passed2 ? null : "activation-no-effect"
132
+ failureReason: passed2 ? null : "activation-no-effect",
133
+ screenshot: passed2 ? void 0 : await probe.screenshotFocused(found.handle)
129
134
  });
130
135
  } finally {
131
136
  await probe.disposeRef(found.handle);
@@ -195,6 +200,14 @@ function createAdaptorProbe(adaptor) {
195
200
  isFocusInsideTarget(fragment) {
196
201
  return adaptor.evaluate(isFocusInsideTargetScript, fragment);
197
202
  },
203
+ async screenshotFocused(ref) {
204
+ await adaptor.evaluate(focusScript, ref);
205
+ await new Promise((resolve) => setTimeout(resolve, SCREENSHOT_SETTLE_MS));
206
+ return captureElementScreenshot(adaptor, ref, {
207
+ clipBuffer: SCREENSHOT_CLIP_BUFFER,
208
+ settleDelay: SCREENSHOT_SETTLE_MS
209
+ });
210
+ },
198
211
  disposeRef(ref) {
199
212
  return adaptor.disposeRef(ref);
200
213
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/audit.ts","../src/browser-scripts.ts"],"sourcesContent":["import { getSelector, truncateHtml } from \"@a11y-pulse/browser-adaptor/dom\";\nimport type { ElementRef, SkipLinkAuditAdaptor } from \"./adaptor\";\nimport {\n\tactiveElementHandleScript,\n\tfocusScript,\n\tisFocusInsideTargetScript,\n\tprobeActiveElementScript,\n} from \"./browser-scripts\";\nimport type { SkipLinkElementResult, SkipLinkResult } from \"./result\";\n\nexport const DEFAULT_CANDIDATE_LIMIT = 3;\nexport const DEFAULT_ACTIVATION_POLL_MS = 250;\n\nexport type SkipLinkOptions = {\n\t/** Max tab stops to scan for skip-link candidates. Defaults to 3. */\n\tcandidateLimit?: number;\n};\n\nexport type ResolvedSkipLinkOptions = {\n\tcandidateLimit: number;\n\tactivationPollMs: number;\n};\n\nexport type SkipLinkCandidate = {\n\tselector: string;\n\thtml: string;\n\tfragment: string;\n\ttargetResolves: boolean;\n\thandle: ElementRef;\n};\n\nexport type TabStopProbe = {\n\tisBody: boolean;\n\t/** Unique identity of the focused element, used to detect a focus cycle. */\n\tidentity: string;\n\tcandidate: SkipLinkCandidate | null;\n};\n\n/** The browser-coupled seams the loop drives. Mocked in unit tests. */\nexport type SkipLinkProbe = {\n\tpressTab(): Promise<void>;\n\tpressEnter(): Promise<void>;\n\tprobeTabStop(): Promise<TabStopProbe>;\n\tfocusHandle(ref: ElementRef): Promise<void>;\n\tisFocusInsideTarget(fragment: string): Promise<boolean>;\n\tdisposeRef(ref: ElementRef): Promise<void>;\n};\n\nfunction resolveOptions(options: SkipLinkOptions): ResolvedSkipLinkOptions {\n\treturn {\n\t\tcandidateLimit: options.candidateLimit ?? DEFAULT_CANDIDATE_LIMIT,\n\t\tactivationPollMs: DEFAULT_ACTIVATION_POLL_MS,\n\t};\n}\n\n/**\n * Tab through the first few stops looking for skip-link-like fragment anchors, then activate each\n * candidate and check that keyboard focus moves. Enables focus reporting up front, then drives the\n * loop.\n */\nexport async function runSkipLinkAudit(\n\tadaptor: SkipLinkAuditAdaptor,\n\toptions: SkipLinkOptions = {},\n): Promise<SkipLinkResult> {\n\tawait adaptor.ensureFocusReporting();\n\n\treturn runSkipLinkLoop(createAdaptorProbe(adaptor), resolveOptions(options));\n}\n\n/** The engine-neutral two-phase loop. Exported for unit testing with a fake probe. */\nexport async function runSkipLinkLoop(\n\tprobe: SkipLinkProbe,\n\toptions: ResolvedSkipLinkOptions,\n): Promise<SkipLinkResult> {\n\tconst collected: Array<SkipLinkCandidate & { tabIndex: number }> = [];\n\tconst seen = new Set<string>();\n\n\tfor (let i = 0; i < options.candidateLimit; i++) {\n\t\tawait probe.pressTab();\n\n\t\tconst tabStop = await probe.probeTabStop();\n\n\t\tif (tabStop.isBody || seen.has(tabStop.identity)) {\n\t\t\tbreak;\n\t\t}\n\n\t\tseen.add(tabStop.identity);\n\n\t\tif (tabStop.candidate) {\n\t\t\tcollected.push({ ...tabStop.candidate, tabIndex: i + 1 });\n\t\t}\n\t}\n\n\tconst skipLinks: SkipLinkElementResult[] = [];\n\n\tfor (const found of collected) {\n\t\ttry {\n\t\t\tif (!found.targetResolves) {\n\t\t\t\tskipLinks.push({\n\t\t\t\t\tselector: found.selector,\n\t\t\t\t\thtml: found.html,\n\t\t\t\t\tfragment: found.fragment,\n\t\t\t\t\ttabIndex: found.tabIndex,\n\t\t\t\t\tpassed: false,\n\t\t\t\t\tfailureReason: \"target-missing\",\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tawait probe.focusHandle(found.handle);\n\t\t\tawait probe.pressEnter();\n\n\t\t\tlet passed = await pollFocusInsideTarget(probe, found.fragment, options.activationPollMs);\n\n\t\t\tif (!passed) {\n\t\t\t\tawait probe.pressTab();\n\t\t\t\tpassed = await probe.isFocusInsideTarget(found.fragment);\n\t\t\t}\n\n\t\t\tskipLinks.push({\n\t\t\t\tselector: found.selector,\n\t\t\t\thtml: found.html,\n\t\t\t\tfragment: found.fragment,\n\t\t\t\ttabIndex: found.tabIndex,\n\t\t\t\tpassed,\n\t\t\t\tfailureReason: passed ? null : \"activation-no-effect\",\n\t\t\t});\n\t\t} finally {\n\t\t\tawait probe.disposeRef(found.handle);\n\t\t}\n\t}\n\n\tconst passed = skipLinks.filter((link) => link.passed).length;\n\n\treturn {\n\t\tskipLinks,\n\t\tsummary: {\n\t\t\tfound: skipLinks.length,\n\t\t\tpassed,\n\t\t\tfailed: skipLinks.length - passed,\n\t\t},\n\t};\n}\n\nasync function pollFocusInsideTarget(\n\tprobe: SkipLinkProbe,\n\tfragment: string,\n\tpollMs: number,\n): Promise<boolean> {\n\tif (await probe.isFocusInsideTarget(fragment)) {\n\t\treturn true;\n\t}\n\n\tif (pollMs <= 0) {\n\t\treturn false;\n\t}\n\n\tconst deadline = Date.now() + pollMs;\n\n\twhile (Date.now() < deadline) {\n\t\tawait new Promise((resolve) => setTimeout(resolve, 16));\n\n\t\tif (await probe.isFocusInsideTarget(fragment)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction createAdaptorProbe(adaptor: SkipLinkAuditAdaptor): SkipLinkProbe {\n\treturn {\n\t\tpressTab() {\n\t\t\treturn adaptor.pressTab();\n\t\t},\n\n\t\tpressEnter() {\n\t\t\treturn adaptor.pressEnter();\n\t\t},\n\n\t\tasync probeTabStop() {\n\t\t\tconst base = await adaptor.evaluate(probeActiveElementScript);\n\n\t\t\tif (base.isBody) {\n\t\t\t\treturn { isBody: true, identity: \"body\", candidate: null };\n\t\t\t}\n\n\t\t\tconst handle = await adaptor.evaluateHandle(activeElementHandleScript);\n\t\t\tconst selector = await adaptor.evaluate(getSelector, handle);\n\t\t\tconst html = truncateHtml(base.html);\n\n\t\t\tif (base.fragment) {\n\t\t\t\treturn {\n\t\t\t\t\tisBody: false,\n\t\t\t\t\tidentity: selector,\n\t\t\t\t\tcandidate: {\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\thtml,\n\t\t\t\t\t\tfragment: base.fragment,\n\t\t\t\t\t\ttargetResolves: base.targetResolves,\n\t\t\t\t\t\thandle,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tawait adaptor.disposeRef(handle);\n\n\t\t\treturn { isBody: false, identity: selector, candidate: null };\n\t\t},\n\n\t\tfocusHandle(ref) {\n\t\t\treturn adaptor.evaluate(focusScript, ref);\n\t\t},\n\n\t\tisFocusInsideTarget(fragment) {\n\t\t\treturn adaptor.evaluate(isFocusInsideTargetScript, fragment);\n\t\t},\n\n\t\tdisposeRef(ref) {\n\t\t\treturn adaptor.disposeRef(ref);\n\t\t},\n\t};\n}\n","/**\n * IMPORTANT: Functions in this file that are serialized and injected into the audited page must not\n * reference any symbols outside their own scope. Common logic (fragment parsing, target resolution,\n * shadow-root descent) is therefore duplicated inside each injected function.\n */\n\n/**\n * Return the in-page fragment for a skip-link-like href, or null if the href is not a same-document\n * hash (including the bare `#` and `#top`, which have no element target).\n */\nexport function parseInPageFragment(href: string | null): string | null {\n\tif (href === null || href === \"\") {\n\t\treturn null;\n\t}\n\n\tif (!href.startsWith(\"#\")) {\n\t\treturn null;\n\t}\n\n\tif (href === \"#\" || href === \"#top\") {\n\t\treturn null;\n\t}\n\n\t// Hash-router and hashbang paths are not element ids.\n\tif (href.startsWith(\"#/\") || href.startsWith(\"#!/\")) {\n\t\treturn null;\n\t}\n\n\treturn href;\n}\n\n/**\n * Resolve a fragment to an element, preferring `id` then a matching `name`. Serialized and run in\n * the page; must stay self-contained.\n */\nexport function resolveFragmentTargetScript(fragment: string): Element | null {\n\tconst raw = fragment.startsWith(\"#\") ? fragment.slice(1) : fragment;\n\tlet decoded = raw;\n\n\ttry {\n\t\tdecoded = decodeURIComponent(raw);\n\t} catch {\n\t\t// Keep the raw id when it is not valid percent-encoding.\n\t}\n\n\treturn document.getElementById(decoded) ?? document.getElementsByName(decoded)[0] ?? null;\n}\n\nexport type SkipLinkActiveElementBase = {\n\tisBody: boolean;\n\thtml: string;\n\t/**\n\t * In-page fragment such as \"#main\", or null when the focused node is not a skip-link candidate.\n\t */\n\tfragment: string | null;\n\ttargetResolves: boolean;\n};\n\n/**\n * Read the currently focused element (descending open shadow roots) and report whether it is a\n * skip-link-like in-page fragment anchor.\n */\nexport function probeActiveElementScript(): SkipLinkActiveElementBase {\n\tlet el = document.activeElement;\n\n\twhile (el?.shadowRoot?.activeElement) {\n\t\tel = el.shadowRoot.activeElement;\n\t}\n\n\tif (!el || el === document.body) {\n\t\treturn {\n\t\t\tisBody: true,\n\t\t\thtml: \"\",\n\t\t\tfragment: null,\n\t\t\ttargetResolves: false,\n\t\t};\n\t}\n\n\tconst openingTag = (el.cloneNode(false) as Element).outerHTML;\n\tconst href = el.tagName === \"A\" ? (el as HTMLAnchorElement).getAttribute(\"href\") : null;\n\n\tlet fragment: string | null = null;\n\n\tif (\n\t\thref?.startsWith(\"#\") &&\n\t\thref !== \"#\" &&\n\t\thref !== \"#top\" &&\n\t\t!href.startsWith(\"#/\") &&\n\t\t!href.startsWith(\"#!/\")\n\t) {\n\t\tfragment = href;\n\t}\n\n\tlet targetResolves = false;\n\n\tif (fragment) {\n\t\tconst raw = fragment.slice(1);\n\t\tlet decoded = raw;\n\n\t\ttry {\n\t\t\tdecoded = decodeURIComponent(raw);\n\t\t} catch {\n\t\t\t// Keep the raw id when it is not valid percent-encoding.\n\t\t}\n\n\t\ttargetResolves = Boolean(\n\t\t\tdocument.getElementById(decoded) ?? document.getElementsByName(decoded)[0],\n\t\t);\n\t}\n\n\treturn {\n\t\tisBody: false,\n\t\thtml: openingTag,\n\t\tfragment,\n\t\ttargetResolves,\n\t};\n}\n\n/**\n * Return the focused element, descending open shadow roots.\n */\nexport function activeElementHandleScript(): Element | null {\n\tlet el = document.activeElement;\n\n\twhile (el?.shadowRoot?.activeElement) {\n\t\tel = el.shadowRoot.activeElement;\n\t}\n\n\treturn el;\n}\n\n/**\n * Whether document.activeElement is the fragment target or inside it.\n */\nexport function isFocusInsideTargetScript(fragment: string): boolean {\n\tconst raw = fragment.startsWith(\"#\") ? fragment.slice(1) : fragment;\n\tlet decoded = raw;\n\n\ttry {\n\t\tdecoded = decodeURIComponent(raw);\n\t} catch {\n\t\t// Keep the raw id when it is not valid percent-encoding.\n\t}\n\n\tconst target = document.getElementById(decoded) ?? document.getElementsByName(decoded)[0] ?? null;\n\n\tif (!target) {\n\t\treturn false;\n\t}\n\n\tlet el = document.activeElement;\n\n\twhile (el?.shadowRoot?.activeElement) {\n\t\tel = el.shadowRoot.activeElement;\n\t}\n\n\tif (!el) {\n\t\treturn false;\n\t}\n\n\treturn el === target || target.contains(el);\n}\n\nexport function focusScript(el: Element | null): void {\n\t(el as HTMLElement | null)?.focus();\n}\n"],"mappings":";AAAA,SAAS,aAAa,oBAAoB;;;AC8DnC,SAAS,2BAAsD;AACrE,MAAI,KAAK,SAAS;AAElB,SAAO,IAAI,YAAY,eAAe;AACrC,SAAK,GAAG,WAAW;AA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A,IAEA,MAAM,eAAe;AACpB,YAAM,OAAO,MAAM,QAAQ,SAAS,wBAAwB;AAE5D,UAAI,KAAK,QAAQ;AAChB,eAAO,EAAE,QAAQ,MAAM,UAAU,QAAQ,WAAW,KAAK;AAAA,MAC1D;AAEA,YAAM,SAAS,MAAM,QAAQ,eAAe,yBAAyB;AACrE,YAAM,WAAW,MAAM,QAAQ,SAAS,aAAa,MAAM;AAC3D,YAAM,OAAO,aAAa,KAAK,IAAI;AAEnC,UAAI,KAAK,UAAU;AAClB,eAAO;AAAA,UACN,QAAQ;AAAA,UACR,UAAU;AAAA,UACV,WAAW;AAAA,YACV;AAAA,YACA;AAAA,YACA,UAAU,KAAK;AAAA,YACf,gBAAgB,KAAK;AAAA,YACrB;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAEA,YAAM,QAAQ,WAAW,MAAM;AAE/B,aAAO,EAAE,QAAQ,OAAO,UAAU,UAAU,WAAW,KAAK;AAAA,IAC7D;AAAA,IAEA,YAAY,KAAK;AAChB,aAAO,QAAQ,SAAS,aAAa,GAAG;AAAA,IACzC;AAAA,IAEA,oBAAoB,UAAU;AAC7B,aAAO,QAAQ,SAAS,2BAA2B,QAAQ;AAAA,IAC5D;AAAA,IAEA,WAAW,KAAK;AACf,aAAO,QAAQ,WAAW,GAAG;AAAA,IAC9B;AAAA,EACD;AACD;","names":["passed"]}
1
+ {"version":3,"sources":["../src/audit.ts","../src/browser-scripts.ts"],"sourcesContent":["import { captureElementScreenshot } from \"@a11y-pulse/browser-adaptor\";\nimport { getSelector, truncateHtml } from \"@a11y-pulse/browser-adaptor/dom\";\nimport type { ElementRef, SkipLinkAuditAdaptor } from \"./adaptor\";\nimport {\n\tactiveElementHandleScript,\n\tfocusScript,\n\tisFocusInsideTargetScript,\n\tprobeActiveElementScript,\n} from \"./browser-scripts\";\nimport type { SkipLinkElementResult, SkipLinkResult } from \"./result\";\n\nexport const DEFAULT_CANDIDATE_LIMIT = 3;\nexport const DEFAULT_ACTIVATION_POLL_MS = 250;\n\nconst SCREENSHOT_CLIP_BUFFER = 10;\nconst SCREENSHOT_SETTLE_MS = 33; // ~2 frames at 60fps\n\nexport type SkipLinkOptions = {\n\t/** Max tab stops to scan for skip-link candidates. Defaults to 3. */\n\tcandidateLimit?: number;\n};\n\nexport type ResolvedSkipLinkOptions = {\n\tcandidateLimit: number;\n\tactivationPollMs: number;\n};\n\nexport type SkipLinkCandidate = {\n\tselector: string;\n\thtml: string;\n\tfragment: string;\n\ttargetResolves: boolean;\n\thandle: ElementRef;\n};\n\nexport type TabStopProbe = {\n\tisBody: boolean;\n\t/** Unique identity of the focused element, used to detect a focus cycle. */\n\tidentity: string;\n\tcandidate: SkipLinkCandidate | null;\n};\n\n/** The browser-coupled seams the loop drives. Mocked in unit tests. */\nexport type SkipLinkProbe = {\n\tpressTab(): Promise<void>;\n\tpressEnter(): Promise<void>;\n\tprobeTabStop(): Promise<TabStopProbe>;\n\tfocusHandle(ref: ElementRef): Promise<void>;\n\tisFocusInsideTarget(fragment: string): Promise<boolean>;\n\t/** Focus the element and screenshot it, so a link that only appears on focus is visible. */\n\tscreenshotFocused(ref: ElementRef): Promise<Uint8Array>;\n\tdisposeRef(ref: ElementRef): Promise<void>;\n};\n\nfunction resolveOptions(options: SkipLinkOptions): ResolvedSkipLinkOptions {\n\treturn {\n\t\tcandidateLimit: options.candidateLimit ?? DEFAULT_CANDIDATE_LIMIT,\n\t\tactivationPollMs: DEFAULT_ACTIVATION_POLL_MS,\n\t};\n}\n\n/**\n * Tab through the first few stops looking for skip-link-like fragment anchors, then activate each\n * candidate and check that keyboard focus moves. Enables focus reporting up front, then drives the\n * loop.\n */\nexport async function runSkipLinkAudit(\n\tadaptor: SkipLinkAuditAdaptor,\n\toptions: SkipLinkOptions = {},\n): Promise<SkipLinkResult> {\n\tawait adaptor.ensureFocusReporting();\n\n\treturn runSkipLinkLoop(createAdaptorProbe(adaptor), resolveOptions(options));\n}\n\n/** The engine-neutral two-phase loop. Exported for unit testing with a fake probe. */\nexport async function runSkipLinkLoop(\n\tprobe: SkipLinkProbe,\n\toptions: ResolvedSkipLinkOptions,\n): Promise<SkipLinkResult> {\n\tconst collected: Array<SkipLinkCandidate & { tabIndex: number }> = [];\n\tconst seen = new Set<string>();\n\n\tfor (let i = 0; i < options.candidateLimit; i++) {\n\t\tawait probe.pressTab();\n\n\t\tconst tabStop = await probe.probeTabStop();\n\n\t\tif (tabStop.isBody || seen.has(tabStop.identity)) {\n\t\t\tbreak;\n\t\t}\n\n\t\tseen.add(tabStop.identity);\n\n\t\tif (tabStop.candidate) {\n\t\t\tcollected.push({ ...tabStop.candidate, tabIndex: i + 1 });\n\t\t}\n\t}\n\n\tconst skipLinks: SkipLinkElementResult[] = [];\n\n\tfor (const found of collected) {\n\t\ttry {\n\t\t\tif (!found.targetResolves) {\n\t\t\t\tskipLinks.push({\n\t\t\t\t\tselector: found.selector,\n\t\t\t\t\thtml: found.html,\n\t\t\t\t\tfragment: found.fragment,\n\t\t\t\t\ttabIndex: found.tabIndex,\n\t\t\t\t\tpassed: false,\n\t\t\t\t\tfailureReason: \"target-missing\",\n\t\t\t\t\tscreenshot: await probe.screenshotFocused(found.handle),\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tawait probe.focusHandle(found.handle);\n\t\t\tawait probe.pressEnter();\n\n\t\t\tlet passed = await pollFocusInsideTarget(probe, found.fragment, options.activationPollMs);\n\n\t\t\tif (!passed) {\n\t\t\t\tawait probe.pressTab();\n\t\t\t\tpassed = await probe.isFocusInsideTarget(found.fragment);\n\t\t\t}\n\n\t\t\tskipLinks.push({\n\t\t\t\tselector: found.selector,\n\t\t\t\thtml: found.html,\n\t\t\t\tfragment: found.fragment,\n\t\t\t\ttabIndex: found.tabIndex,\n\t\t\t\tpassed,\n\t\t\t\tfailureReason: passed ? null : \"activation-no-effect\",\n\t\t\t\tscreenshot: passed ? undefined : await probe.screenshotFocused(found.handle),\n\t\t\t});\n\t\t} finally {\n\t\t\tawait probe.disposeRef(found.handle);\n\t\t}\n\t}\n\n\tconst passed = skipLinks.filter((link) => link.passed).length;\n\n\treturn {\n\t\tskipLinks,\n\t\tsummary: {\n\t\t\tfound: skipLinks.length,\n\t\t\tpassed,\n\t\t\tfailed: skipLinks.length - passed,\n\t\t},\n\t};\n}\n\nasync function pollFocusInsideTarget(\n\tprobe: SkipLinkProbe,\n\tfragment: string,\n\tpollMs: number,\n): Promise<boolean> {\n\tif (await probe.isFocusInsideTarget(fragment)) {\n\t\treturn true;\n\t}\n\n\tif (pollMs <= 0) {\n\t\treturn false;\n\t}\n\n\tconst deadline = Date.now() + pollMs;\n\n\twhile (Date.now() < deadline) {\n\t\tawait new Promise((resolve) => setTimeout(resolve, 16));\n\n\t\tif (await probe.isFocusInsideTarget(fragment)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction createAdaptorProbe(adaptor: SkipLinkAuditAdaptor): SkipLinkProbe {\n\treturn {\n\t\tpressTab() {\n\t\t\treturn adaptor.pressTab();\n\t\t},\n\n\t\tpressEnter() {\n\t\t\treturn adaptor.pressEnter();\n\t\t},\n\n\t\tasync probeTabStop() {\n\t\t\tconst base = await adaptor.evaluate(probeActiveElementScript);\n\n\t\t\tif (base.isBody) {\n\t\t\t\treturn { isBody: true, identity: \"body\", candidate: null };\n\t\t\t}\n\n\t\t\tconst handle = await adaptor.evaluateHandle(activeElementHandleScript);\n\t\t\tconst selector = await adaptor.evaluate(getSelector, handle);\n\t\t\tconst html = truncateHtml(base.html);\n\n\t\t\tif (base.fragment) {\n\t\t\t\treturn {\n\t\t\t\t\tisBody: false,\n\t\t\t\t\tidentity: selector,\n\t\t\t\t\tcandidate: {\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\thtml,\n\t\t\t\t\t\tfragment: base.fragment,\n\t\t\t\t\t\ttargetResolves: base.targetResolves,\n\t\t\t\t\t\thandle,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tawait adaptor.disposeRef(handle);\n\n\t\t\treturn { isBody: false, identity: selector, candidate: null };\n\t\t},\n\n\t\tfocusHandle(ref) {\n\t\t\treturn adaptor.evaluate(focusScript, ref);\n\t\t},\n\n\t\tisFocusInsideTarget(fragment) {\n\t\t\treturn adaptor.evaluate(isFocusInsideTargetScript, fragment);\n\t\t},\n\n\t\tasync screenshotFocused(ref) {\n\t\t\tawait adaptor.evaluate(focusScript, ref);\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, SCREENSHOT_SETTLE_MS));\n\n\t\t\treturn captureElementScreenshot(adaptor, ref, {\n\t\t\t\tclipBuffer: SCREENSHOT_CLIP_BUFFER,\n\t\t\t\tsettleDelay: SCREENSHOT_SETTLE_MS,\n\t\t\t});\n\t\t},\n\n\t\tdisposeRef(ref) {\n\t\t\treturn adaptor.disposeRef(ref);\n\t\t},\n\t};\n}\n","/**\n * IMPORTANT: Functions in this file that are serialized and injected into the audited page must not\n * reference any symbols outside their own scope. Common logic (fragment parsing, target resolution,\n * shadow-root descent) is therefore duplicated inside each injected function.\n */\n\n/**\n * Return the in-page fragment for a skip-link-like href, or null if the href is not a same-document\n * hash (including the bare `#` and `#top`, which have no element target).\n */\nexport function parseInPageFragment(href: string | null): string | null {\n\tif (href === null || href === \"\") {\n\t\treturn null;\n\t}\n\n\tif (!href.startsWith(\"#\")) {\n\t\treturn null;\n\t}\n\n\tif (href === \"#\" || href === \"#top\") {\n\t\treturn null;\n\t}\n\n\t// Hash-router and hashbang paths are not element ids.\n\tif (href.startsWith(\"#/\") || href.startsWith(\"#!/\")) {\n\t\treturn null;\n\t}\n\n\treturn href;\n}\n\n/**\n * Resolve a fragment to an element, preferring `id` then a matching `name`. Serialized and run in\n * the page; must stay self-contained.\n */\nexport function resolveFragmentTargetScript(fragment: string): Element | null {\n\tconst raw = fragment.startsWith(\"#\") ? fragment.slice(1) : fragment;\n\tlet decoded = raw;\n\n\ttry {\n\t\tdecoded = decodeURIComponent(raw);\n\t} catch {\n\t\t// Keep the raw id when it is not valid percent-encoding.\n\t}\n\n\treturn document.getElementById(decoded) ?? document.getElementsByName(decoded)[0] ?? null;\n}\n\nexport type SkipLinkActiveElementBase = {\n\tisBody: boolean;\n\thtml: string;\n\t/**\n\t * In-page fragment such as \"#main\", or null when the focused node is not a skip-link candidate.\n\t */\n\tfragment: string | null;\n\ttargetResolves: boolean;\n};\n\n/**\n * Read the currently focused element (descending open shadow roots) and report whether it is a\n * skip-link-like in-page fragment anchor.\n */\nexport function probeActiveElementScript(): SkipLinkActiveElementBase {\n\tlet el = document.activeElement;\n\n\twhile (el?.shadowRoot?.activeElement) {\n\t\tel = el.shadowRoot.activeElement;\n\t}\n\n\tif (!el || el === document.body) {\n\t\treturn {\n\t\t\tisBody: true,\n\t\t\thtml: \"\",\n\t\t\tfragment: null,\n\t\t\ttargetResolves: false,\n\t\t};\n\t}\n\n\tconst openingTag = (el.cloneNode(false) as Element).outerHTML;\n\tconst href = el.tagName === \"A\" ? (el as HTMLAnchorElement).getAttribute(\"href\") : null;\n\n\tlet fragment: string | null = null;\n\n\tif (\n\t\thref?.startsWith(\"#\") &&\n\t\thref !== \"#\" &&\n\t\thref !== \"#top\" &&\n\t\t!href.startsWith(\"#/\") &&\n\t\t!href.startsWith(\"#!/\")\n\t) {\n\t\tfragment = href;\n\t}\n\n\tlet targetResolves = false;\n\n\tif (fragment) {\n\t\tconst raw = fragment.slice(1);\n\t\tlet decoded = raw;\n\n\t\ttry {\n\t\t\tdecoded = decodeURIComponent(raw);\n\t\t} catch {\n\t\t\t// Keep the raw id when it is not valid percent-encoding.\n\t\t}\n\n\t\ttargetResolves = Boolean(\n\t\t\tdocument.getElementById(decoded) ?? document.getElementsByName(decoded)[0],\n\t\t);\n\t}\n\n\treturn {\n\t\tisBody: false,\n\t\thtml: openingTag,\n\t\tfragment,\n\t\ttargetResolves,\n\t};\n}\n\n/**\n * Return the focused element, descending open shadow roots.\n */\nexport function activeElementHandleScript(): Element | null {\n\tlet el = document.activeElement;\n\n\twhile (el?.shadowRoot?.activeElement) {\n\t\tel = el.shadowRoot.activeElement;\n\t}\n\n\treturn el;\n}\n\n/**\n * Whether document.activeElement is the fragment target or inside it.\n */\nexport function isFocusInsideTargetScript(fragment: string): boolean {\n\tconst raw = fragment.startsWith(\"#\") ? fragment.slice(1) : fragment;\n\tlet decoded = raw;\n\n\ttry {\n\t\tdecoded = decodeURIComponent(raw);\n\t} catch {\n\t\t// Keep the raw id when it is not valid percent-encoding.\n\t}\n\n\tconst target = document.getElementById(decoded) ?? document.getElementsByName(decoded)[0] ?? null;\n\n\tif (!target) {\n\t\treturn false;\n\t}\n\n\tlet el = document.activeElement;\n\n\twhile (el?.shadowRoot?.activeElement) {\n\t\tel = el.shadowRoot.activeElement;\n\t}\n\n\tif (!el) {\n\t\treturn false;\n\t}\n\n\treturn el === target || target.contains(el);\n}\n\nexport function focusScript(el: Element | null): void {\n\t(el as HTMLElement | null)?.focus();\n}\n"],"mappings":";AAAA,SAAS,gCAAgC;AACzC,SAAS,aAAa,oBAAoB;;;AC6DnC,SAAS,2BAAsD;AACrE,MAAI,KAAK,SAAS;AAElB,SAAO,IAAI,YAAY,eAAe;AACrC,SAAK,GAAG,WAAW;AAAA,EACpB;AAEA,MAAI,CAAC,MAAM,OAAO,SAAS,MAAM;AAChC,WAAO;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,MACV,gBAAgB;AAAA,IACjB;AAAA,EACD;AAEA,QAAM,aAAc,GAAG,UAAU,KAAK,EAAc;AACpD,QAAM,OAAO,GAAG,YAAY,MAAO,GAAyB,aAAa,MAAM,IAAI;AAEnF,MAAI,WAA0B;AAE9B,MACC,MAAM,WAAW,GAAG,KACpB,SAAS,OACT,SAAS,UACT,CAAC,KAAK,WAAW,IAAI,KACrB,CAAC,KAAK,WAAW,KAAK,GACrB;AACD,eAAW;AAAA,EACZ;AAEA,MAAI,iBAAiB;AAErB,MAAI,UAAU;AACb,UAAM,MAAM,SAA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ClB,eAAO;AAAA,UACN,QAAQ;AAAA,UACR,UAAU;AAAA,UACV,WAAW;AAAA,YACV;AAAA,YACA;AAAA,YACA,UAAU,KAAK;AAAA,YACf,gBAAgB,KAAK;AAAA,YACrB;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAEA,YAAM,QAAQ,WAAW,MAAM;AAE/B,aAAO,EAAE,QAAQ,OAAO,UAAU,UAAU,WAAW,KAAK;AAAA,IAC7D;AAAA,IAEA,YAAY,KAAK;AAChB,aAAO,QAAQ,SAAS,aAAa,GAAG;AAAA,IACzC;AAAA,IAEA,oBAAoB,UAAU;AAC7B,aAAO,QAAQ,SAAS,2BAA2B,QAAQ;AAAA,IAC5D;AAAA,IAEA,MAAM,kBAAkB,KAAK;AAC5B,YAAM,QAAQ,SAAS,aAAa,GAAG;AACvC,YAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,oBAAoB,CAAC;AAExE,aAAO,yBAAyB,SAAS,KAAK;AAAA,QAC7C,YAAY;AAAA,QACZ,aAAa;AAAA,MACd,CAAC;AAAA,IACF;AAAA,IAEA,WAAW,KAAK;AACf,aAAO,QAAQ,WAAW,GAAG;AAAA,IAC9B;AAAA,EACD;AACD;","names":["passed"]}
package/dist/result.d.ts CHANGED
@@ -12,6 +12,8 @@ export type SkipLinkElementResult = {
12
12
  passed: boolean;
13
13
  /** Why the candidate failed, or null when it passed. */
14
14
  failureReason: SkipLinkFailureReason | null;
15
+ /** PNG bytes of the focused skip link, clipped and padded. Only captured when it failed. */
16
+ screenshot?: Uint8Array;
15
17
  };
16
18
  export type SkipLinkResult = {
17
19
  /** Skip-link candidates found in the first tab stops. Empty when none were found. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a11y-pulse/skip-link-audit",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "WCAG 2.4.1 Bypass Blocks audit that finds skip-link-like in-page anchors in the first tab stops and verifies that activating them moves keyboard focus.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -54,7 +54,7 @@
54
54
  "@a11y-pulse/browser-adaptor": "*"
55
55
  },
56
56
  "devDependencies": {
57
- "happy-dom": "^20.12.0",
58
- "puppeteer": "^25.10.0"
57
+ "happy-dom": "^21.0.3",
58
+ "puppeteer": "^25.14.0"
59
59
  }
60
60
  }