An open source design system that's fully customizable and agent ready
TypeScript
test(a11y): Slider (Multi-Thumb) contract and range Slider binding (#10830)
Cindy Zhangf36bd72b81e7
diff --git a/apps/storybook/stories/SliderA11y.stories.tsx b/apps/storybook/stories/SliderA11y.stories.tsxindex 332538cc49..302c10b44c 100644--- a/apps/storybook/stories/SliderA11y.stories.tsx+++ b/apps/storybook/stories/SliderA11y.stories.tsx@@ -2,14 +2,16 @@/*** @file SliderA11y.stories.tsx- * @input The Slider binding states, rendered through the binding's own renderer so the jsdom and Chromium lanes see the same tree+ * @input The Slider and range Slider binding states, rendered through each binding's own renderer so the jsdom and Chromium lanes see the same tree* @output One checked-in story per state for the Chromium accessibility lane; excluded from the visual matrix- * @position Browser fixtures for component:Slider AR1 (SLIDER_PATTERN)+ * @position Browser fixtures for component:Slider AR1 (SLIDER_PATTERN, and SLIDER_MULTITHUMB_PATTERN in range mode)*/import type {Meta, StoryObj} from '@storybook/react';import {renderSliderState} from '../../../packages/core/src/Slider/__tests__/Slider.a11y.renders';import {SLIDER_BINDING_STATES} from '../../../packages/core/src/Slider/__tests__/Slider.a11y.states';+import {renderSliderRangeState} from '../../../packages/core/src/Slider/__tests__/SliderRange.a11y.renders';+import {SLIDER_RANGE_BINDING_STATES} from '../../../packages/core/src/Slider/__tests__/SliderRange.a11y.states';const meta = {title: 'A11y/Slider',@@ -34,3 +36,22 @@ export const HorizontalRtl = storyFor('horizontal-rtl');export const Formatted = storyFor('formatted');export const DisabledWithMessage = storyFor('disabled-with-message');export const StepThree = storyFor('step-three');++function rangeStoryFor(+ id: (typeof SLIDER_RANGE_BINDING_STATES)[number]['id'],+): Story {+ const state = SLIDER_RANGE_BINDING_STATES.find(+ candidate => candidate.id === id,+ );+ if (state == null) {+ throw new Error(`no range Slider binding state "${id}"`);+ }+ return {render: () => renderSliderRangeState(state)};+}++export const Range = rangeStoryFor('range');+export const RangeSeparation = rangeStoryFor('range-separation');+export const RangeCoincident = rangeStoryFor('range-coincident');+export const RangeRtl = rangeStoryFor('range-rtl');+export const RangeVertical = rangeStoryFor('range-vertical');+export const RangeFormatted = rangeStoryFor('range-formatted');diff --git a/internal/a11y-spec/README.md b/internal/a11y-spec/README.mdindex 9c169b9c30..e438cd4496 100644--- a/internal/a11y-spec/README.md+++ b/internal/a11y-spec/README.md@@ -62,6 +62,7 @@ src/├── carousel.* non-rotating collection, slide, off-screen, and focus semantics├── tree-view.* a tree's roles, names, expanded state, one Tab stop, and arrow/Home/End/Enter-or-Space/typeahead movement├── slider.* a thumb's role, name, values, text, orientation, and arrow/Page/Home/End keys (RTL-mirrored arrows)+ ├── slider-multithumb.* two thumbs' distinct names, bounds that stop at and follow the other thumb, no crossing, and a constant Tab order├── progressbar.* a progress indicator's role and name, value and range or indeterminate state, value text, and a subtree with nothing focusable├── accordion.* a group's header role and name, panel state, single-expansion collapse, page Tab order├── breadcrumb.* landmark, list-trail, current-page, and separator semantics@@ -73,37 +74,38 @@ src/## The patterns-| Pattern | Adopted from | Bound by |-| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| `radio-group` | [APG radio group](https://www.w3.org/WAI/ARIA/apg/patterns/radio/) | RadioList, SegmentedControl; role/state portions of DropdownMenu radio items |-| `checkbox` | [APG checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/) | CheckboxInput, CheckboxListItem, DropdownMenuCheckboxItem, SelectableCard |-| `switch` | [APG switch](https://www.w3.org/WAI/ARIA/apg/patterns/switch/) | Switch |-| `button` | [APG button](https://www.w3.org/WAI/ARIA/apg/patterns/button/) | Button, IconButton, ClickableCard, SideNavCollapseButton, ChatSendButton |-| `toggle-button` | Toggle-button semantics in the [APG button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/) | ToggleButton, including standalone and grouped states |-| `text-input` | Native HTML controls and [WAI-ARIA textbox](https://www.w3.org/TR/wai-aria-1.2/#textbox) | TextInput, TextArea |-| `modal-dialog` | [APG dialog (modal)](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/) | Dialog |-| `status-message` | [WCAG 2.2 Status Messages](https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html) | Toast, FieldStatus, Spinner, ChatSystemMessage, ChatTypingIndicator, ProgressBar |-| `tabs` | [APG Tabs](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/) | Explicit `role="tablist"` TabList, Tab, and caller-authored tabpanels |-| `listbox` | [WAI-ARIA 1.2 Listbox](https://www.w3.org/TR/wai-aria-1.2/#listbox) and WCAG 2.2 semantics | Selector and MultiSelector popup listbox, group, and option parts |-| `spinbutton` | WCAG 2.2 semantics and [APG Spinbutton](https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/) | NumberInput |-| `disclosure` | [APG Disclosure](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/) | Standalone Collapsible triggers and their controlled content |-| `menu-button` | [APG Menu Button](https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/) required parts; the optional ArrowDown/ArrowUp opens Astryx ships are advisory | Anchored DropdownMenu and MoreMenu triggers: button role and name, `aria-haspopup="menu"`, `aria-expanded`, `aria-controls`, Enter/Space open on the first enabled item (advisory: ArrowDown on the first, ArrowUp on the last) |-| `menu` | [APG Menu and Menubar](https://www.w3.org/WAI/ARIA/apg/patterns/menubar/) menu; arrows (with wrap) and Home/End per AST-020 FR15; typeahead advisory | DropdownMenu pointer menu: named `menu`, item roles/names, `aria-checked`, `aria-disabled`, arrows with wrap, Home/End, Enter and Escape back to the trigger, Tab out (advisory: typeahead) |-| `toolbar` | [APG Toolbar](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/); arrows (with wrap) and Home/End per AST-020 FR15 | Toolbar: named `toolbar`, `aria-orientation`, controls inside it, one Tab stop entering on the first enabled control, next/previous arrows (RTL-mirrored, Down/Up when vertical) with wrap, Home/End |-| `tooltip` | [APG Tooltip](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/) role and relationship per AST-020 FR15; WCAG 1.4.13; three rows advisory | Tooltip, useTooltip: `tooltip` role, `aria-describedby` and computed description, focus shows it (focus stays), Escape dismisses, hover keeps it over trigger and tooltip (advisory: blur hides, hover shows, pointer leaving hides) |-| `accordion` | [APG Accordion](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) required parts | CollapsibleGroup headers: button role and name, expanded state, controlled panel, Enter/Space, single-expansion sibling collapse, page Tab order, no arrow-key movement (single-expansion collapse, grouped Tab order, no arrow movement are advisory until `component:CollapsibleGroup` AR4 is current) |-| `breadcrumb` | WCAG 2.2 semantics; [APG Breadcrumb](https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/) as context | Breadcrumbs landmarks, list trails, current-page state, and separators |-| `combobox` | WCAG 2.2 + [WAI-ARIA 1.2 Combobox](https://www.w3.org/TR/wai-aria-1.2/#combobox); APG as context | Selector trigger identity, state, popup, and active-descendant relationships |-| `landmark` | WCAG 2.2 semantics; [APG Landmark Regions](https://www.w3.org/WAI/ARIA/apg/patterns/landmarks/) as context | LayoutHeader, LayoutContent, LayoutFooter, and LayoutPanel caller-declared landmarks |-| `slider` | [APG Slider](https://www.w3.org/WAI/ARIA/apg/patterns/slider/) role, values, name, orientation and keys | Slider thumbs: role, name, now/min/max, value text, orientation, arrows (RTL-mirrored), Page, Home/End, disabled keeps value |-| `progressbar` | WCAG 2.2 4.1.2 and [WAI-ARIA 1.2 progressbar](https://www.w3.org/TR/wai-aria-1.2/#progressbar); no APG pattern exists | ProgressBar, Lab CircularProgress: progressbar role and name, now/min/max, indeterminate claims no value, value text, no focusable descendants (target marks sit beside the bar) |-| `treeview` | [APG Tree View](https://www.w3.org/WAI/ARIA/apg/patterns/treeview/) structure and keyboard model | TreeList rows: tree/treeitem/group, aria-expanded, level/position, one Tab stop, Up/Down, Right/Left (RTL-mirrored), Home/End, Enter or Space, typeahead |-| `carousel` | [APG Carousel](https://www.w3.org/WAI/ARIA/apg/patterns/carousel/) and WCAG 2.2 semantics | Carousel container, slides, scroll area, and stable navigation-control focus |-| `alertdialog` | [APG Alert Dialog](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/) role, references, modality, focus, dismissal | AlertDialog: alertdialog role and name, aria-describedby to the message, modal, Cancel first (advisory), Escape closes, click beside inert (advisory); modal mechanics stay with the modal-dialog contract through Dialog |-| `grid` | [APG Grid](https://www.w3.org/WAI/ARIA/apg/patterns/grid/) role, structure, name, selection and data-grid keys | Calendar month grids: grid role/name, row and gridcell/columnheader structure, one Tab stop, aria-selected/aria-multiselectable, arrows in reading order, Home/End, Enter selects (advisory) |-| `windowsplitter` | [APG Window Splitter](https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/) role, values, name, relationship and keys | ResizeHandle: separator role/name, now/min/max, orientation, aria-controls to the pane, arrows, Enter collapse/restore, Home/End, disabled keeps position |-| `link` | WCAG 2.2 semantics; [APG Link](https://www.w3.org/WAI/ARIA/apg/patterns/link/) role and Enter mechanics | Link, including LinkProvider and `as` router components |-| `table` | [APG Table](https://www.w3.org/WAI/ARIA/apg/patterns/table/) roles and name per AST-020 FR15; no keyboard (the pattern defines none); modules add theirs | Table, in data-driven and children mode: table role and name, `row`/`columnheader`/`rowheader`/`cell` roles inside the table; the sort module adds `aria-sort` on sorted headers only |+| Pattern | Adopted from | Bound by |+| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `radio-group` | [APG radio group](https://www.w3.org/WAI/ARIA/apg/patterns/radio/) | RadioList, SegmentedControl; role/state portions of DropdownMenu radio items |+| `checkbox` | [APG checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/) | CheckboxInput, CheckboxListItem, DropdownMenuCheckboxItem, SelectableCard |+| `switch` | [APG switch](https://www.w3.org/WAI/ARIA/apg/patterns/switch/) | Switch |+| `button` | [APG button](https://www.w3.org/WAI/ARIA/apg/patterns/button/) | Button, IconButton, ClickableCard, SideNavCollapseButton, ChatSendButton |+| `toggle-button` | Toggle-button semantics in the [APG button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/) | ToggleButton, including standalone and grouped states |+| `text-input` | Native HTML controls and [WAI-ARIA textbox](https://www.w3.org/TR/wai-aria-1.2/#textbox) | TextInput, TextArea |+| `modal-dialog` | [APG dialog (modal)](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/) | Dialog |+| `status-message` | [WCAG 2.2 Status Messages](https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html) | Toast, FieldStatus, Spinner, ChatSystemMessage, ChatTypingIndicator, ProgressBar |+| `tabs` | [APG Tabs](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/) | Explicit `role="tablist"` TabList, Tab, and caller-authored tabpanels |+| `listbox` | [WAI-ARIA 1.2 Listbox](https://www.w3.org/TR/wai-aria-1.2/#listbox) and WCAG 2.2 semantics | Selector and MultiSelector popup listbox, group, and option parts |+| `spinbutton` | WCAG 2.2 semantics and [APG Spinbutton](https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/) | NumberInput |+| `disclosure` | [APG Disclosure](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/) | Standalone Collapsible triggers and their controlled content |+| `menu-button` | [APG Menu Button](https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/) required parts; the optional ArrowDown/ArrowUp opens Astryx ships are advisory | Anchored DropdownMenu and MoreMenu triggers: button role and name, `aria-haspopup="menu"`, `aria-expanded`, `aria-controls`, Enter/Space open on the first enabled item (advisory: ArrowDown on the first, ArrowUp on the last) |+| `menu` | [APG Menu and Menubar](https://www.w3.org/WAI/ARIA/apg/patterns/menubar/) menu; arrows (with wrap) and Home/End per AST-020 FR15; typeahead advisory | DropdownMenu pointer menu: named `menu`, item roles/names, `aria-checked`, `aria-disabled`, arrows with wrap, Home/End, Enter and Escape back to the trigger, Tab out (advisory: typeahead) |+| `toolbar` | [APG Toolbar](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/); arrows (with wrap) and Home/End per AST-020 FR15 | Toolbar: named `toolbar`, `aria-orientation`, controls inside it, one Tab stop entering on the first enabled control, next/previous arrows (RTL-mirrored, Down/Up when vertical) with wrap, Home/End |+| `tooltip` | [APG Tooltip](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/) role and relationship per AST-020 FR15; WCAG 1.4.13; three rows advisory | Tooltip, useTooltip: `tooltip` role, `aria-describedby` and computed description, focus shows it (focus stays), Escape dismisses, hover keeps it over trigger and tooltip (advisory: blur hides, hover shows, pointer leaving hides) |+| `accordion` | [APG Accordion](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) required parts | CollapsibleGroup headers: button role and name, expanded state, controlled panel, Enter/Space, single-expansion sibling collapse, page Tab order, no arrow-key movement (single-expansion collapse, grouped Tab order, no arrow movement are advisory until `component:CollapsibleGroup` AR4 is current) |+| `breadcrumb` | WCAG 2.2 semantics; [APG Breadcrumb](https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/) as context | Breadcrumbs landmarks, list trails, current-page state, and separators |+| `combobox` | WCAG 2.2 + [WAI-ARIA 1.2 Combobox](https://www.w3.org/TR/wai-aria-1.2/#combobox); APG as context | Selector trigger identity, state, popup, and active-descendant relationships |+| `landmark` | WCAG 2.2 semantics; [APG Landmark Regions](https://www.w3.org/WAI/ARIA/apg/patterns/landmarks/) as context | LayoutHeader, LayoutContent, LayoutFooter, and LayoutPanel caller-declared landmarks |+| `slider` | [APG Slider](https://www.w3.org/WAI/ARIA/apg/patterns/slider/) role, values, name, orientation and keys | Slider thumbs: role, name, now/min/max, value text, orientation, arrows (RTL-mirrored), Page, Home/End, disabled keeps value |+| `slider-multithumb` | [APG Slider (Multi-Thumb)](https://www.w3.org/WAI/ARIA/apg/patterns/slider-multithumb/) thumbs, dependent bounds and Tab order | Range Slider: two distinctly named thumbs, bounds that stop at the other thumb and follow its moves, End/Home stop at the other thumb, Tab lower to upper; each thumb also runs `slider` |+| `progressbar` | WCAG 2.2 4.1.2 and [WAI-ARIA 1.2 progressbar](https://www.w3.org/TR/wai-aria-1.2/#progressbar); no APG pattern exists | ProgressBar, Lab CircularProgress: progressbar role and name, now/min/max, indeterminate claims no value, value text, no focusable descendants (target marks sit beside the bar) |+| `treeview` | [APG Tree View](https://www.w3.org/WAI/ARIA/apg/patterns/treeview/) structure and keyboard model | TreeList rows: tree/treeitem/group, aria-expanded, level/position, one Tab stop, Up/Down, Right/Left (RTL-mirrored), Home/End, Enter or Space, typeahead |+| `carousel` | [APG Carousel](https://www.w3.org/WAI/ARIA/apg/patterns/carousel/) and WCAG 2.2 semantics | Carousel container, slides, scroll area, and stable navigation-control focus |+| `alertdialog` | [APG Alert Dialog](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/) role, references, modality, focus, dismissal | AlertDialog: alertdialog role and name, aria-describedby to the message, modal, Cancel first (advisory), Escape closes, click beside inert (advisory); modal mechanics stay with the modal-dialog contract through Dialog |+| `grid` | [APG Grid](https://www.w3.org/WAI/ARIA/apg/patterns/grid/) role, structure, name, selection and data-grid keys | Calendar month grids: grid role/name, row and gridcell/columnheader structure, one Tab stop, aria-selected/aria-multiselectable, arrows in reading order, Home/End, Enter selects (advisory) |+| `windowsplitter` | [APG Window Splitter](https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/) role, values, name, relationship and keys | ResizeHandle: separator role/name, now/min/max, orientation, aria-controls to the pane, arrows, Enter collapse/restore, Home/End, disabled keeps position |+| `link` | WCAG 2.2 semantics; [APG Link](https://www.w3.org/WAI/ARIA/apg/patterns/link/) role and Enter mechanics | Link, including LinkProvider and `as` router components |+| `table` | [APG Table](https://www.w3.org/WAI/ARIA/apg/patterns/table/) roles and name per AST-020 FR15; no keyboard (the pattern defines none); modules add theirs | Table, in data-driven and children mode: table role and name, `row`/`columnheader`/`rowheader`/`cell` roles inside the table; the sort module adds `aria-sort` on sorted headers only |The `progressbar` contract owns what one rendered progress indicator exposes ineach state: the progressbar role and the operation's name (never a meter or adiff --git a/internal/a11y-spec/src/index.ts b/internal/a11y-spec/src/index.tsindex 4e4449c6c9..82cb7c3afb 100644--- a/internal/a11y-spec/src/index.ts+++ b/internal/a11y-spec/src/index.ts@@ -147,6 +147,11 @@ export {} from './patterns/landmark';export {SLIDER_PATTERN, type SliderStateFacts} from './patterns/slider';+export {+ SLIDER_MULTITHUMB_PATTERN,+ UPPER_THUMB,+ type SliderMultithumbStateFacts,+} from './patterns/slider-multithumb';export {PROGRESSBAR_PATTERN,type ProgressbarStateFacts,diff --git a/internal/a11y-spec/src/patterns/slider-multithumb.chromium.spec.ts b/internal/a11y-spec/src/patterns/slider-multithumb.chromium.spec.tsnew file mode 100644index 0000000000..f8fd417de6--- /dev/null+++ b/internal/a11y-spec/src/patterns/slider-multithumb.chromium.spec.ts@@ -0,0 +1,98 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+// @pr-a11y scope ^(internal/a11y-spec/src/patterns/slider|internal/a11y-spec/src/harness|packages/core/src/Slider/|apps/storybook/stories/SliderA11y)++/**+ * @file slider-multithumb.chromium.spec.ts+ * @input SLIDER_MULTITHUMB_PATTERN and its fixtures in real Chromium (the fixture script implements the range keyboard model)+ * @output Proof that every expectation passes conforming fixtures and fails its mutation at the layers only a browser observes+ * @position Contract self-test, Chromium lane+ */++import {expect, test, type CDPSession, type Page} from '../playwright';+import {describeExpectation, requiredLayers} from '../contract';+import {checkAccessibilitySpec, type ExpectationResult} from '../check';+import {+ CHROMIUM_OBSERVES,+ createChromiumHarness,+ holdMotionStill,+} from '../harness/chromium';+import {SLIDER_MULTITHUMB_PATTERN, UPPER_THUMB} from './slider-multithumb';+import {+ SLIDER_MULTITHUMB_MUTATIONS,+ CONFORMING_FIXTURES,+ SUBJECT_SELECTOR,+ UPPER_SELECTOR,+ fixture,+ type SliderMultithumbFixture,+} from './slider-multithumb.fixtures';++function fixturePage(html: string): string {+ return `<!doctype html><html lang="en"><body>${html}</body></html>`;+}++async function results(+ page: Page,+ cdp: CDPSession,+ target: SliderMultithumbFixture,+ only?: readonly string[],+): Promise<readonly ExpectationResult[]> {+ const run = await checkAccessibilitySpec({+ spec: SLIDER_MULTITHUMB_PATTERN,+ binding: 'fixture',+ state: target.id,+ facts: target.facts,+ only,+ mount: async () => {+ await page.setContent(fixturePage(target.html));+ await holdMotionStill(page);+ return createChromiumHarness({+ page,+ cdp,+ subject: page.locator(SUBJECT_SELECTOR),+ related: {[UPPER_THUMB]: page.locator(UPPER_SELECTOR)},+ });+ },+ });+ return run.results;+}++test.describe('multi-thumb slider contract — conforming fixtures', () => {+ for (const id of CONFORMING_FIXTURES) {+ test(`${id}: every applicable expectation passes`, async ({page}) => {+ const cdp = await page.context().newCDPSession(page);+ const observed = await results(page, cdp, fixture(id));+ expect(+ observed+ .filter(+ result =>+ result.status !== 'pass' && result.status !== 'not-applicable',+ )+ .map(result => `${result.expectation}: ${result.detail ?? ''}`),+ ).toEqual([]);+ });+ }+});++test.describe('multi-thumb slider contract — deliberately violating fixtures', () => {+ for (const expectation of SLIDER_MULTITHUMB_PATTERN.expectations) {+ if (+ !requiredLayers(expectation).every(layer =>+ CHROMIUM_OBSERVES.includes(layer),+ )+ ) {+ continue;+ }+ for (const fixtureId of SLIDER_MULTITHUMB_MUTATIONS[expectation.id] ?? []) {+ test(`${describeExpectation(expectation)} — fails against ${fixtureId}`, async ({+ page,+ }) => {+ const cdp = await page.context().newCDPSession(page);+ const [result] = await results(page, cdp, fixture(fixtureId), [+ expectation.id,+ ]);+ expect(result?.status, result?.detail ?? 'no result').toBe('fail');+ expect(result?.detail ?? '').not.toBe('');+ });+ }+ }+});diff --git a/internal/a11y-spec/src/patterns/slider-multithumb.fixtures.ts b/internal/a11y-spec/src/patterns/slider-multithumb.fixtures.tsnew file mode 100644index 0000000000..cd79e2e552--- /dev/null+++ b/internal/a11y-spec/src/patterns/slider-multithumb.fixtures.ts@@ -0,0 +1,213 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file slider-multithumb.fixtures.ts+ * @input Plain HTML two-thumb sliders (one script implements the range keyboard model; the DOM lane never runs it), conforming and deliberately violating+ * @output SLIDER_MULTITHUMB_FIXTURES, the thumb selectors, and the expectation → violating-fixture map+ * @position Contract self-test data for slider-multithumb.jsdom.test.ts and slider-multithumb.chromium.spec.ts+ */++import type {SliderMultithumbStateFacts} from './slider-multithumb';++const SUBJECT_ATTRIBUTE = 'data-a11y-subject';+const UPPER_ATTRIBUTE = 'data-a11y-upper';+export const SUBJECT_SELECTOR = `[${SUBJECT_ATTRIBUTE}]`;+export const UPPER_SELECTOR = `[${UPPER_ATTRIBUTE}]`;++export interface SliderMultithumbFixture {+ readonly id: string;+ readonly summary: string;+ readonly facts: SliderMultithumbStateFacts;+ readonly html: string;+}++// Each key moves the focused thumb inside its own bounds, then the other+// thumb's bound follows the new value. The flags each break one outcome.+const SCRIPT = `<script>+(() => {+ const group = document.querySelector('[role="group"]');+ const lower = document.querySelector('[${SUBJECT_ATTRIBUTE}]');+ const upper = document.querySelector('[${UPPER_ATTRIBUTE}]');+ const num = (el, name) => Number(el.getAttribute(name));+ const step = Number(group.dataset.step), gap = Number(group.dataset.separation);+ const min = Number(group.dataset.min), max = Number(group.dataset.max);+ const follow = () => {+ if (window.__frozenBounds) return;+ lower.setAttribute('aria-valuemax', String(num(upper, 'aria-valuenow') - gap));+ upper.setAttribute('aria-valuemin', String(num(lower, 'aria-valuenow') + gap));+ };+ for (const thumb of [lower, upper]) {+ thumb.addEventListener('keydown', e => {+ if (thumb.getAttribute('aria-disabled') === 'true') return;+ const low = window.__crossing ? min : num(thumb, 'aria-valuemin');+ const high = window.__crossing ? max : num(thumb, 'aria-valuemax');+ const now = num(thumb, 'aria-valuenow');+ const targets = {ArrowUp: now + step, ArrowRight: now + step, ArrowDown: now - step, ArrowLeft: now - step, Home: low, End: high};+ if (!(e.key in targets)) return;+ e.preventDefault();+ thumb.setAttribute('aria-valuenow', String(Math.min(high, Math.max(low, targets[e.key]))));+ follow();+ if (window.__reorder && thumb === lower) group.prepend(upper);+ });+ }+})();+</script>`;++function range({+ min = 0,+ max = 100,+ step = 1,+ lower = 20,+ upper = 80,+ separation = 0,+ disabled = false,+ lowerLabel = 'Minimum price',+ upperLabel = 'Maximum price' as string | null,+ upperRole = 'slider',+ fullBounds = false,+ upperTabIndex = 0,+}: {+ min?: number;+ max?: number;+ step?: number;+ lower?: number;+ upper?: number;+ separation?: number;+ disabled?: boolean;+ lowerLabel?: string;+ upperLabel?: string | null;+ upperRole?: string;+ fullBounds?: boolean;+ upperTabIndex?: number;+} = {}): string {+ const lowerMax = fullBounds ? max : upper - separation;+ const upperMin = fullBounds ? min : lower + separation;+ const off = disabled ? ' aria-disabled="true"' : '';+ const box =+ 'style="display:inline-block;width:40px;height:40px;background:#888"';+ return `<button type="button">Before</button><div role="group" aria-label="Price" data-min="${min}" data-max="${max}" data-step="${step}" data-separation="${separation}"><div ${SUBJECT_ATTRIBUTE} role="slider" tabindex="0" aria-label="${lowerLabel}" aria-valuenow="${lower}" aria-valuemin="${min}" aria-valuemax="${lowerMax}"${off} ${box}></div><div ${UPPER_ATTRIBUTE} role="${upperRole}" tabindex="${upperTabIndex}"${upperLabel == null ? '' : ` aria-label="${upperLabel}"`} aria-valuenow="${upper}" aria-valuemin="${upperMin}" aria-valuemax="${max}"${off} ${box}></div></div><button type="button">After</button>${SCRIPT}`;+}++const facts = (+ overrides: Partial<SliderMultithumbStateFacts> = {},+): SliderMultithumbStateFacts => ({+ min: 0,+ max: 100,+ step: 1,+ lower: 20,+ upper: 80,+ separation: 0,+ operable: true,+ focusable: true,+ ...overrides,+});++const flag = (name: string, html: string) =>+ html.replace('<script>', `<script>window.${name} = true;</script><script>`);++export const SLIDER_MULTITHUMB_FIXTURES: readonly SliderMultithumbFixture[] = [+ {+ id: 'conforming-range',+ summary: 'two thumbs at 20 and 80 of 0–100 with no separation',+ facts: facts(),+ html: range(),+ },+ {+ id: 'conforming-separation',+ summary: 'two thumbs at 20 and 60 that keep 10 apart, with step 5',+ facts: facts({step: 5, upper: 60, separation: 10}),+ html: range({step: 5, upper: 60, separation: 10}),+ },+ {+ id: 'conforming-coincident',+ summary: 'two thumbs that share the value 50',+ facts: facts({lower: 50, upper: 50}),+ html: range({lower: 50, upper: 50}),+ },+ {+ id: 'conforming-disabled',+ summary: 'two unavailable thumbs that keep their place in the Tab order',+ facts: facts({operable: false}),+ html: range({disabled: true}),+ },+ {+ id: 'violating-same-name',+ summary: 'two thumbs that share one name',+ facts: facts(),+ html: range({lowerLabel: 'Price', upperLabel: 'Price'}),+ },+ {+ id: 'violating-upper-unnamed',+ summary: 'an upper thumb with no accessible name',+ facts: facts(),+ html: range({upperLabel: null}),+ },+ {+ id: 'violating-upper-role',+ summary: 'an upper thumb exposed as a progressbar',+ facts: facts(),+ html: range({upperRole: 'progressbar'}),+ },+ {+ id: 'violating-full-bounds',+ summary: 'two thumbs that each expose the whole track as their bounds',+ facts: facts(),+ html: range({fullBounds: true}),+ },+ {+ id: 'violating-frozen-bounds',+ summary: "two thumbs whose bounds never follow the other thumb's moves",+ facts: facts(),+ html: flag('__frozenBounds', range()),+ },+ {+ id: 'violating-crossing',+ summary: 'a lower thumb that End sends past the upper thumb',+ facts: facts(),+ html: flag('__crossing', range()),+ },+ {+ id: 'violating-tab-skips-upper',+ summary: 'an upper thumb that is not a Tab stop',+ facts: facts(),+ html: range({upperTabIndex: -1}),+ },+ {+ id: 'violating-reorder',+ summary: 'thumbs that swap DOM order once the lower thumb moves',+ facts: facts(),+ html: flag('__reorder', range()),+ },+];++export function fixture(id: string): SliderMultithumbFixture {+ const found = SLIDER_MULTITHUMB_FIXTURES.find(+ candidate => candidate.id === id,+ );+ if (found == null) {+ throw new Error(`unknown multi-thumb slider fixture "${id}"`);+ }+ return found;+}++export const CONFORMING_FIXTURES: readonly string[] =+ SLIDER_MULTITHUMB_FIXTURES.filter(candidate =>+ candidate.id.startsWith('conforming-'),+ ).map(candidate => candidate.id);++export const SLIDER_MULTITHUMB_MUTATIONS: Readonly<+ Record<string, readonly string[]>+> = {+ 'slider-multithumb.thumbs.distinct-names': [+ 'violating-same-name',+ 'violating-upper-unnamed',+ 'violating-upper-role',+ ],+ 'slider-multithumb.bounds.follow-other-thumb': ['violating-full-bounds'],+ 'slider-multithumb.bounds.update-on-change': ['violating-frozen-bounds'],+ 'slider-multithumb.keys.no-crossing': ['violating-crossing'],+ 'slider-multithumb.tab-order.constant': [+ 'violating-tab-skips-upper',+ 'violating-reorder',+ ],+};diff --git a/internal/a11y-spec/src/patterns/slider-multithumb.jsdom.test.ts b/internal/a11y-spec/src/patterns/slider-multithumb.jsdom.test.tsnew file mode 100644index 0000000000..de7cbe83ab--- /dev/null+++ b/internal/a11y-spec/src/patterns/slider-multithumb.jsdom.test.ts@@ -0,0 +1,157 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+/** @vitest-environment jsdom */++/**+ * @file slider-multithumb.jsdom.test.ts+ * @input SLIDER_MULTITHUMB_PATTERN and its conforming and violating fixtures+ * @output Proof that the contract is complete, that every DOM-layer expectation passes conforming fixtures and fails its mutation, and that jsdom reports browser layers as unrun+ * @position Contract self-test, jsdom lane+ */++import {afterEach, describe, expect, it} from 'vitest';+import {+ citeSource,+ describeExpectation,+ requiredLayers,+ unansweredDimensions,+} from '../contract';+import {checkAccessibilitySpec, type ExpectationResult} from '../check';+import {JSDOM_OBSERVES, createJsdomHarness} from '../harness/jsdom';+import {SLIDER_MULTITHUMB_PATTERN, UPPER_THUMB} from './slider-multithumb';+import {+ SLIDER_MULTITHUMB_MUTATIONS,+ CONFORMING_FIXTURES,+ SUBJECT_SELECTOR,+ UPPER_SELECTOR,+ fixture,+ type SliderMultithumbFixture,+} from './slider-multithumb.fixtures';++const observableHere = SLIDER_MULTITHUMB_PATTERN.expectations.filter(+ expectation =>+ requiredLayers(expectation).every(layer => JSDOM_OBSERVES.includes(layer)),+);++afterEach(() => document.body.replaceChildren());++async function resultsFor(target: SliderMultithumbFixture) {+ const container = document.createElement('div');+ document.body.append(container);+ const result = await checkAccessibilitySpec({+ spec: SLIDER_MULTITHUMB_PATTERN,+ binding: 'fixture',+ state: target.id,+ facts: target.facts,+ mount: async () => {+ container.innerHTML = target.html;+ const subject = container.querySelector(SUBJECT_SELECTOR);+ const upper = container.querySelector(UPPER_SELECTOR);+ if (subject == null || upper == null) {+ throw new Error(`fixture "${target.id}" is missing a thumb`);+ }+ return createJsdomHarness({subject, related: {[UPPER_THUMB]: upper}});+ },+ unmount: () => {+ container.innerHTML = '';+ },+ });+ return result.results;+}++function resultFor(+ results: readonly ExpectationResult[],+ id: string,+): ExpectationResult {+ const found = results.find(result => result.expectation === id);+ if (found == null) {+ throw new Error(`no result for ${id}`);+ }+ return found;+}++describe('multi-thumb slider contract — completeness', () => {+ it('answers every completeness dimension', () => {+ expect(unansweredDimensions(SLIDER_MULTITHUMB_PATTERN)).toEqual([]);+ });++ it('gives every expectation at least one deliberately violating fixture', () => {+ const missing = SLIDER_MULTITHUMB_PATTERN.expectations+ .filter(+ expectation =>+ (SLIDER_MULTITHUMB_MUTATIONS[expectation.id] ?? []).length === 0,+ )+ .map(expectation => expectation.id);+ expect(missing).toEqual([]);+ });++ it('has an expectation for every mutation it records', () => {+ const ids = new Set(+ SLIDER_MULTITHUMB_PATTERN.expectations.map(expectation => expectation.id),+ );+ expect(+ Object.keys(SLIDER_MULTITHUMB_MUTATIONS).filter(id => !ids.has(id)),+ ).toEqual([]);+ });++ it('names every fixture it records a mutation against', () => {+ for (const fixtures of Object.values(SLIDER_MULTITHUMB_MUTATIONS)) {+ for (const id of fixtures) {+ expect(() => fixture(id)).not.toThrow();+ }+ }+ });+});++describe('multi-thumb slider contract — the jsdom harness stays within its evidence boundary', () => {+ it('runs DOM expectations and reports browser expectations as unrun', async () => {+ const results = await resultsFor(fixture('conforming-range'));+ expect(results.some(result => result.status === 'pass')).toBe(true);+ const above = results.filter(result => result.status === 'unrun');+ expect(above.length).toBeGreaterThan(0);+ for (const result of above) {+ expect(+ (result.missingLayers ?? []).some(+ layer => layer === 'real-browser' || layer === 'accessibility-tree',+ ),+ ).toBe(true);+ }+ });+});++describe.each(observableHere.map(expectation => [expectation.id] as const))(+ '%s',+ id => {+ const expectation = SLIDER_MULTITHUMB_PATTERN.expectations.find(+ candidate => candidate.id === id,+ )!;++ it.each(CONFORMING_FIXTURES.map(name => [name] as const))(+ 'passes against %s (or does not apply to it)',+ async name => {+ const result = resultFor(await resultsFor(fixture(name)), id);+ expect(+ ['pass', 'not-applicable'],+ `${id} against ${name}: ${result.detail ?? ''}`,+ ).toContain(result.status);+ },+ );++ it.each(+ (SLIDER_MULTITHUMB_MUTATIONS[id] ?? []).map(name => [name] as const),+ )('fails against %s, which removes its outcome', async name => {+ const result = resultFor(await resultsFor(fixture(name)), id);+ expect(result.status, `${id} against ${name}`).toBe('fail');+ expect(result.detail ?? '').not.toBe('');+ });++ it('carries its id and primary source into every result description', async () => {+ const target = fixture(+ SLIDER_MULTITHUMB_MUTATIONS[id]?.[0] ?? CONFORMING_FIXTURES[0]!,+ );+ const result = resultFor(await resultsFor(target), id);+ expect(result.description).toContain(id);+ expect(result.description).toContain(citeSource(expectation.sources[0]));+ expect(describeExpectation(expectation)).toBe(result.description);+ });+ },+);diff --git a/internal/a11y-spec/src/patterns/slider-multithumb.ts b/internal/a11y-spec/src/patterns/slider-multithumb.tsnew file mode 100644index 0000000000..4b3de41d62--- /dev/null+++ b/internal/a11y-spec/src/patterns/slider-multithumb.ts@@ -0,0 +1,587 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file slider-multithumb.ts+ * @input WCAG 2.2 A/AA success criteria and the APG Slider (Multi-Thumb) pattern's thumb, dependent-bound, and Tab-order requirements+ * @output SLIDER_MULTITHUMB_PATTERN — the reusable contract a two-thumb slider binds to when it adopts the pattern (Slider range mode under component:Slider AR1, `spec:AST-020/FR15`)+ * @position Pattern contract; bound by Slider in range mode, next to SLIDER_PATTERN bound per thumb+ */++import {+ definePattern,+ type ApgRequirement,+ type AstryxRecord,+ type PatternContract,+ type WcagCriterion,+} from '../contract';+import type {Harness, Subject} from '../harness';++const APG_URL = 'https://www.w3.org/WAI/ARIA/apg/patterns/slider-multithumb/';+const UNDERSTANDING = 'https://www.w3.org/WAI/WCAG22/Understanding';++/** The binding's name for the thumb that sets the upper value. */+export const UPPER_THUMB = 'upper-thumb';++const WCAG_2_1_1: WcagCriterion = {+ standard: 'wcag',+ id: '2.1.1',+ name: 'Keyboard',+ level: 'A',+ url: `${UNDERSTANDING}/keyboard.html`,+};+const WCAG_2_4_3: WcagCriterion = {+ standard: 'wcag',+ id: '2.4.3',+ name: 'Focus Order',+ level: 'A',+ url: `${UNDERSTANDING}/focus-order.html`,+};+const WCAG_2_4_6: WcagCriterion = {+ standard: 'wcag',+ id: '2.4.6',+ name: 'Headings and Labels',+ level: 'AA',+ url: `${UNDERSTANDING}/headings-and-labels.html`,+};+const WCAG_4_1_2: WcagCriterion = {+ standard: 'wcag',+ id: '4.1.2',+ name: 'Name, Role, Value',+ level: 'A',+ url: `${UNDERSTANDING}/name-role-value.html`,+};++const apgReq = (requirement: string, anchor: string): ApgRequirement => ({+ standard: 'apg',+ pattern: 'slider-multithumb',+ requirement,+ url: `${APG_URL}#${anchor}`,+});+const A = 'wai-ariaroles,states,andproperties';+const K = 'keyboardinteraction';+const APG_ROLE = apgReq(+ 'Each element serving as a focusable slider thumb has role slider.',+ A,+);+const APG_NAME = apgReq(+ 'If a slider has a visible label, it is referenced by aria-labelledby on the slider element. Otherwise, the slider element has a label provided by aria-label.',+ A,+);+const APG_DEPENDENT_BOUNDS = apgReq(+ 'When the range (e.g. minimum and/or maximum value) of another slider is dependent on the current value of a slider, the values of aria-valuemin or aria-valuemax of the dependent sliders are updated when the value changes.',+ A,+);+const APG_TAB_ORDER = apgReq(+ 'Each thumb is in the page tab sequence and has the keyboard interactions described in the Slider Pattern. The tab order remains constant regardless of thumb value and visual position within the slider.',+ K,+);+const SLIDER_AR1: AstryxRecord = {+ standard: 'astryx',+ id: 'component:Slider',+ clause: 'AR1',+ url: 'https://github.com/meta/astryx/blob/daa239e981898df414257d2530732b8e32a4b446/docs/specs/components/Slider/Slider.spec.md#L167-L177',+ requirement:+ 'Slider adopts the APG Slider pattern, each thumb as one composite control: every thumb is `role="slider"` with an accessible name (a range names each thumb), `aria-valuemin`, `aria-valuemax`, `aria-valuenow` […]; every thumb is a Tab stop, enabled or disabled. […] In a range, a thumb never crosses the other past the minimum separation.',+};++/**+ * What a binding knows about one two-thumb slider. The subject is the lower+ * thumb; the binding names the upper thumb `UPPER_THUMB`. `separation` is the+ * smallest gap the thumbs keep, in value units.+ */+export interface SliderMultithumbStateFacts {+ readonly min: number;+ readonly max: number;+ readonly step: number;+ readonly lower: number;+ readonly upper: number;+ readonly separation: number;+ /** Whether the user is meant to be able to change the values. */+ readonly operable: boolean;+ /** Whether each thumb is meant to accept keyboard focus. */+ readonly focusable: boolean;+}++interface Thumbs {+ readonly lower: Subject;+ readonly upper: Subject;+}++async function thumbs(harness: Harness, subject: Subject): Promise<Thumbs> {+ return {lower: subject, upper: await harness.related(UPPER_THUMB)};+}++async function numericAttribute(+ thumb: Subject,+ which: string,+ name: string,+): Promise<number> {+ const raw = await thumb.attribute(name);+ const parsed = raw == null ? Number.NaN : Number(raw);+ if (!Number.isFinite(parsed)) {+ throw new Error(+ `the ${which} thumb's ${name} is ${raw ?? 'absent'}, not a number`,+ );+ }+ return parsed;+}++async function expectBounds(+ thumb: Subject,+ which: string,+ expected: {now: number; min: number; max: number},+ after: string,+): Promise<void> {+ const now = await numericAttribute(thumb, which, 'aria-valuenow');+ const min = await numericAttribute(thumb, which, 'aria-valuemin');+ const max = await numericAttribute(thumb, which, 'aria-valuemax');+ if (now !== expected.now || min !== expected.min || max !== expected.max) {+ throw new Error(+ `${after}, the ${which} thumb exposes now/min/max ${now}/${min}/${max}, not ${expected.now}/${expected.min}/${expected.max}`,+ );+ }+}++async function expectValue(+ thumb: Subject,+ which: string,+ expected: number,+ after: string,+): Promise<void> {+ const now = await numericAttribute(thumb, which, 'aria-valuenow');+ if (Math.abs(now - expected) > 1e-9) {+ throw new Error(+ `${after} left the ${which} thumb's aria-valuenow at ${now}, not ${expected}`,+ );+ }+}++async function focusOrFail(+ thumb: Subject,+ which: string,+ forWhat: string,+): Promise<void> {+ await thumb.focus();+ if (!(await thumb.isFocused())) {+ throw new Error(+ `the ${which} thumb did not take focus, so ${forWhat} never reaches it`,+ );+ }+}++const OPERABLE = {+ condition: 'the thumbs can be changed and focused',+ test: (facts: SliderMultithumbStateFacts) =>+ facts.operable && facts.focusable,+};++export const SLIDER_MULTITHUMB_PATTERN: PatternContract<SliderMultithumbStateFacts> =+ definePattern<SliderMultithumbStateFacts>({+ pattern: 'slider-multithumb',+ url: APG_URL,+ scope:+ "What two thumbs on one slider owe each other: a distinct name for each, bounds that follow the other thumb's value and update when it moves, no crossing past the separation, and a Tab order that never changes. Each thumb's own role, values and keys are SLIDER_PATTERN's.",+ expectations: [+ {+ id: 'slider-multithumb.thumbs.distinct-names',+ outcome:+ 'The browser exposes both thumbs as sliders with different names, so a user can tell the lower thumb from the upper one.',+ sources: [WCAG_4_1_2, WCAG_2_4_6, APG_ROLE, APG_NAME, SLIDER_AR1],+ covers: [+ '4.1.2-name-role-value',+ '2.4.6-headings-and-labels',+ 'apg-interaction',+ ],+ appliesWhen: {+ condition: 'the binding designates two slider thumbs',+ test: () => true,+ },+ evidenceLayer: 'accessibility-tree',+ enforcement: 'required',+ run: async ({harness, subject}) => {+ const {lower, upper} = await thumbs(harness, subject);+ const names: string[] = [];+ for (const [which, thumb] of [+ ['lower', lower],+ ['upper', upper],+ ] as const) {+ const {role, name} = await thumb.computed();+ if (role !== 'slider') {+ throw new Error(+ `the browser exposes the ${which} thumb as ${role == null ? 'no role' : `"${role}"`}, not as a slider`,+ );+ }+ if (!name || name.trim() === '') {+ throw new Error(+ `the browser computes no accessible name for the ${which} thumb`,+ );+ }+ names.push(name.trim());+ }+ if (names[0] === names[1]) {+ throw new Error(+ `both thumbs are named "${names[0]}", so a user cannot tell them apart`,+ );+ }+ },+ },+ {+ id: 'slider-multithumb.bounds.follow-other-thumb',+ outcome:+ "Each thumb's bounds stop at the other thumb, so a user hears how far that thumb can actually move.",+ sources: [WCAG_4_1_2, APG_DEPENDENT_BOUNDS, SLIDER_AR1],+ covers: ['4.1.2-name-role-value', 'apg-interaction'],+ appliesWhen: {+ condition: 'the binding designates two slider thumbs',+ test: () => true,+ },+ evidenceLayer: 'dom',+ enforcement: 'required',+ run: async ({harness, subject, facts}) => {+ const {lower, upper} = await thumbs(harness, subject);+ await expectBounds(+ lower,+ 'lower',+ {+ now: facts.lower,+ min: facts.min,+ max: facts.upper - facts.separation,+ },+ 'before any key',+ );+ await expectBounds(+ upper,+ 'upper',+ {+ now: facts.upper,+ min: facts.lower + facts.separation,+ max: facts.max,+ },+ 'before any key',+ );+ },+ },+ {+ id: 'slider-multithumb.bounds.update-on-change',+ outcome:+ "When one thumb moves, the other thumb's bound moves with it, so the range a user hears is never stale.",+ sources: [WCAG_4_1_2, APG_DEPENDENT_BOUNDS, SLIDER_AR1],+ covers: ['4.1.2-name-role-value', 'apg-interaction'],+ appliesWhen: {+ condition:+ 'the thumbs can be changed and focused, with room for one step each toward the other',+ test: facts =>+ OPERABLE.test(facts) &&+ facts.lower + 2 * facts.step + facts.separation <= facts.upper,+ },+ evidenceLayer: 'real-browser',+ alsoNeeds: ['dom'],+ enforcement: 'required',+ run: async ({harness, subject, facts}) => {+ const {lower, upper} = await thumbs(harness, subject);+ await focusOrFail(lower, 'lower', 'the arrow keys');+ await harness.press('ArrowUp');+ await expectBounds(+ upper,+ 'upper',+ {+ now: facts.upper,+ min: facts.lower + facts.step + facts.separation,+ max: facts.max,+ },+ 'after ArrowUp on the lower thumb',+ );+ await focusOrFail(upper, 'upper', 'the arrow keys');+ await harness.press('ArrowDown');+ await expectBounds(+ lower,+ 'lower',+ {+ now: facts.lower + facts.step,+ min: facts.min,+ max: facts.upper - facts.step - facts.separation,+ },+ 'after ArrowDown on the upper thumb',+ );+ },+ },+ {+ id: 'slider-multithumb.keys.no-crossing',+ outcome:+ 'End on the lower thumb and Home on the upper thumb stop at the other thumb, so a range never turns inside out.',+ sources: [SLIDER_AR1, WCAG_2_1_1, APG_DEPENDENT_BOUNDS],+ covers: ['2.1.1-keyboard', 'apg-interaction'],+ appliesWhen: OPERABLE,+ evidenceLayer: 'real-browser',+ alsoNeeds: ['dom'],+ enforcement: 'required',+ run: async ({harness, subject, facts}) => {+ const {lower, upper} = await thumbs(harness, subject);+ await focusOrFail(lower, 'lower', 'End');+ await harness.press('End');+ await expectValue(+ lower,+ 'lower',+ facts.upper - facts.separation,+ 'End on the lower thumb',+ );+ await expectValue(+ upper,+ 'upper',+ facts.upper,+ 'End on the lower thumb',+ );+ await harness.press('Home');+ await expectValue(+ lower,+ 'lower',+ facts.min,+ 'Home on the lower thumb',+ );+ await focusOrFail(upper, 'upper', 'Home');+ await harness.press('Home');+ await expectValue(+ upper,+ 'upper',+ facts.min + facts.separation,+ 'Home on the upper thumb',+ );+ await expectValue(+ lower,+ 'lower',+ facts.min,+ 'Home on the upper thumb',+ );+ },+ },+ {+ id: 'slider-multithumb.tab-order.constant',+ outcome:+ 'Tab goes from the lower thumb to the upper thumb, also after the lower thumb moves up to the upper one, so a keyboard user always meets the thumbs in the same order.',+ sources: [WCAG_2_4_3, APG_TAB_ORDER, SLIDER_AR1],+ covers: ['2.4.3-focus-order', 'apg-interaction'],+ appliesWhen: {+ condition: 'the thumbs can receive focus',+ test: facts => facts.focusable,+ },+ evidenceLayer: 'real-browser',+ enforcement: 'required',+ run: async ({harness, subject, facts}) => {+ const {lower, upper} = await thumbs(harness, subject);+ const tabFromLower = async (after: string) => {+ await focusOrFail(lower, 'lower', 'Tab');+ await harness.press('Tab');+ if (!(await upper.isFocused())) {+ throw new Error(+ `${after}, Tab from the lower thumb does not reach the upper thumb`,+ );+ }+ };+ await tabFromLower('before any key');+ if (facts.operable) {+ await focusOrFail(lower, 'lower', 'End');+ await harness.press('End');+ await tabFromLower(+ 'after End moves the lower thumb up to the upper one',+ );+ }+ },+ },+ ],+ exemptions: {+ '1.1.1-non-text-content': {+ owner: 'the binding component',+ verifiedBy:+ "the component's decorative-icon tests and the repository axe audit, `pnpm a11y:audit`",+ reason:+ 'This contract owns what the two thumbs owe each other. Tick marks and any icon the binding paints are binding composition.',+ },+ '1.3.1-info-and-relationships': {+ owner: 'the binding component and caller content',+ verifiedBy:+ "the component's range-group, label and description association tests",+ reason:+ "The group around the thumbs, its label, and any description or status text are the binding's relationships, proven by its own tests.",+ },+ '1.3.2-meaningful-sequence': {+ owner: 'the binding component and composing page',+ verifiedBy:+ "the component's DOM-order tests and page-level reading-order review",+ reason:+ 'Where the slider, its label and its values sit relative to surrounding content is composition.',+ },+ '1.3.5-identify-input-purpose': {+ owner: 'not applicable',+ verifiedBy: 'none needed',+ reason:+ 'A slider collects values, not information about the user that autofill could supply.',+ },+ '1.4.1-use-of-color': {+ owner: 'the binding component and theme',+ verifiedBy:+ "the component's filled-range, marks and disabled state tests plus rendered review",+ reason:+ 'The filled range between the thumbs and the disabled cues are paint results owned by the binding and theme.',+ },+ '1.4.3-contrast-minimum': {+ owner: 'the binding component and theme',+ verifiedBy: 'the repository axe audit plus rendered contrast review',+ reason:+ 'Label and mark text contrast is a paint outcome owned by the binding and theme.',+ },+ '1.4.11-non-text-contrast': {+ owner: 'the binding component and theme',+ verifiedBy:+ 'the repository axe audit plus rendered review of the thumbs, track and focus indicator',+ reason:+ 'Thumb, track and focus indicator contrast are paint outcomes owned by the binding and theme.',+ },+ '2.1.1-keyboard': {+ owner: 'SLIDER_PATTERN, bound per thumb, and the composing page',+ verifiedBy:+ "the binding's SLIDER_PATTERN run over each thumb and page-level keyboard review",+ reason:+ "This contract encodes only the keys' effect across thumbs. Each thumb's arrow, Page, Home and End keys are SLIDER_PATTERN's; reaching the slider is the page's.",+ coversRemainderOnly: true,+ },+ '2.1.2-no-keyboard-trap': {+ owner: 'the binding component and composing page',+ verifiedBy: "the component's Tab tests and page-level keyboard review",+ reason:+ 'Two thumbs add no focus trap; Tab entry into and exit from the slider are generic focus behavior.',+ },+ '2.4.2-page-titled': {+ owner: 'the page',+ verifiedBy: 'page-level review',+ reason: 'A slider rendered in isolation owns no document title.',+ },+ '2.4.3-focus-order': {+ owner: 'the composing page',+ verifiedBy: 'page-level focus-order review',+ reason:+ "This contract proves the order of the two thumbs. The slider's place among surrounding controls depends on composition.",+ coversRemainderOnly: true,+ },+ '2.4.4-link-purpose': {+ owner: 'not applicable',+ verifiedBy: 'none needed',+ reason: 'A slider renders no link.',+ },+ '2.4.6-headings-and-labels': {+ owner: 'the binding component and caller content',+ verifiedBy: "the component's name tests and caller content review",+ reason:+ 'This contract proves the thumbs have different names; whether the label they compose with is descriptive is caller content.',+ coversRemainderOnly: true,+ },+ '2.4.7-focus-visible': {+ owner: 'the binding component and theme',+ verifiedBy:+ "the component's focus-outline tests and rendered focus review",+ reason:+ "The focused thumb's indicator is a paint result owned by the binding and theme.",+ },+ '2.4.11-focus-not-obscured': {+ owner: 'the binding component and composing page',+ verifiedBy:+ "the component's coincident-thumb pointer tests and page-level layout review",+ reason:+ 'Whether another surface covers the focused thumb depends on composition; two coincident thumbs drawn over each other are the binding geometry.',+ },+ '2.5.2-pointer-cancellation': {+ owner: 'the binding component',+ verifiedBy: "the component's pointer drag and release tests",+ reason:+ "Which thumb a press takes and how a drag ends are the binding's pointer model, outside this keyboard and semantics contract.",+ },+ '2.5.3-label-in-name': {+ owner: 'the binding component',+ verifiedBy: "the component's accessible-name tests",+ reason:+ "Whether each thumb's name contains the visible label it composes with is the binding's naming requirement.",+ },+ '2.5.8-target-size': {+ owner: 'the binding component and theme',+ verifiedBy:+ "the repository axe audit's target-size rule and the component's touch-target tests",+ reason:+ "The thumbs' hit areas, including how they share the gap between them, are geometry owned by the binding and theme.",+ },+ '3.1.1-language-of-page': {+ owner: 'the page',+ verifiedBy: 'page-level review',+ reason: 'A slider owns no document language.',+ },+ '3.2.2-on-input': {+ owner: 'the caller and composing page',+ verifiedBy: 'integration review of what a caller does with onChange',+ reason:+ "Changing the range is the slider's own purpose; any context change a caller makes on change is the caller's action.",+ },+ '3.2.4-consistent-identification': {+ owner: 'the composing page',+ verifiedBy:+ 'this shared contract across bindings plus content review of repeated slider labels',+ reason:+ 'Consistency is a property of the full set of repeated functions, not one isolated slider.',+ },+ '3.3.1-error-identification': {+ owner: 'the binding component',+ verifiedBy:+ "the component's status tests (aria-invalid and the status text association)",+ reason:+ "An error status on a slider is the binding's status composition, outside this pattern.",+ },+ '3.3.2-labels-or-instructions': {+ owner: 'the binding component and caller content',+ verifiedBy: "the component's label and description tests",+ reason:+ "This contract proves the thumbs are named apart; help text and its association are the binding's.",+ },+ '4.1.2-name-role-value': {+ owner: 'SLIDER_PATTERN, bound per thumb, and the binding component',+ verifiedBy:+ "the binding's SLIDER_PATTERN run over each thumb and the component's range-group and status tests",+ reason:+ "This contract encodes the thumbs' roles, distinct names and dependent bounds. Each thumb's value text, orientation and disabled state are SLIDER_PATTERN's; the group and aria-invalid are the binding's.",+ coversRemainderOnly: true,+ },+ '4.1.3-status-messages': {+ owner:+ 'the caller and the assistive-technology verification record, spec:AST-009',+ verifiedBy:+ 'the status-message pattern and real-AT evidence under AST-009 when a change claims spoken or braille output',+ reason:+ 'A value change is not a status-message contract, and this pattern makes no announcement claim.',+ },+ 'apg-interaction': {+ owner: 'SLIDER_PATTERN and the binding component',+ verifiedBy:+ 'the binding running SLIDER_PATTERN over each thumb, under component:Slider AR1',+ reason:+ "APG gives each thumb the Slider pattern's own interaction, which SLIDER_PATTERN encodes. This contract encodes only what the multi-thumb pattern adds.",+ coversRemainderOnly: true,+ },+ 'forced-colors': {+ owner: 'the binding component and theme',+ verifiedBy:+ "the component's forced-colors tests plus rendered Windows High Contrast review",+ reason:+ 'Forced-colors output is a paint result owned by the binding and theme.',+ },+ 'reduced-motion': {+ owner: 'the binding component and theme',+ verifiedBy:+ "the component's reduced-motion source tests and rendered motion review",+ reason:+ 'Thumb and fill motion is binding-specific paint over time and is not part of slider semantics.',+ },+ 'at-facing-strings': {+ owner: 'the binding component and caller content',+ verifiedBy:+ 'the repository i18n catalog check and source review of the thumb names',+ reason:+ 'The contract introduces no string; the thumb names come from the binding catalog and the label from the caller.',+ },+ },+ });diff --git a/packages/core/src/Slider/Slider.test.tsx b/packages/core/src/Slider/Slider.test.tsxindex a0126f304c..ce3c26d20b 100644--- a/packages/core/src/Slider/Slider.test.tsx+++ b/packages/core/src/Slider/Slider.test.tsx@@ -209,53 +209,6 @@ describe('Slider', () => {expect(control).not.toContainElement(screen.getByText('50'));});- it('range mode sets correct aria values on both thumbs', () => {- render(- <Slider- label="Range"- value={[25, 75] as [number, number]}- min={0}- max={100}- />,- );- const sliders = screen.getAllByRole('slider');- expect(sliders[0]).toHaveAttribute('aria-valuenow', '25');- expect(sliders[1]).toHaveAttribute('aria-valuenow', '75');- // Per the APG multi-thumb pattern, each thumb's bounds are constrained by- // its sibling: the lower thumb can't exceed the upper thumb's value and- // the upper thumb can't go below the lower thumb's value.- expect(sliders[0]).toHaveAttribute('aria-valuemin', '0');- expect(sliders[0]).toHaveAttribute('aria-valuemax', '75');- expect(sliders[1]).toHaveAttribute('aria-valuemin', '25');- expect(sliders[1]).toHaveAttribute('aria-valuemax', '100');- });-- it('range thumb bounds update after moving a thumb', async () => {- const user = userEvent.setup();- function ControlledRange() {- const [value, setValue] = useState<[number, number]>([25, 75]);- return (- <Slider- label="Range"- value={value}- onChange={setValue}- min={0}- max={100}- />- );- }- render(<ControlledRange />);- const sliders = screen.getAllByRole('slider');- act(() => {- sliders[0].focus();- });- await user.keyboard('{ArrowRight}');- expect(sliders[0]).toHaveAttribute('aria-valuenow', '26');- // The upper thumb's floor tracks the lower thumb's new value.- expect(sliders[1]).toHaveAttribute('aria-valuemin', '26');- expect(sliders[0]).toHaveAttribute('aria-valuemax', '75');- });-it('range thumb bounds include the minStepsBetweenThumbs gap', () => {render(<Slider@@ -496,6 +449,39 @@ describe('Slider', () => {expect(handleChange).not.toHaveBeenCalled();});+ it('keeps both thumbs of a disabled range as Tab stops that hold their values', async () => {+ const user = userEvent.setup();+ const handleChange = vi.fn();+ render(+ <>+ <button type="button">Before</button>+ <Slider+ label="Price"+ value={[20, 80] as [number, number]}+ onChange={handleChange}+ isDisabled+ />+ </>,+ );+ const [lower, upper] = screen.getAllByRole('slider');+ for (const thumb of [lower, upper]) {+ expect(thumb).toHaveAttribute('aria-disabled', 'true');+ expect(thumb).toHaveAttribute('tabindex', '0');+ }+ act(() => {+ screen.getByRole('button', {name: 'Before'}).focus();+ });+ await user.tab();+ expect(lower).toHaveFocus();+ await user.keyboard('{End}');+ await user.tab();+ expect(upper).toHaveFocus();+ await user.keyboard('{Home}');+ expect(lower).toHaveAttribute('aria-valuenow', '20');+ expect(upper).toHaveAttribute('aria-valuenow', '80');+ expect(handleChange).not.toHaveBeenCalled();+ });+describe('caller handlers while disabled (spec:AST-085 FR2)', () => {// A disabled slider stays focusable (aria-disabled, not native disabled),// so the browser no longer blocks its events: the component withholdsdiff --git a/packages/core/src/Slider/__tests__/Slider.a11y.states.ts b/packages/core/src/Slider/__tests__/Slider.a11y.states.tsindex 797f0c2cb1..2e1e8dcffc 100644--- a/packages/core/src/Slider/__tests__/Slider.a11y.states.ts+++ b/packages/core/src/Slider/__tests__/Slider.a11y.states.ts@@ -93,9 +93,9 @@ export const SLIDER_BINDING_STATES = [export const SLIDER_EXCLUSIONS = [{id: 'range-thumb-separation',- owner: 'component:Slider AR1 and Slider.test.tsx',+ owner: 'the range Slider binding, SliderRange.a11y.*',reason:- "A range Slider renders two thumbs whose aria-valuemin/aria-valuemax narrow to the other thumb minus the minimum separation; that two-thumb coupling and the group semantics around them are the binding's own tests. This binding proves the single-thumb pattern each thumb follows.",+ 'A range Slider renders two thumbs whose aria-valuemin/aria-valuemax narrow to the other thumb minus the minimum separation. The range binding runs the multi-thumb pattern over the pair and this slider pattern over each thumb. This binding proves the single-thumb states.',},{id: 'pointer-drag-model',diff --git a/packages/core/src/Slider/__tests__/SliderRange.a11y.chromium.spec.ts b/packages/core/src/Slider/__tests__/SliderRange.a11y.chromium.spec.tsnew file mode 100644index 0000000000..966e1a2d48--- /dev/null+++ b/packages/core/src/Slider/__tests__/SliderRange.a11y.chromium.spec.ts@@ -0,0 +1,190 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+// @pr-a11y scope ^(internal/a11y-spec/src/patterns/slider|internal/a11y-spec/src/harness|packages/core/src/Slider/|apps/storybook/stories/SliderA11y)++/**+ * @file SliderRange.a11y.chromium.spec.ts+ * @input Built range Slider stories, SLIDER_MULTITHUMB_PATTERN, and SLIDER_PATTERN in real Chromium+ * @output Browser evidence for every multi-thumb expectation across the binding's states and for every slider expectation on each thumb, reconciled against the exact known failures+ * @position Chromium lane of the range Slider binding (component:Slider AR1)+ */++import {+ expect,+ test,+ type CDPSession,+ type Page,+} from '@astryxdesign/a11y-spec/playwright';+import {+ SLIDER_MULTITHUMB_PATTERN,+ SLIDER_PATTERN,+ UPPER_THUMB,+ blockingResults,+ checkAccessibilitySpec,+ formatFailures,+ neverExercised,+ summarize,+ unmatchedKnownFailures,+ type BindingResult,+ type PatternContract,+} from '@astryxdesign/a11y-spec';+import {+ createChromiumHarness,+ holdMotionStill,+} from '@astryxdesign/a11y-spec/chromium';+import {+ DEFAULT_STORYBOOK_DIR,+ serveStorybook,+ type StaticServer,+} from '@astryxdesign/a11y-spec/storybook';+import {SLIDER_RANGE_KNOWN_FAILURES} from './SliderRange.a11y.known-failures';+import {+ LOWER_THUMB_NAME,+ SLIDER_RANGE_BINDING_STATES,+ UPPER_THUMB_NAME,+ thumbFacts,+ type SliderRangeBindingState,+ type SliderRangeThumb,+} from './SliderRange.a11y.states';++const BINDING = 'Slider (range)';++let storybook: StaticServer;++test.beforeAll(async () => {+ storybook = await serveStorybook(+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,+ );+});++test.afterAll(async () => {+ await storybook?.close();+});++function storyUrl(storyId: string): string {+ return `${storybook.origin}/iframe.html?id=${storyId}&viewMode=story`;+}++async function mountState(page: Page, state: SliderRangeBindingState) {+ await page.goto(storyUrl(state.storyId), {waitUntil: 'load'});+ await holdMotionStill(page);+ const root = page.locator('#storybook-root');+ const thumb = (which: SliderRangeThumb) =>+ root.getByRole('slider', {+ name: which === 'lower' ? LOWER_THUMB_NAME : UPPER_THUMB_NAME,+ });+ await thumb('upper').waitFor({state: 'attached'});+ return thumb;+}++async function runPair(+ page: Page,+ cdp: CDPSession,+ state: SliderRangeBindingState,+): Promise<BindingResult> {+ return checkAccessibilitySpec({+ spec: SLIDER_MULTITHUMB_PATTERN,+ binding: BINDING,+ state: state.id,+ facts: state.facts,+ knownFailures: SLIDER_RANGE_KNOWN_FAILURES,+ mount: async () => {+ const thumb = await mountState(page, state);+ return createChromiumHarness({+ page,+ cdp,+ subject: thumb('lower'),+ related: {[UPPER_THUMB]: thumb('upper')},+ });+ },+ });+}++async function runThumb(+ page: Page,+ cdp: CDPSession,+ state: SliderRangeBindingState,+ which: SliderRangeThumb,+): Promise<BindingResult> {+ return checkAccessibilitySpec({+ spec: SLIDER_PATTERN,+ binding: BINDING,+ state: `${state.id}:${which}`,+ facts: thumbFacts(state, which),+ knownFailures: SLIDER_RANGE_KNOWN_FAILURES,+ mount: async () => {+ const thumb = await mountState(page, state);+ return createChromiumHarness({+ page,+ cdp,+ subject: thumb(which),+ related: {},+ });+ },+ });+}++const PER_THUMB_RUNS = SLIDER_RANGE_BINDING_STATES.filter(+ state => state.perThumb,+).flatMap(state =>+ (['lower', 'upper'] as const).map(which => [state, which] as const),+);++function expectClean<Facts>(+ spec: PatternContract<Facts>,+ result: BindingResult,+) {+ const report = summarize(spec, [result]);+ // Required rows block (AST-020 FR9); advisory rows and exact known+ // failures report.+ expect(formatFailures(blockingResults([result]))).toBe('');+ expect(report.unrunLayers).toEqual([]);+ expect(report.counts.unexpectedPass).toBe(0);+}++// Each run mounts a story once per expectation, so the coverage check runs+// as one serial part per state, sharing their results, then one check over+// all of them.+test.describe('every expectation is exercised by a range Slider state', () => {+ test.describe.configure({mode: 'serial'});+ const pairs: BindingResult[] = [];+ const thumbs: BindingResult[] = [];++ for (const state of SLIDER_RANGE_BINDING_STATES) {+ test(`runs ${state.id}`, async ({page}) => {+ const cdp = await page.context().newCDPSession(page);+ const pair = await runPair(page, cdp, state);+ expectClean(SLIDER_MULTITHUMB_PATTERN, pair);+ pairs.push(pair);+ if (!state.perThumb) {+ return;+ }+ for (const which of ['lower', 'upper'] as const) {+ const result = await runThumb(page, cdp, state, which);+ expectClean(SLIDER_PATTERN, result);+ thumbs.push(result);+ }+ });+ }++ test('no expectation is left unexercised', () => {+ // Every part ran in this worker; this test alone proves nothing.+ expect(pairs.map(result => result.state).sort()).toEqual(+ SLIDER_RANGE_BINDING_STATES.map(state => state.id).sort(),+ );+ expect(thumbs.map(result => result.state).sort()).toEqual(+ PER_THUMB_RUNS.map(([state, which]) => `${state.id}:${which}`).sort(),+ );+ expect(neverExercised(pairs)).toEqual([]);+ // No range state is disabled (the `disabled-range` exclusion); the+ // single-thumb binding exercises an unavailable thumb.+ expect(neverExercised(thumbs)).toEqual([+ 'slider.thumb.unavailable-keeps-value',+ ]);+ expect(+ unmatchedKnownFailures(SLIDER_RANGE_KNOWN_FAILURES, [+ ...pairs,+ ...thumbs,+ ]),+ ).toEqual([]);+ });+});diff --git a/packages/core/src/Slider/__tests__/SliderRange.a11y.known-failures.ts b/packages/core/src/Slider/__tests__/SliderRange.a11y.known-failures.tsnew file mode 100644index 0000000000..db2787ce76--- /dev/null+++ b/packages/core/src/Slider/__tests__/SliderRange.a11y.known-failures.ts@@ -0,0 +1,12 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file SliderRange.a11y.known-failures.ts+ * @input The exact contract failures the shipped range Slider produces today+ * @output SLIDER_RANGE_KNOWN_FAILURES — records both lanes reconcile against, so a fix shows up as an unexpected pass and any other failure stays a failure+ * @position Known-failure ledger for the range Slider binding (both patterns it runs)+ */++import type {KnownFailure} from '@astryxdesign/a11y-spec';++export const SLIDER_RANGE_KNOWN_FAILURES: ReadonlyArray<KnownFailure> = [];diff --git a/packages/core/src/Slider/__tests__/SliderRange.a11y.renders.tsx b/packages/core/src/Slider/__tests__/SliderRange.a11y.renders.tsxnew file mode 100644index 0000000000..d9e356fa98--- /dev/null+++ b/packages/core/src/Slider/__tests__/SliderRange.a11y.renders.tsx@@ -0,0 +1,47 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++/**+ * @file SliderRange.a11y.renders.tsx+ * @input One range Slider binding state+ * @output The React tree every lane renders for that state (the jsdom test directly, the story through Storybook)+ * @position Shared fixture for the range Slider binding+ */++import {useState, type ReactElement} from 'react';+import {Slider} from '../Slider';+import type {SliderRangeBindingState} from './SliderRange.a11y.states';++function BoundRangeSlider({state}: {state: SliderRangeBindingState}) {+ const [value, setValue] = useState<[number, number]>([+ state.facts.lower,+ state.facts.upper,+ ]);+ return (+ <Slider+ label={state.label}+ min={state.facts.min}+ max={state.facts.max}+ step={state.facts.step}+ value={value}+ onChange={setValue}+ minStepsBetweenThumbs={state.minStepsBetweenThumbs}+ orientation={state.orientation}+ isDisabled={!state.facts.operable}+ formatValue={+ state.formatValue === true ? current => `${current} percent` : undefined+ }+ />+ );+}++export function renderSliderRangeState(+ state: SliderRangeBindingState,+): ReactElement {+ return (+ <div dir={state.direction} style={{padding: 24, width: 320}}>+ <BoundRangeSlider state={state} />+ </div>+ );+}diff --git a/packages/core/src/Slider/__tests__/SliderRange.a11y.states.ts b/packages/core/src/Slider/__tests__/SliderRange.a11y.states.tsnew file mode 100644index 0000000000..bff7499a95--- /dev/null+++ b/packages/core/src/Slider/__tests__/SliderRange.a11y.states.ts@@ -0,0 +1,174 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file SliderRange.a11y.states.ts+ * @input Range Slider's representative two-thumb states and the facts SLIDER_MULTITHUMB_PATTERN and SLIDER_PATTERN read+ * @output SLIDER_RANGE_BINDING_STATES, the per-thumb facts derived from them, and the explicit ownership exclusions for this binding+ * @position Binding inventory shared by the jsdom test, the Chromium spec, and the story (component:Slider AR1)+ */++import type {+ SliderMultithumbStateFacts,+ SliderStateFacts,+} from '@astryxdesign/a11y-spec';++export interface SliderRangeBindingState {+ readonly id: string;+ readonly summary: string;+ readonly storyId: string;+ /** The group's visible label. */+ readonly label: string;+ readonly facts: SliderMultithumbStateFacts;+ /** `minStepsBetweenThumbs`; `facts.separation` is this times `facts.step`. */+ readonly minStepsBetweenThumbs: number;+ readonly orientation: 'horizontal' | 'vertical';+ readonly direction: 'ltr' | 'rtl';+ /**+ * Whether each thumb also runs SLIDER_PATTERN. It moves a thumb one step and+ * ten steps up and back, so a thumb needs that room below its upper bound.+ */+ readonly perThumb: boolean;+ /** Whether each thumb speaks its value as "<value> percent". */+ readonly formatValue?: boolean;+}++/** The names Slider gives a range's thumbs (`@astryx.slider.minimumThumb`, `maximumThumb`). */+export const LOWER_THUMB_NAME = 'Minimum value';+export const UPPER_THUMB_NAME = 'Maximum value';++function facts(+ overrides: Partial<SliderMultithumbStateFacts> = {},+): SliderMultithumbStateFacts {+ return {+ min: 0,+ max: 100,+ step: 1,+ lower: 20,+ upper: 80,+ separation: 0,+ operable: true,+ focusable: true,+ ...overrides,+ };+}++const story = (id: string) => `a11y-slider--${id}`;++export const SLIDER_RANGE_BINDING_STATES = [+ {+ id: 'range',+ summary: 'a horizontal range Slider at 20–80 of 0–100',+ storyId: story('range'),+ label: 'Price',+ facts: facts(),+ minStepsBetweenThumbs: 0,+ orientation: 'horizontal',+ direction: 'ltr',+ perThumb: true,+ },+ {+ id: 'range-separation',+ summary:+ 'a range Slider whose thumbs keep 10 steps apart: each bound stops 10 short of the other thumb',+ storyId: story('range-separation'),+ label: 'Price',+ facts: facts({upper: 60, separation: 10}),+ minStepsBetweenThumbs: 10,+ orientation: 'horizontal',+ direction: 'ltr',+ perThumb: true,+ },+ {+ id: 'range-coincident',+ summary:+ 'a range Slider whose thumbs share the value 50: neither key crosses the other thumb',+ storyId: story('range-coincident'),+ label: 'Price',+ facts: facts({lower: 50, upper: 50}),+ minStepsBetweenThumbs: 0,+ orientation: 'horizontal',+ direction: 'ltr',+ perThumb: false,+ },+ {+ id: 'range-rtl',+ summary:+ 'a horizontal range Slider on a right-to-left page: ArrowLeft must raise each thumb',+ storyId: story('range-rtl'),+ label: 'Price',+ facts: facts(),+ minStepsBetweenThumbs: 0,+ orientation: 'horizontal',+ direction: 'rtl',+ perThumb: true,+ },+ {+ id: 'range-vertical',+ summary: 'a vertical range Slider',+ storyId: story('range-vertical'),+ label: 'Temperature',+ facts: facts(),+ minStepsBetweenThumbs: 0,+ orientation: 'vertical',+ direction: 'ltr',+ perThumb: true,+ },+ {+ id: 'range-formatted',+ summary: 'a range Slider whose thumbs speak formatted values',+ storyId: story('range-formatted'),+ label: 'Discount',+ facts: facts(),+ minStepsBetweenThumbs: 0,+ orientation: 'horizontal',+ direction: 'ltr',+ perThumb: true,+ formatValue: true,+ },+] as const satisfies ReadonlyArray<SliderRangeBindingState>;++export type SliderRangeThumb = 'lower' | 'upper';++/** What SLIDER_PATTERN expects of one range thumb: its bounds stop at the other thumb. */+export function thumbFacts(+ state: SliderRangeBindingState,+ thumb: SliderRangeThumb,+): SliderStateFacts {+ const {min, max, step, lower, upper, separation, operable, focusable} =+ state.facts;+ const value = thumb === 'lower' ? lower : upper;+ return {+ min: thumb === 'lower' ? min : lower + separation,+ max: thumb === 'lower' ? upper - separation : max,+ step,+ value,+ orientation: state.orientation,+ rtl: state.direction === 'rtl',+ operable,+ focusable,+ valueText: state.formatValue === true ? `${value} percent` : null,+ largeStep: step * 10,+ };+}++export const SLIDER_RANGE_EXCLUSIONS = [+ {+ id: 'group-semantics',+ owner: 'component:Slider and Slider.test.tsx range-group suites',+ reason:+ 'The role="group" around the thumbs, its label, description and status association are the component\'s relationships; the multi-thumb contract exempts them to the binding, and Slider.test.tsx proves them.',+ },+ {+ id: 'disabled-range',+ owner:+ 'Slider.test.tsx "keeps both thumbs of a disabled range as Tab stops that hold their values"',+ reason:+ 'A disabled range is not a story state yet: its story trips the axe color-contrast rule on the group label, because the thumbs carry aria-disabled and the group does not. The multi-thumb outcomes a disabled range can still change are its Tab order and its held values, and that local test proves both thumbs stay Tab stops in order, carry aria-disabled, and keep their values under End and Home.',+ },+ {+ id: 'pointer-drag-model',+ owner: 'Slider.test.tsx pointer suites and the Chromium pointer evidence',+ reason:+ 'Which coincident thumb a press takes, how a drag hands over between thumbs, and how a released drag coasts are pointer behavior outside the keyboard-and-semantics patterns; the component suites prove them.',+ },+] as const;diff --git a/packages/core/src/Slider/__tests__/SliderRange.a11y.test.tsx b/packages/core/src/Slider/__tests__/SliderRange.a11y.test.tsxnew file mode 100644index 0000000000..ca8b5843aa--- /dev/null+++ b/packages/core/src/Slider/__tests__/SliderRange.a11y.test.tsx@@ -0,0 +1,159 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+/** @vitest-environment jsdom */++/**+ * @file SliderRange.a11y.test.tsx+ * @input SLIDER_MULTITHUMB_PATTERN bound to range Slider's representative states, and SLIDER_PATTERN bound to each of their thumbs+ * @output jsdom-lane proof of the DOM expectations and an honest "unrun" report for the browser layers+ * @position Binding test for component:Slider AR1 in range mode (the Chromium spec covers the rest)+ */++import {cleanup, render, screen} from '@testing-library/react';+import {describe, expect, it} from 'vitest';+import {+ SLIDER_MULTITHUMB_PATTERN,+ SLIDER_PATTERN,+ UPPER_THUMB,+ checkAccessibilitySpec,+ createJsdomHarness,+ expectAccessibilitySpec,+ summarize,+ type BindingResult,+} from '@astryxdesign/a11y-spec';+import {SLIDER_RANGE_KNOWN_FAILURES} from './SliderRange.a11y.known-failures';+import {renderSliderRangeState} from './SliderRange.a11y.renders';+import {+ LOWER_THUMB_NAME,+ SLIDER_RANGE_BINDING_STATES,+ SLIDER_RANGE_EXCLUSIONS,+ UPPER_THUMB_NAME,+ thumbFacts,+ type SliderRangeBindingState,+ type SliderRangeThumb,+} from './SliderRange.a11y.states';++const BINDING = 'Slider (range)';++function thumb(which: SliderRangeThumb): HTMLElement {+ return screen.getByRole('slider', {+ name: which === 'lower' ? LOWER_THUMB_NAME : UPPER_THUMB_NAME,+ });+}++const PER_THUMB_RUNS = SLIDER_RANGE_BINDING_STATES.filter(+ state => state.perThumb,+).flatMap(state =>+ (['lower', 'upper'] as const).map(which => [state, which] as const),+);++async function checkPair(+ state: SliderRangeBindingState,+): Promise<BindingResult> {+ return checkAccessibilitySpec({+ spec: SLIDER_MULTITHUMB_PATTERN,+ binding: BINDING,+ state: state.id,+ facts: state.facts,+ knownFailures: SLIDER_RANGE_KNOWN_FAILURES,+ mount: async () => {+ render(renderSliderRangeState(state));+ return createJsdomHarness({+ subject: thumb('lower'),+ related: {[UPPER_THUMB]: thumb('upper')},+ });+ },+ unmount: cleanup,+ });+}++describe('Slider (range) — multi-thumb slider pattern, jsdom lane', () => {+ it.each(+ SLIDER_RANGE_BINDING_STATES.map(+ state => [state.id, state.summary, state] as const,+ ),+ )('%s — %s', async (_id, _summary, state) => {+ await expectAccessibilitySpec({+ spec: SLIDER_MULTITHUMB_PATTERN,+ binding: BINDING,+ state: state.id,+ facts: state.facts,+ knownFailures: SLIDER_RANGE_KNOWN_FAILURES,+ render: () => {+ render(renderSliderRangeState(state));+ },+ subject: () => thumb('lower'),+ related: () => ({[UPPER_THUMB]: thumb('upper')}),+ cleanup,+ });+ });++ it('runs the DOM layer and reports the browser-owned outcomes as unrun', async () => {+ const results: BindingResult[] = [];+ for (const state of SLIDER_RANGE_BINDING_STATES) {+ results.push(await checkPair(state));+ }+ const report = summarize(SLIDER_MULTITHUMB_PATTERN, results);+ expect(report.counts.pass).toBeGreaterThan(0);+ expect(report.unrunLayers).toEqual(['accessibility-tree', 'real-browser']);+ expect(report.counts.unexpectedPass).toBe(0);+ });+});++describe('Slider (range) — slider pattern on each thumb, jsdom lane', () => {+ it.each(+ PER_THUMB_RUNS.map(+ ([state, which]) => [`${state.id}:${which}`, state, which] as const,+ ),+ )('%s', async (_id, state, which) => {+ await expectAccessibilitySpec({+ spec: SLIDER_PATTERN,+ binding: BINDING,+ state: `${state.id}:${which}`,+ facts: thumbFacts(state, which),+ knownFailures: SLIDER_RANGE_KNOWN_FAILURES,+ render: () => {+ render(renderSliderRangeState(state));+ },+ subject: () => thumb(which),+ related: () => ({}),+ cleanup,+ });+ });+});++describe('Slider (range) binding inventory', () => {+ it('gives every representative state a distinct checked-in story', () => {+ const stories = SLIDER_RANGE_BINDING_STATES.map(state => state.storyId);+ expect(new Set(stories).size).toBe(stories.length);+ });++ it('keeps group, disabled-range and pointer ownership explicit', () => {+ expect(SLIDER_RANGE_EXCLUSIONS.map(exclusion => exclusion.id)).toEqual([+ 'group-semantics',+ 'disabled-range',+ 'pointer-drag-model',+ ]);+ for (const exclusion of SLIDER_RANGE_EXCLUSIONS) {+ expect(exclusion.owner.length, exclusion.id).toBeGreaterThan(20);+ expect(exclusion.reason.length, exclusion.id).toBeGreaterThan(80);+ }+ });++ it('declares a separation that matches minStepsBetweenThumbs', () => {+ for (const state of SLIDER_RANGE_BINDING_STATES) {+ expect(state.facts.separation, state.id).toBe(+ state.minStepsBetweenThumbs * state.facts.step,+ );+ }+ });++ it('renders exactly two named thumbs for every state', () => {+ for (const state of SLIDER_RANGE_BINDING_STATES) {+ render(renderSliderRangeState(state));+ expect(screen.getAllByRole('slider'), state.id).toHaveLength(2);+ expect(thumb('lower'), state.id).toBeTruthy();+ expect(thumb('upper'), state.id).toBeTruthy();+ cleanup();+ }+ });+});