@a11y-pulse/skip-link-audit 0.1.2 → 0.3.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/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;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,SAAS,MAAM,CAAC;AAC5B,QAAI,UAAU;AAEd,Q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,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\tinspectSkipLinkScript,\n\treadPageStateScript,\n\tresetFocusScript,\n\trestorePageStateScript,\n\ttype SkipLinkFocusPosition,\n\ttype SkipLinkPageState,\n\ttakeUnreachableSkipLinkScript,\n} from \"./browser-scripts\";\nimport type {\n\tSkipLinkElementResult,\n\tSkipLinkFailureReason,\n\tSkipLinkFocusLanding,\n\tSkipLinkResult,\n\tSkipLinkTarget,\n\tSkipLinkUnreachableResult,\n} from \"./result\";\n\nexport const DEFAULT_CANDIDATE_LIMIT = 3;\nexport const DEFAULT_ACTIVATION_POLL_MS = 250;\n\n/** How many unreachable skip links to report when none can be reached by tabbing. */\nconst UNREACHABLE_LIMIT = 3;\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\tlinkText: string;\n\t/** The element the fragment resolves to, or null when nothing matches it. */\n\ttarget: SkipLinkTarget | null;\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/** Where focus is relative to a skip link, read after a key press. */\nexport type FocusReading = {\n\tposition: SkipLinkFocusPosition;\n\t/** Whether the document's URL fragment is the one the link points at. */\n\tnavigated: boolean;\n\t/** Whether the link's target exists. */\n\ttargetExists: boolean;\n\t/** Whether the link's target exists and is rendered. */\n\ttargetRendered: boolean;\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\t/** Where focus is now, relative to the skip link behind `ref` and its target. */\n\treadFocus(ref: ElementRef): Promise<FocusReading>;\n\t/** Selector and opening tag of the focused element, or null when nothing is focused. */\n\tdescribeFocused(): Promise<{ selector: string; html: string } | null>;\n\t/** Skip links in the document that can never receive keyboard focus. */\n\tfindUnreachable(): Promise<SkipLinkUnreachableResult[]>;\n\t/** Record the URL, history length and scroll position so activating a link can be undone. */\n\tsaveState(): Promise<SkipLinkPageState>;\n\trestoreState(state: SkipLinkPageState): Promise<void>;\n\t/**\n\t * Drop focus and start the tab order from the top again, so the next Tab press does not carry on\n\t * from a skip target or from the last stop the audit looked at.\n\t */\n\tclearFocus(): Promise<void>;\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 links, then activate each one and check that\n * keyboard focus moves. Enables focus reporting up front, then drives the 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/** Enter alone moved focus to the target, or to later content when there is no target to reach. */\nfunction movedByEnter(focus: FocusReading): boolean {\n\tif (focus.position === \"inside-target\" || focus.position === \"after-target\") {\n\t\treturn true;\n\t}\n\n\treturn !focus.targetExists && focus.position === \"after-link\";\n}\n\nasync function landing(probe: SkipLinkProbe, focus: FocusReading): Promise<SkipLinkFocusLanding> {\n\tconst focused = focus.position === \"body\" ? null : await probe.describeFocused();\n\n\treturn {\n\t\tposition: focus.position,\n\t\tselector: focused?.selector ?? null,\n\t\thtml: focused?.html ?? null,\n\t};\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\tconst skipLinks: SkipLinkElementResult[] = [];\n\n\ttry {\n\t\tfor (let i = 0; i < options.candidateLimit; i++) {\n\t\t\tawait probe.pressTab();\n\n\t\t\tconst tabStop = await probe.probeTabStop();\n\n\t\t\tif (tabStop.isBody || seen.has(tabStop.identity)) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tseen.add(tabStop.identity);\n\n\t\t\tif (tabStop.candidate) {\n\t\t\t\tcollected.push({ ...tabStop.candidate, tabIndex: i + 1 });\n\t\t\t}\n\t\t}\n\n\t\tfor (const found of collected) {\n\t\t\ttry {\n\t\t\t\tconst state = await probe.saveState();\n\n\t\t\t\ttry {\n\t\t\t\t\tawait probe.focusHandle(found.handle);\n\t\t\t\t\tawait probe.pressEnter();\n\n\t\t\t\t\t// A link with no target is still activated: a script may move focus on its behalf.\n\t\t\t\t\tconst afterEnter = await pollFocus(probe, found.handle, options.activationPollMs);\n\t\t\t\t\tconst focusAfterEnter = await landing(probe, afterEnter);\n\n\t\t\t\t\tlet passed = movedByEnter(afterEnter);\n\t\t\t\t\tlet failureReason: SkipLinkFailureReason | null = null;\n\t\t\t\t\tlet focusAfterTab: SkipLinkFocusLanding | null = null;\n\n\t\t\t\t\tif (!passed && !afterEnter.targetExists) {\n\t\t\t\t\t\tfailureReason = \"target-missing\";\n\t\t\t\t\t} else if (!passed && !afterEnter.targetRendered) {\n\t\t\t\t\t\tfailureReason = \"target-hidden\";\n\t\t\t\t\t} else if (!passed) {\n\t\t\t\t\t\t// Following a fragment moves the browser's focus starting point without focusing\n\t\t\t\t\t\t// anything, so the next Tab shows whether the link worked.\n\t\t\t\t\t\tawait probe.pressTab();\n\n\t\t\t\t\t\tconst afterTab = await probe.readFocus(found.handle);\n\t\t\t\t\t\tconst activated = afterEnter.navigated || afterEnter.position !== \"skip-link\";\n\n\t\t\t\t\t\tfocusAfterTab = await landing(probe, afterTab);\n\t\t\t\t\t\t// Tabbing out of the document after the fragment was followed means the target\n\t\t\t\t\t\t// was reached and nothing focusable comes after it.\n\t\t\t\t\t\tpassed =\n\t\t\t\t\t\t\tafterTab.position === \"inside-target\" ||\n\t\t\t\t\t\t\t(activated && afterTab.position === \"after-target\") ||\n\t\t\t\t\t\t\t(afterEnter.navigated && afterTab.position === \"body\");\n\t\t\t\t\t\tfailureReason = passed ? null : \"activation-no-effect\";\n\t\t\t\t\t}\n\n\t\t\t\t\tskipLinks.push({\n\t\t\t\t\t\tselector: found.selector,\n\t\t\t\t\t\thtml: found.html,\n\t\t\t\t\t\tfragment: found.fragment,\n\t\t\t\t\t\ttabIndex: found.tabIndex,\n\t\t\t\t\t\tpassed,\n\t\t\t\t\t\tfailureReason,\n\t\t\t\t\t\tlinkText: found.linkText,\n\t\t\t\t\t\ttarget: found.target,\n\t\t\t\t\t\tfocusAfterEnter,\n\t\t\t\t\t\tfocusAfterTab,\n\t\t\t\t\t\tscreenshot: passed ? undefined : await probe.screenshotFocused(found.handle),\n\t\t\t\t\t});\n\t\t\t\t} finally {\n\t\t\t\t\tawait probe.restoreState(state);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tawait probe.disposeRef(found.handle);\n\t\t\t}\n\t\t}\n\t} finally {\n\t\t// Looking for candidates moved focus even when none was found, and so did each activation,\n\t\t// including one that threw. Whatever runs next starts tabbing from the top of the page.\n\t\tawait probe.clearFocus();\n\t}\n\n\t// A skip link nobody can tab to is only a problem when no other skip link works in its place.\n\tconst unreachable = collected.length === 0 ? await probe.findUnreachable() : [];\n\tconst passed = skipLinks.filter((link) => link.passed).length;\n\n\treturn {\n\t\tskipLinks,\n\t\tunreachable,\n\t\tsummary: {\n\t\t\tfound: skipLinks.length,\n\t\t\tpassed,\n\t\t\tfailed: skipLinks.length - passed,\n\t\t\tunreachable: unreachable.length,\n\t\t},\n\t};\n}\n\nasync function pollFocus(\n\tprobe: SkipLinkProbe,\n\tref: ElementRef,\n\tpollMs: number,\n): Promise<FocusReading> {\n\tlet focus = await probe.readFocus(ref);\n\tconst deadline = Date.now() + pollMs;\n\n\twhile (!movedByEnter(focus) && Date.now() < deadline) {\n\t\tawait new Promise((resolve) => setTimeout(resolve, 16));\n\n\t\tfocus = await probe.readFocus(ref);\n\t}\n\n\treturn focus;\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 handle = await adaptor.evaluateHandle(activeElementHandleScript);\n\t\t\tconst { link } = await adaptor.evaluate(inspectSkipLinkScript, handle, \"classify\");\n\n\t\t\tif (!link || link.isBody) {\n\t\t\t\tawait adaptor.disposeRef(handle);\n\n\t\t\t\treturn { isBody: true, identity: \"body\", candidate: null };\n\t\t\t}\n\n\t\t\tconst selector = await adaptor.evaluate(getSelector, handle);\n\n\t\t\tif (link.fragment && link.skipLike) {\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: truncateHtml(link.html),\n\t\t\t\t\t\tfragment: link.fragment,\n\t\t\t\t\t\tlinkText: link.linkText,\n\t\t\t\t\t\ttarget: link.target && { ...link.target, html: truncateHtml(link.target.html) },\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\tasync readFocus(ref) {\n\t\t\tconst { link } = await adaptor.evaluate(inspectSkipLinkScript, ref, \"focus\");\n\n\t\t\treturn {\n\t\t\t\tposition: link?.focus.position ?? \"body\",\n\t\t\t\tnavigated: link?.focus.navigated ?? false,\n\t\t\t\ttargetExists: Boolean(link?.target),\n\t\t\t\ttargetRendered: link?.target?.rendered ?? false,\n\t\t\t};\n\t\t},\n\n\t\tasync describeFocused() {\n\t\t\tconst handle = await adaptor.evaluateHandle(activeElementHandleScript);\n\n\t\t\ttry {\n\t\t\t\tconst { link } = await adaptor.evaluate(inspectSkipLinkScript, handle, \"focus\");\n\n\t\t\t\tif (!link || link.isBody) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tselector: await adaptor.evaluate(getSelector, handle),\n\t\t\t\t\thtml: truncateHtml(link.html),\n\t\t\t\t};\n\t\t\t} finally {\n\t\t\t\tawait adaptor.disposeRef(handle);\n\t\t\t}\n\t\t},\n\n\t\tasync findUnreachable() {\n\t\t\tconst { unreachable } = await adaptor.evaluate(\n\t\t\t\tinspectSkipLinkScript,\n\t\t\t\tnull,\n\t\t\t\t\"unreachable\",\n\t\t\t\tUNREACHABLE_LIMIT,\n\t\t\t);\n\t\t\tconst results: SkipLinkUnreachableResult[] = [];\n\n\t\t\tfor (const link of unreachable) {\n\t\t\t\tconst handle = await adaptor.evaluateHandle(takeUnreachableSkipLinkScript);\n\n\t\t\t\ttry {\n\t\t\t\t\tresults.push({\n\t\t\t\t\t\tselector: await adaptor.evaluate(getSelector, handle),\n\t\t\t\t\t\thtml: truncateHtml(link.html),\n\t\t\t\t\t\tfragment: link.fragment,\n\t\t\t\t\t\tlinkText: link.linkText,\n\t\t\t\t\t\treason: link.reason,\n\t\t\t\t\t});\n\t\t\t\t} finally {\n\t\t\t\t\tawait adaptor.disposeRef(handle);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn results;\n\t\t},\n\n\t\tsaveState() {\n\t\t\treturn adaptor.evaluate(readPageStateScript);\n\t\t},\n\n\t\trestoreState(state) {\n\t\t\treturn adaptor.evaluate(restorePageStateScript, state);\n\t\t},\n\n\t\tclearFocus() {\n\t\t\treturn adaptor.evaluate(resetFocusScript);\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 are serialized and injected into the audited page, so they must\n * not reference any symbols outside their own scope. Everything that needs the fragment parsing,\n * target resolution or skip-link heuristics goes through `inspectSkipLinkScript`, so there is one\n * copy of that logic and the tests exercise the code that ships.\n */\n\n/** Where the focused element sits relative to a skip link and its target. */\nexport type SkipLinkFocusPosition =\n\t/** Focus is on the target or inside it. */\n\t| \"inside-target\"\n\t/** Focus is on content that follows the target in document order. */\n\t| \"after-target\"\n\t/** Focus is on content after the link, and the link has no target to compare against. */\n\t| \"after-link\"\n\t/** Focus is still on the skip link. */\n\t| \"skip-link\"\n\t/** Nothing is focused. */\n\t| \"body\"\n\t/** Focus is somewhere else, such as before the link or between the link and its target. */\n\t| \"elsewhere\";\n\nexport type SkipLinkUnreachableReason =\n\t| \"not-rendered\"\n\t| \"visibility-hidden\"\n\t| \"inert\"\n\t| \"negative-tabindex\";\n\nexport type SkipLinkTargetInspection = {\n\tselector: string;\n\t/** Opening tag of the target. */\n\thtml: string;\n\t/** False when the target or an ancestor is `display: none` (or otherwise not rendered). */\n\trendered: boolean;\n};\n\nexport type SkipLinkInspection = {\n\t/** True when the inspected element is missing or is `<body>`. */\n\tisBody: boolean;\n\t/** Opening tag of the inspected element. */\n\thtml: string;\n\t/** Visible text of the link, falling back to its `aria-label`. */\n\tlinkText: string;\n\t/**\n\t * The same-document fragment the link points at, such as \"#main\". Null when the element is not a\n\t * link to a fragment of this document.\n\t */\n\tfragment: string | null;\n\t/** Whether the link looks like a skip link rather than a menu toggle or other in-page link. */\n\tskipLike: boolean;\n\ttarget: SkipLinkTargetInspection | null;\n\tfocus: {\n\t\tposition: SkipLinkFocusPosition;\n\t\t/** Whether the document's URL fragment is the one the link points at. */\n\t\tnavigated: boolean;\n\t};\n};\n\nexport type SkipLinkUnreachableInspection = {\n\thtml: string;\n\tlinkText: string;\n\tfragment: string;\n\treason: SkipLinkUnreachableReason;\n};\n\nexport type SkipLinkInspectionResult = {\n\t/** The inspected element. Null in \"unreachable\" mode. */\n\tlink: SkipLinkInspection | null;\n\t/** Skip links that can never receive focus. Only filled in \"unreachable\" mode. */\n\tunreachable: SkipLinkUnreachableInspection[];\n};\n\n/** Attribute that marks unreachable skip links so a handle can be taken to each one in turn. */\nexport const UNREACHABLE_MARKER = \"data-a11y-pulse-unreachable-skip-link\";\n\n/**\n * Inspect skip links in the page.\n *\n * - \"classify\": describe `el` and decide whether it is a skip link.\n * - \"focus\": describe `el` and where keyboard focus is relative to it and its target.\n * - \"unreachable\": ignore `el` and find skip links that can never receive keyboard focus, marking\n * each with `data-a11y-pulse-unreachable-skip-link`.\n */\nexport function inspectSkipLinkScript(\n\tel: Element | null,\n\tmode: \"classify\" | \"focus\" | \"unreachable\",\n\tlimit = 3,\n): SkipLinkInspectionResult {\n\t// Letters, digits and underscore in any script. `\\b` only knows ASCII, so without this\n\t// \"aller au\" matches inside \"Smaller audiences\" and accented words are cut in two.\n\tconst WORD = \"\\\\p{L}\\\\p{N}_\";\n\tconst START = `(?:^|[^${WORD}])`;\n\tconst END = `(?![${WORD}])`;\n\t// Verbs and prepositions that mean \"go to\" as much as \"skip to\" (\"Aller au panier\", \"Ga naar\n\t// winkelwagen\"), so they only count when a noun from NOUN follows.\n\tconst GO =\n\t\t\"skip|jump|go|zum|zur|springe|aller|passer|accéder|ir|saltar|salta|vai|passa|pular|avançar|ga|naar|spring|hoppa|hopp|gå|till|siirry|hyppää|przejdź|przeskocz|pomiń|přeskočit|přejít|перейти|пропустить\";\n\tconst FILLER =\n\t\t\"to|the|main|primary|zu|zum|zur|dem|der|direkt|au|aux|à|la|le|du|directement|al|a|el|alla|allo|ai|il|para|o|ao|naar|de|het|direct|till|til|det|do|na|k|ke|głównej|hlavní|hlavnímu|к|основному\";\n\tconst NOUN =\n\t\t\"content|main|navigation|nav|menu|search|footer|\\\\p{L}*inhalt|\\\\p{L}*navigation|menü|suche|contenu|recherche|contenido|navegación|menú|búsqueda|contenuto|navigazione|ricerca|conteúdo|navegação|pesquisa|\\\\p{L}*inhoud|navigatie|zoeken|\\\\p{L}*innehåll\\\\p{L}*|navigering\\\\p{L}*|meny\\\\p{L}*|\\\\p{L}*innhold\\\\p{L}*|\\\\p{L}*indhold\\\\p{L}*|navigasjon\\\\p{L}*|\\\\p{L}*sisält\\\\p{L}*|navigaatio\\\\p{L}*|valikko\\\\p{L}*|treści|zawartości|nawigacj\\\\p{L}*|obsah\\\\p{L}*|navigac\\\\p{L}*|содержани\\\\p{L}*|контент\\\\p{L}*|навигаци\\\\p{L}*|меню\";\n\tconst SKIP_WORDS = new RegExp(\n\t\t[\n\t\t\t// \"Skip to content\", \"Aller au contenu\", \"Ga direct naar de inhoud\", \"Перейти к содержанию\".\n\t\t\t`${START}(?:${GO})(?:\\\\s+(?:${FILLER})){0,3}\\\\s+(?:${NOUN})${END}`,\n\t\t\t// Verbs that only ever mean \"skip\".\n\t\t\t`${START}(?:skip|überspringen)${END}`,\n\t\t\t// Scripts written without spaces between words.\n\t\t\t\"スキップ|本文へ|メインコンテンツへ|跳[过過]|跳(?:到|至|转到|轉到)\\\\s*(?:主要|主|正文|内容|內容|导航|導航)|건너뛰기|본문\\\\s*(?:으로|바로\\\\s*가기)\",\n\t\t].join(\"|\"),\n\t\t\"iu\",\n\t);\n\t// A class or id that names the link a skip link: \"skip\", \"skip-link\", \"skiplink\", \"skip-to-content\".\n\tconst SKIP_TOKEN = /^skip(?:[-_]?(?:link|nav|navigation|main|content|to[-_]?[a-z]+))?$/i;\n\t// Ids that pages conventionally give their main content when they have no main landmark.\n\tconst CONTENT_ID =\n\t\t/^(?:(?:main|page|site|primary|skip)[-_]?)?(?:content|main)(?:[-_]?(?:area|wrapper|container|start))?$|^primary$/i;\n\tconst UNREACHABLE_ATTR = \"data-a11y-pulse-unreachable-skip-link\";\n\n\tfunction openingTag(node: Element): string {\n\t\treturn (node.cloneNode(false) as Element).outerHTML;\n\t}\n\n\tfunction isRendered(node: Element): boolean {\n\t\tif (typeof node.checkVisibility === \"function\") {\n\t\t\treturn node.checkVisibility();\n\t\t}\n\n\t\tfor (let current: Element | null = node; current; current = current.parentElement) {\n\t\t\tif (getComputedStyle(current).display === \"none\") {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tfunction textOf(node: Element): string {\n\t\tconst text = (node.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n\n\t\treturn (text || (node.getAttribute(\"aria-label\") ?? \"\").trim()).slice(0, 200);\n\t}\n\n\t/** The fragment of a link to this document, or null for any other element or destination. */\n\tfunction fragmentOf(node: Element): string | null {\n\t\tif (node.tagName !== \"A\" || !node.hasAttribute(\"href\")) {\n\t\t\treturn null;\n\t\t}\n\n\t\tlet url: URL;\n\t\tlet here: URL;\n\n\t\ttry {\n\t\t\t// `href` is the resolved URL, so `/page#main`, absolute URLs and `<base>` are all handled.\n\t\t\turl = new URL((node as HTMLAnchorElement).href);\n\t\t\there = new URL(location.href);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (\n\t\t\turl.origin !== here.origin ||\n\t\t\turl.pathname !== here.pathname ||\n\t\t\turl.search !== here.search\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst hash = url.hash;\n\n\t\t// A bare `#` and `#top` scroll to the top, and hash-router paths are not element ids.\n\t\tif (hash === \"\" || hash === \"#\" || hash.toLowerCase() === \"#top\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (hash.startsWith(\"#/\") || hash.startsWith(\"#!/\")) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn hash;\n\t}\n\n\t/** Resolve a fragment the way browsers do: an id first, then an `<a name>`. */\n\tfunction targetOf(fragment: string): Element | null {\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\tfor (const id of raw === decoded ? [raw] : [raw, decoded]) {\n\t\t\tconst byId = document.getElementById(id);\n\n\t\t\tif (byId) {\n\t\t\t\treturn byId;\n\t\t\t}\n\n\t\t\tfor (const named of Array.from(document.getElementsByName(id))) {\n\t\t\t\tif (named.tagName === \"A\") {\n\t\t\t\t\treturn named;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfunction follows(node: Node, reference: Node): boolean {\n\t\treturn Boolean(reference.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING);\n\t}\n\n\t/** Skip wording in what the link says: its text or its `aria-label`. */\n\tfunction hasSkipWords(node: Element): boolean {\n\t\treturn SKIP_WORDS.test(`${textOf(node)} ${node.getAttribute(\"aria-label\") ?? \"\"}`);\n\t}\n\n\t/** A class or id that marks the link as a skip link, such as `class=\"skip-link\"`. */\n\tfunction hasSkipToken(node: Element): boolean {\n\t\tif (SKIP_TOKEN.test(node.id)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn (node.getAttribute(\"class\") ?? \"\").split(/\\s+/).some((token) => SKIP_TOKEN.test(token));\n\t}\n\n\t/** Whether the target is the page's main content: the main landmark, a heading, or around either. */\n\tfunction isContentTarget(target: Element): boolean {\n\t\tif (target.matches('h1, h2, h3, h4, h5, h6, [role=\"heading\"]')) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst main = document.querySelector('main, [role=\"main\"]');\n\n\t\tif (main) {\n\t\t\treturn target === main || target.contains(main) || main.contains(target);\n\t\t}\n\n\t\t// Without a main landmark, an id such as \"content\" or \"main-content\" is the next best sign.\n\t\treturn CONTENT_ID.test(target.id || (target.getAttribute(\"name\") ?? \"\"));\n\t}\n\n\tfunction isSkipLike(link: Element, target: Element | null): boolean {\n\t\tconst role = link.getAttribute(\"role\");\n\n\t\t// Disclosure toggles, tabs and link-shaped buttons act on the page instead of moving focus.\n\t\tif (link.hasAttribute(\"aria-expanded\") || role === \"tab\" || role === \"button\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (hasSkipWords(link) || hasSkipToken(link)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// From here on only the target can vouch for the link. Jumping past other controls is not\n\t\t// enough: a \"Menu\" link to a navigation block further down the page does that too.\n\t\tif (!target || !follows(target, link)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// A menu or panel revealed by `:target` is hidden until its link is followed, and navigation\n\t\t// is what a skip link skips, not where one goes without saying so.\n\t\tif (!isRendered(target) || target.closest('nav, [role=\"navigation\"]')) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn isContentTarget(target);\n\t}\n\n\tfunction targetSelector(target: Element): string {\n\t\tif (target.id) {\n\t\t\treturn `#${CSS.escape(target.id)}`;\n\t\t}\n\n\t\treturn `a[name=\"${CSS.escape(target.getAttribute(\"name\") ?? \"\")}\"]`;\n\t}\n\n\tfunction unreachableReason(link: Element): SkipLinkUnreachableReason | null {\n\t\tif (!isRendered(link)) {\n\t\t\treturn \"not-rendered\";\n\t\t}\n\n\t\tconst visibility = getComputedStyle(link).visibility;\n\n\t\tif (visibility === \"hidden\" || visibility === \"collapse\") {\n\t\t\treturn \"visibility-hidden\";\n\t\t}\n\n\t\tif (link.closest(\"[inert]\")) {\n\t\t\treturn \"inert\";\n\t\t}\n\n\t\tconst tabindex = link.getAttribute(\"tabindex\");\n\n\t\tif (tabindex !== null && Number.parseInt(tabindex, 10) < 0) {\n\t\t\treturn \"negative-tabindex\";\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tif (mode === \"unreachable\") {\n\t\tconst unreachable: SkipLinkUnreachableInspection[] = [];\n\n\t\tfor (const marked of Array.from(document.querySelectorAll(`[${UNREACHABLE_ATTR}]`))) {\n\t\t\tmarked.removeAttribute(UNREACHABLE_ATTR);\n\t\t}\n\n\t\t// Skip links sit at the top of the document, so only its first links are worth reading.\n\t\tfor (const link of Array.from(document.querySelectorAll(\"a[href]\")).slice(0, 50)) {\n\t\t\tif (unreachable.length >= limit) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst fragment = fragmentOf(link);\n\n\t\t\t// Only what the link says counts here. A hidden link is not about to be followed, so there\n\t\t\t// is no target behaviour to go on, and class names are too loose a sign on their own.\n\t\t\tif (!fragment || !hasSkipWords(link) || !isSkipLike(link, targetOf(fragment))) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst reason = unreachableReason(link);\n\n\t\t\tif (!reason) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst html = openingTag(link);\n\n\t\t\tlink.setAttribute(UNREACHABLE_ATTR, String(unreachable.length));\n\t\t\tunreachable.push({ html, linkText: textOf(link), fragment, reason });\n\t\t}\n\n\t\treturn { link: null, unreachable };\n\t}\n\n\tif (!el || el === document.body || el === document.documentElement) {\n\t\treturn {\n\t\t\tlink: {\n\t\t\t\tisBody: true,\n\t\t\t\thtml: \"\",\n\t\t\t\tlinkText: \"\",\n\t\t\t\tfragment: null,\n\t\t\t\tskipLike: false,\n\t\t\t\ttarget: null,\n\t\t\t\tfocus: { position: \"body\", navigated: false },\n\t\t\t},\n\t\t\tunreachable: [],\n\t\t};\n\t}\n\n\tconst fragment = fragmentOf(el);\n\tconst target = fragment ? targetOf(fragment) : null;\n\n\t// Compare document positions on the light-DOM host, and identity on the deepest focused node.\n\tconst host = document.activeElement;\n\tlet active = host;\n\n\twhile (active?.shadowRoot?.activeElement) {\n\t\tactive = active.shadowRoot.activeElement;\n\t}\n\n\tlet position: SkipLinkFocusPosition = \"elsewhere\";\n\n\tif (!host || !active || host === document.body || host === document.documentElement) {\n\t\tposition = \"body\";\n\t} else if (active === el) {\n\t\tposition = \"skip-link\";\n\t} else if (target && (active === target || target.contains(active) || target.contains(host))) {\n\t\tposition = \"inside-target\";\n\t} else if (target && follows(host, target)) {\n\t\tposition = \"after-target\";\n\t} else if (!target && follows(host, el)) {\n\t\tposition = \"after-link\";\n\t}\n\n\treturn {\n\t\tlink: {\n\t\t\tisBody: false,\n\t\t\thtml: openingTag(el),\n\t\t\tlinkText: textOf(el),\n\t\t\tfragment,\n\t\t\tskipLike: mode === \"classify\" && fragment !== null ? isSkipLike(el, target) : false,\n\t\t\ttarget: target\n\t\t\t\t? {\n\t\t\t\t\t\tselector: targetSelector(target),\n\t\t\t\t\t\thtml: openingTag(target),\n\t\t\t\t\t\trendered: isRendered(target),\n\t\t\t\t\t}\n\t\t\t\t: null,\n\t\t\tfocus: { position, navigated: fragment !== null && location.hash === fragment },\n\t\t},\n\t\tunreachable: [],\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 * Return the next skip link marked by `inspectSkipLinkScript` in \"unreachable\" mode, removing its\n * marker so the following call returns the one after it.\n */\nexport function takeUnreachableSkipLinkScript(): Element | null {\n\tconst marked = document.querySelector(\"[data-a11y-pulse-unreachable-skip-link]\");\n\n\tmarked?.removeAttribute(\"data-a11y-pulse-unreachable-skip-link\");\n\n\treturn marked;\n}\n\nexport type SkipLinkPageState = {\n\thref: string;\n\tscrollX: number;\n\tscrollY: number;\n\t/** `history.length` before the link was activated, to tell whether following it added an entry. */\n\thistoryLength: number;\n};\n\nexport function readPageStateScript(): SkipLinkPageState {\n\treturn {\n\t\thref: location.href,\n\t\tscrollX: window.scrollX,\n\t\tscrollY: window.scrollY,\n\t\thistoryLength: history.length,\n\t};\n}\n\n/**\n * Put the URL, the `:target` element and the scroll position back the way they were before a skip\n * link was activated, so whatever runs next sees the page as it was loaded.\n *\n * Following a fragment link adds a history entry, so the way back is to go back: that returns the\n * document to the entry it was on, which also resets `:target` (rewriting the URL with\n * `replaceState` does not). The entry that was added stays ahead in the history as a forward entry,\n * because nothing can remove one. When the URL changed without a new entry, or by more than its\n * fragment, the URL is rewritten in place instead and `:target` is left as it is.\n */\nexport function restorePageStateScript(state: SkipLinkPageState): Promise<void> {\n\tconst withoutFragment = (href: string): string => href.split(\"#\")[0] ?? href;\n\n\tconst rewrite = (): void => {\n\t\tif (location.href === state.href) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\thistory.replaceState(history.state, \"\", state.href);\n\t\t} catch {\n\t\t\t// Documents that cannot rewrite their URL (`about:blank`, sandboxed frames) keep the hash.\n\t\t}\n\t};\n\n\tconst scroll = (): void => {\n\t\twindow.scrollTo(state.scrollX, state.scrollY);\n\t};\n\n\tif (\n\t\tlocation.href === state.href ||\n\t\twithoutFragment(location.href) !== withoutFragment(state.href) ||\n\t\thistory.length !== state.historyLength + 1\n\t) {\n\t\trewrite();\n\t\tscroll();\n\n\t\treturn Promise.resolve();\n\t}\n\n\treturn new Promise((resolve) => {\n\t\tlet settled = false;\n\n\t\tconst settle = (): void => {\n\t\t\tif (settled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsettled = true;\n\t\t\twindow.removeEventListener(\"popstate\", onPopState);\n\t\t\trewrite();\n\t\t\tscroll();\n\t\t\tresolve();\n\t\t};\n\n\t\t// The browser finishes a traversal (its own scroll restoration, and moving the point Tab\n\t\t// starts from) when it next renders, so wait that out instead of racing it. The timer is\n\t\t// for a page that is not being rendered and so never gets its frames.\n\t\tconst onPopState = (): void => {\n\t\t\trequestAnimationFrame(() => requestAnimationFrame(settle));\n\t\t\tsetTimeout(settle, 100);\n\t\t};\n\n\t\twindow.addEventListener(\"popstate\", onPopState);\n\t\t// A traversal that the page or the browser never completes must not hold the audit up.\n\t\tsetTimeout(settle, 1000);\n\t\thistory.back();\n\t});\n}\n\nexport function focusScript(el: Element | null): void {\n\t(el as HTMLElement | null)?.focus();\n}\n\n/**\n * Drop focus and put the point sequential focus navigation starts from back at the top of the\n * document, so the next Tab press reaches the first tab stop as it would on a freshly loaded page.\n * Blurring alone leaves that point where focus last was: on a skip link's target, mid-page.\n *\n * The point is moved by focusing a throwaway node. On a page with a positive `tabindex` the node\n * has to stay in front of the first element in the tab order until focus next moves, and removes\n * itself then; otherwise it is taken straight out again and nothing is left behind.\n */\nexport function resetFocusScript(): Promise<void> {\n\t// Must be a string literal inside this function: it is serialized into the page.\n\tconst anchorAttr = \"data-a11y-pulse-skip-link-focus-start\";\n\n\t// Following a fragment, or going back from one, moves the starting point when the browser next\n\t// renders. Resetting it before then would be undone, so let pending frames run first. The timer\n\t// is for a page that is not being rendered and so never gets its frames.\n\treturn new Promise((resolve) => {\n\t\tlet done = false;\n\n\t\tconst run = (): void => {\n\t\t\tif (done) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdone = true;\n\n\t\t\ttry {\n\t\t\t\treset();\n\t\t\t} finally {\n\t\t\t\tresolve();\n\t\t\t}\n\t\t};\n\n\t\trequestAnimationFrame(() => requestAnimationFrame(run));\n\t\tsetTimeout(run, 100);\n\t});\n\n\tfunction reset(): void {\n\t\tlet active = document.activeElement;\n\n\t\twhile (active?.shadowRoot?.activeElement) {\n\t\t\tactive = active.shadowRoot.activeElement;\n\t\t}\n\n\t\t(active as HTMLElement | null)?.blur?.();\n\n\t\tfor (const leftover of Array.from(document.querySelectorAll(`[${anchorAttr}]`))) {\n\t\t\tleftover.remove();\n\t\t}\n\n\t\tconst root = document.documentElement;\n\t\tconst body = document.body;\n\n\t\tif (!root || !body) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst place = (parent: Node, before: Node | null): HTMLElement | null => {\n\t\t\tconst anchor = document.createElement(\"span\");\n\n\t\t\tanchor.tabIndex = -1;\n\t\t\tanchor.setAttribute(anchorAttr, \"\");\n\t\t\tanchor.setAttribute(\"aria-hidden\", \"true\");\n\t\t\tanchor.style.cssText = \"position:fixed;top:0;left:0;width:1px;height:1px;outline:none\";\n\n\t\t\ttry {\n\t\t\t\tparent.insertBefore(anchor, before);\n\t\t\t\tanchor.focus({ preventScroll: true });\n\t\t\t} catch {\n\t\t\t\t// A document that refuses the node is left as it is.\n\t\t\t}\n\n\t\t\tif (document.activeElement === anchor) {\n\t\t\t\treturn anchor;\n\t\t\t}\n\n\t\t\tanchor.remove();\n\n\t\t\treturn null;\n\t\t};\n\n\t\t// A positive tabindex puts its element ahead of everything else, lowest value first.\n\t\tlet first: Element | null = null;\n\t\tlet lowest = Number.POSITIVE_INFINITY;\n\n\t\tfor (const candidate of Array.from(document.querySelectorAll(\"[tabindex]\"))) {\n\t\t\tconst tabIndex = (candidate as HTMLElement).tabIndex;\n\n\t\t\tif (tabIndex <= 0 || tabIndex >= lowest) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tcandidate.matches(\":disabled\") ||\n\t\t\t\tcandidate.closest(\"[inert]\") ||\n\t\t\t\t(typeof candidate.checkVisibility === \"function\" &&\n\t\t\t\t\t!candidate.checkVisibility({ checkVisibilityCSS: true }))\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfirst = candidate;\n\t\t\tlowest = tabIndex;\n\t\t}\n\n\t\tif (first?.parentNode) {\n\t\t\tconst anchor = place(first.parentNode, first);\n\n\t\t\tif (anchor) {\n\t\t\t\tanchor.blur();\n\n\t\t\t\tconst cleanUp = (event: Event): void => {\n\t\t\t\t\tif (event.target !== anchor) {\n\t\t\t\t\t\tanchor.remove();\n\t\t\t\t\t\twindow.removeEventListener(\"focus\", cleanUp, true);\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\twindow.addEventListener(\"focus\", cleanUp, true);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Ahead of <body> first, so that a focusable <body> is still the first stop.\n\t\tconst places: Array<[Node, Node | null]> = [\n\t\t\t[root, body],\n\t\t\t[body, body.firstChild],\n\t\t];\n\n\t\tfor (const [parent, before] of places) {\n\t\t\tconst anchor = place(parent, before);\n\n\t\t\tif (anchor) {\n\t\t\t\tanchor.remove();\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";AAAA,SAAS,gCAAgC;AACzC,SAAS,aAAa,oBAAoB;;;ACkFnC,SAAS,sBACf,IACA,MACA,QAAQ,GACmB;AAG3B,QAAM,OAAO;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AAY,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":["fragment","target","passed"]}
package/dist/result.d.ts CHANGED
@@ -1,4 +1,24 @@
1
- export type SkipLinkFailureReason = "target-missing" | "activation-no-effect";
1
+ import type { SkipLinkFocusPosition, SkipLinkUnreachableReason } from "./browser-scripts";
2
+ export type { SkipLinkFocusPosition, SkipLinkUnreachableReason };
3
+ export type SkipLinkFailureReason = "target-missing" | "target-hidden" | "activation-no-effect";
4
+ /** The element a skip link's fragment resolves to. */
5
+ export type SkipLinkTarget = {
6
+ /** Selector for the target, by `id` or `a[name]`. */
7
+ selector: string;
8
+ /** Truncated opening tag. */
9
+ html: string;
10
+ /** False when the target or one of its ancestors is not rendered, such as `display: none`. */
11
+ rendered: boolean;
12
+ };
13
+ /** Where keyboard focus was after a key press. */
14
+ export type SkipLinkFocusLanding = {
15
+ /** Where the focused element sits relative to the skip link and its target. */
16
+ position: SkipLinkFocusPosition;
17
+ /** Selector for the focused element, or null when nothing was focused. */
18
+ selector: string | null;
19
+ /** Truncated opening tag of the focused element, or null when nothing was focused. */
20
+ html: string | null;
21
+ };
2
22
  export type SkipLinkElementResult = {
3
23
  /** Selector for the skip-link element (see getSelector). */
4
24
  selector: string;
@@ -12,13 +32,45 @@ export type SkipLinkElementResult = {
12
32
  passed: boolean;
13
33
  /** Why the candidate failed, or null when it passed. */
14
34
  failureReason: SkipLinkFailureReason | null;
35
+ /** Text of the link, falling back to its `aria-label`. */
36
+ linkText?: string;
37
+ /** The element the fragment resolves to, or null when nothing in the page matches it. */
38
+ target?: SkipLinkTarget | null;
39
+ /** Where focus was once Enter had been pressed on the link. */
40
+ focusAfterEnter?: SkipLinkFocusLanding;
41
+ /**
42
+ * Where focus was after the follow-up Tab, which is only pressed when Enter did not visibly move
43
+ * focus. Null when it was not pressed.
44
+ */
45
+ focusAfterTab?: SkipLinkFocusLanding | null;
46
+ /** PNG bytes of the focused skip link, clipped and padded. Only captured when it failed. */
47
+ screenshot?: Uint8Array;
48
+ };
49
+ /** A skip link that is in the document but can never receive keyboard focus. */
50
+ export type SkipLinkUnreachableResult = {
51
+ /** Selector for the skip-link element (see getSelector). */
52
+ selector: string;
53
+ /** Truncated opening tag. */
54
+ html: string;
55
+ /** The href fragment, e.g. "#main". */
56
+ fragment: string;
57
+ /** Text of the link, falling back to its `aria-label`. */
58
+ linkText: string;
59
+ /** Why the link cannot be focused. */
60
+ reason: SkipLinkUnreachableReason;
15
61
  };
16
62
  export type SkipLinkResult = {
17
63
  /** Skip-link candidates found in the first tab stops. Empty when none were found. */
18
64
  skipLinks: SkipLinkElementResult[];
65
+ /**
66
+ * Skip links that exist in the document but can never be focused. Only looked for when no skip
67
+ * link was reached by tabbing.
68
+ */
69
+ unreachable: SkipLinkUnreachableResult[];
19
70
  summary: {
20
71
  found: number;
21
72
  passed: number;
22
73
  failed: number;
74
+ unreachable: number;
23
75
  };
24
76
  };
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.3.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.4",
58
+ "puppeteer": "^25.16.0"
59
59
  }
60
60
  }