@a11y-oracle/axe-bridge

中文文档
1.3.2发布于 2026/03/12MITTypeScriptES Module近 30 天下载 3071

Axe-core result post-processor that resolves 10 incomplete rules using visual analysis, keyboard interaction, and CDP inspection

原始使用文档
文档目录16 节
  1. The Problem
  2. The Solution
  3. Installation
  4. Usage
  5. Resolve All Incompletes (Recommended)
  6. With Options
  7. Individual Resolvers
  8. With Playwright
  9. With Cypress
  10. API Reference
  11. resolveAllIncomplete(cdp, axeResults, options?)
  12. Individual Resolvers
  13. Pipeline Utilities
  14. Types
  15. How It Works
  16. Dependencies

@a11y-oracle/axe-bridge

Axe-core result post-processor that resolves "incomplete" (Needs Review) findings using visual analysis, keyboard interaction, and CDP inspection. Drop-in middleware between axe-core's analyze() and your assertion layer.

The Problem

axe-core marks rules as "incomplete" when they require state changes, interaction, or spatial awareness that static DOM analysis cannot reliably perform. This creates noise in CI dashboards and requires manual review for rules like color contrast, focus indicators, target sizes, and more.

The Solution

resolveAllIncomplete() takes axe-core results and a live CDP session, then pipes them through 10 specialized resolvers that promote findings from incomplete to passes or violations:

#Rule IDWCAG SCTechnique
1color-contrast1.4.3CSS halo heuristic + pixel-level screenshot analysis
2identical-links-same-purpose2.4.4URL normalization and comparison
3link-in-text-block1.4.1Default-state computed style checks
4target-size2.5.8Bounding box measurements + spacing
5scrollable-region-focusable2.1.1Scroll height + focusable child traversal
6skip-link2.4.1Tab-focus visibility verification
7aria-hidden-focus4.1.2Full keyboard Tab traversal
8focus-indicator2.4.7Before/after screenshot pixel diff
9content-on-hover1.4.13Hover + dismiss interaction tests
10frame-testedN/ACross-origin iframe axe-core injection

Installation

npm install @a11y-oracle/axe-bridge

Usage

import { resolveAllIncomplete } from '@a11y-oracle/axe-bridge';

// After running axe-core while the page is still live:
const axeResults = await axe.run(document);
const resolved = await resolveAllIncomplete(cdpSession, axeResults);

// resolved.incomplete will have fewer (or zero) entries
// resolved.violations and resolved.passes will have the promoted entries

With Options

const resolved = await resolveAllIncomplete(cdpSession, axeResults, {
  wcagLevel: 'wcag22aa',
  contrast: {
    threshold: 4.5,              // normal text contrast ratio
    largeTextThreshold: 3.0,     // large text contrast ratio
    supermajorityPassRatio: 0.75, // auto-pass split decisions when 75%+ pixels pass
    bestCaseMultiplier: 2.0,     // auto-pass when best-case CR exceeds 2× threshold
  },
  focusIndicator: { focusSettleDelay: 150, diffThreshold: 0.2 },
  skipRules: ['frame-tested'], // skip specific resolvers
});

Individual Resolvers

Each resolver can be used standalone:

import { resolveIncompleteContrast } from '@a11y-oracle/axe-bridge';

const resolved = await resolveIncompleteContrast(cdpSession, axeResults, {
  wcagLevel: 'wcag22aa',
});

With Playwright

import { test, expect } from '@playwright/test';
import { resolveAllIncomplete } from '@a11y-oracle/axe-bridge';

test('no unresolved accessibility issues', async ({ page }) => {
  await page.goto('/my-page.html');
  const cdp = await page.context().newCDPSession(page);

  const axeResults = await axe.run(document);
  const resolved = await resolveAllIncomplete(cdp, axeResults);

  expect(resolved.violations).toHaveLength(0);
  expect(resolved.incomplete).toHaveLength(0);

  await cdp.detach();
});

With Cypress

// Using Cypress.automation for CDP access:
cy.window().then(async (win) => {
  const axeResults = await axeCore.run(win.document);

  // cdpSession obtained via Cypress.automation('remote:debugger:protocol', ...)
  const resolved = await resolveAllIncomplete(cdpSession, axeResults);

  expect(resolved.violations).to.have.length(0);
});

API Reference

resolveAllIncomplete(cdp, axeResults, options?)

Orchestrator that pipes results through all 10 resolvers in sequence. Each resolver receives the output of the previous one.

  • Parameters:
    • cdp: CDPSessionLike — CDP session connected to the page
    • axeResults: AxeResults — Raw results from axe-core's analyze()
    • options?: IncompleteResolutionOptions — Per-resolver options and skipRules filter
  • Returns: Promise<AxeResults> — Modified copy with resolved findings
  • Pipeline order: color-contrast → identical-links-same-purpose → link-in-text-block → target-size → scrollable-region-focusable → skip-link → aria-hidden-focus → focus-indicator → content-on-hover → frame-tested

Individual Resolvers

resolveIncompleteContrast(cdp, axeResults, options?)

Resolves color-contrast incomplete entries using CSS halo heuristics and pixel-level screenshot analysis. Resolved nodes (both passes and violations) are enriched with contrast data in the axe check's data field, including contrastRatio, expectedRatio, fgColor, bgColorLightest, bgColorDarkest, and algorithm ('visual-pixel' or 'visual-halo').

  • Options: ContrastResolutionOptions:
    • wcagLevel — WCAG conformance level (default: 'wcag22aa'). Thresholds are derived automatically (AA → 4.5/3.0). Level A has no contrast SC so the resolver is skipped.
    • threshold — Override minimum contrast ratio for normal text (overrides wcagLevel)
    • largeTextThreshold — Override minimum contrast ratio for large text (overrides wcagLevel)
    • supermajorityPassRatio — During a split decision (one extreme passes, one fails), auto-pass if at least this fraction of pixels pass (default: 0.75)
    • bestCaseMultiplier — During a split decision, auto-pass if the best-case contrast ratio exceeds the threshold multiplied by this value (default: 2.0)
  • Automatically detects large text from axe-core's check data (>= 24px or bold >= 18.66px)

resolveIdenticalLinksSamePurpose(cdp, axeResults)

Resolves identical-links-same-purpose by normalizing URLs (stripping query params, hashes, resolving relative paths) and comparing destinations.

  • Same destination → Pass, different → Violation

resolveLinkInTextBlock(cdp, axeResults, options?)

Resolves link-in-text-block by checking the default/resting state for non-color visual indicators.

  • Options: LinkInTextBlockOptions — linkTextContrastThreshold (default: 3.0)
  • Checks: text-decoration: underline, border-bottom > 0, font-weight difference from parent
  • If no non-color indicator: compares link vs surrounding text color contrast

resolveTargetSize(cdp, axeResults, options?)

Resolves target-size by measuring bounding boxes and center-to-center spacing.

  • Options: TargetSizeOptions — minSize (default: 24)
  • Width/height >= 24px → Pass; undersized with 24px+ spacing → Pass; otherwise → Violation

resolveScrollableRegionFocusable(cdp, axeResults, options?)

Resolves scrollable-region-focusable by checking scroll height, tabindex, and focusable children.

  • Options: ScrollableRegionOptions — maxChildren (default: 50)
  • Not actually scrollable → Pass; has tabindex >= 0 → Pass; focusable children scroll to content → Pass

resolveSkipLink(cdp, axeResults, options?)

Resolves skip-link by focusing the skip link and verifying it becomes visible.

  • Options: SkipLinkOptions — focusSettleDelay (default: 100)
  • Checks bounding box, viewport containment, opacity, clip, position

resolveAriaHiddenFocus(cdp, axeResults, options?)

Resolves aria-hidden-focus via a single keyboard Tab traversal across all flagged nodes.

  • Options: AriaHiddenFocusOptions — maxTabs (default: 100)
  • Tab lands on flagged element → Violation; traversal completes without landing → Pass

resolveFocusIndicator(cdp, axeResults, options?)

Resolves focus-indicator by pixel-diffing before/after focus screenshots. Elements are scrolled into the viewport before capture, ensuring off-screen elements produce valid screenshots. Enables focus emulation via Emulation.setFocusEmulationEnabled so focus indicators render even in headless browsers or Cypress AUT iframes.

  • Options: FocusIndicatorOptions — focusSettleDelay (default: 100), diffThreshold (default: 0.1%)
  • Screenshots are identical → Violation; pixels changed → Pass

resolveContentOnHover(cdp, axeResults, options?)

Resolves content-on-hover with hover and dismiss interaction tests.

  • Options: ContentOnHoverOptions — hoverDelay (default: 300), dismissDelay (default: 200)
  • Tests: content appears on hover, remains when mouse moves to content (hoverable), disappears on Escape (dismissible)

resolveFrameTested(cdp, axeResults, options?)

Resolves frame-tested by injecting axe-core into cross-origin iframes via CDP.

  • Options: FrameTestedOptions — axeSource (complete axe-core script), iframeTimeout (default: 30000)
  • Uses Page.createIsolatedWorld to bypass same-origin restrictions

Pipeline Utilities

Shared helpers used by all resolvers:

import {
  getSelector,        // Extract innermost CSS selector from axe node target
  cloneResults,       // Deep-clone AxeResults without mutation
  ruleShell,          // Create a rule shell (metadata only, no nodes)
  findIncompleteRule,  // Find a rule by ID in the incomplete array
  applyPromotions,    // Move nodes between incomplete/passes/violations
} from '@a11y-oracle/axe-bridge';

Types

import type {
  // Axe-core compatible types
  AxeResults,
  AxeRule,
  AxeNode,
  AxeCheck,

  // WCAG level
  WcagLevel,
  ContrastThresholds,

  // Per-resolver options
  ContrastResolutionOptions,
  LinkInTextBlockOptions,
  TargetSizeOptions,
  ScrollableRegionOptions,
  SkipLinkOptions,
  AriaHiddenFocusOptions,
  FocusIndicatorOptions,
  ContentOnHoverOptions,
  FrameTestedOptions,

  // Orchestrator options
  IncompleteResolutionOptions,

  // Pipeline utility types
  PromotionResult,
} from '@a11y-oracle/axe-bridge';

Note: Axe-core types are locally defined for structural compatibility without requiring axe-core as a runtime dependency.

How It Works

Each resolver follows a common pipeline pattern:

  1. Clone — Deep-clone the input results (original is never mutated)
  2. Find — Locate the target rule in the incomplete array
  3. Analyze — For each flagged node, run the resolver's specific technique (CDP queries, screenshots, keyboard traversal, etc.)
  4. Promote — Move resolved nodes to passes or violations; unresolved nodes stay in incomplete

The resolveAllIncomplete orchestrator chains all resolvers in sequence, so findings accumulate through the pipeline.

Dependencies

  • @a11y-oracle/visual-engine — Visual analysis engine (halo detection, pixel analysis, PNG decoding, CDP capture)
  • @a11y-oracle/focus-analyzer — Color parsing and contrast ratio computation
  • @a11y-oracle/keyboard-engine — Native CDP keyboard dispatch for skip-link, aria-hidden-focus, and content-on-hover
  • @a11y-oracle/cdp-types — CDPSessionLike interface for framework-agnostic CDP access

版本与发布记录

@a11y-oracle/axe-bridge 共发布 10 个版本,首次发布于 2026/03/05;过去 12 个月发布了 10 个版本。

版本发布日期距今
1.3.2latest2026/03/127 个月前
1.3.12026/03/117 个月前
1.3.02026/03/068 个月前
1.2.02026/03/068 个月前
1.1.42026/03/068 个月前
1.1.32026/03/068 个月前

关于 @a11y-oracle/axe-bridge 的常见问题

@a11y-oracle/axe-bridge 是什么?

Axe-core result post-processor that resolves 10 incomplete rules using visual analysis, keyboard interaction, and CDP inspection

如何安装 @a11y-oracle/axe-bridge?

在项目目录运行 npm install @a11y-oracle/axe-bridge,或使用 pnpm add / yarn add / bun add。

@a11y-oracle/axe-bridge 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@a11y-oracle/axe-bridge 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@a11y-oracle/axe-bridge 可以商用吗?

@a11y-oracle/axe-bridge 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@a11y-oracle/axe-bridge 的下载量有多少?

根据 npm 官方下载统计,@a11y-oracle/axe-bridge 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,071 次,日均约 102 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@a11y-oracle/axe-bridge 还在维护吗?

最新版本 1.3.2 发布于 2026/03/12(7 个月前);至今共发布 10 个版本,其中过去 12 个月发布了 10 个;首次发布于 2026/03/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。