@orkestrel/test 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/src/browser/index.d.ts +61 -19
- package/dist/src/browser/index.js +80 -24
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.d.cts +1 -1
- package/dist/src/core/index.d.ts +1 -1
- package/dist/src/server/index.cjs +12 -12
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +20 -20
- package/dist/src/server/index.d.ts +20 -20
- package/dist/src/server/index.js +12 -12
- package/dist/src/server/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npm install -D @orkestrel/test
|
|
|
23
23
|
|
|
24
24
|
## Requirements
|
|
25
25
|
|
|
26
|
-
- Node.js >= 22.
|
|
26
|
+
- Node.js >= 22.18.0
|
|
27
27
|
- ESM and CommonJS
|
|
28
28
|
|
|
29
29
|
## Usage
|
|
@@ -92,7 +92,7 @@ a browser workspace renders that table in.
|
|
|
92
92
|
The server face adds `readInventory`, which reads a checkout into a map of root-relative path to
|
|
93
93
|
file text that a parity suite can assert against, and `createLoopback`, which binds a server the
|
|
94
94
|
test built to an ephemeral loopback port. Behind them sit the pure leaves the server face also
|
|
95
|
-
exports on its own: `readInventory` refuses
|
|
95
|
+
exports on its own: `readInventory` refuses a path outside the root with `resolveContained` and prunes with
|
|
96
96
|
`isExcluded`, while `createScratch` refuses one with `requireContained`, the throwing form, and
|
|
97
97
|
reads and compares its allocation with `readIdentity` and `matchesIdentity` before `destroy()`
|
|
98
98
|
removes anything. `createLink` and `removeTree` do the writing under it, and both decide on the
|
|
@@ -146,7 +146,7 @@ back for every key that is not integer-like.
|
|
|
146
146
|
|
|
147
147
|
`createScratch` and `readInventory` promise different things, and each boundary is worth stating up
|
|
148
148
|
front. `createScratch` allocates its own directory at POSIX mode `0700` — under the host temporary
|
|
149
|
-
directory, or under a `parent` you name — and refuses a path that lexically
|
|
149
|
+
directory, or under a `parent` you name — and refuses a path that lexically resolves outside it. The suite
|
|
150
150
|
gates that assertion on `supportsMode`, the shipped probe that reads whether permission bits
|
|
151
151
|
round-trip on this host, so it runs only where they do and claims nothing about a host that emulates
|
|
152
152
|
them. The mode keeps another uid out, and neither a sibling test worker nor the code under test is
|
|
@@ -162,8 +162,8 @@ reports `ctime` in its place, the first write moves it, and `destroy()` then rem
|
|
|
162
162
|
returns as if it had. `readInventory` walks a checkout you supply, usually one the test did not
|
|
163
163
|
create, so it throws on a symlinked root or named target, throws on a named target whose real path
|
|
164
164
|
leaves the root through a link in the middle, and skips a symlink met while walking. Neither is a
|
|
165
|
-
sandbox against
|
|
166
|
-
|
|
165
|
+
sandbox against untrusted filesystem content: those refusals stop accidental access outside the root, not a process
|
|
166
|
+
that can create hard links where the test process already writes.
|
|
167
167
|
|
|
168
168
|
The browser face is the journey layer: an accessible-name resolver with exact failure voices,
|
|
169
169
|
region and disclosure targeting, input and traversal verbs, perception readers, a WCAG contrast
|
|
@@ -611,7 +611,9 @@ export declare function collectScrollRegions(root: Element, axis?: 'inline' | 'b
|
|
|
611
611
|
* {@link containsNode}, so a control inside an open shadow root or a same-origin frame that `root`
|
|
612
612
|
* holds is in the region, and `start` may sit inside one. A `start` that sits outside the region,
|
|
613
613
|
* as the control immediately before it, is the walk's origin and never its end, so the first Tab into the
|
|
614
|
-
* region reaches its first stop.
|
|
614
|
+
* region reaches its first stop. A native segmented input contributes one stop while consecutive
|
|
615
|
+
* landings pass through its segments up to {@link FOCUS_SEGMENT_LIMIT} landings. A longer run or
|
|
616
|
+
* any other revisit ends the walk.
|
|
615
617
|
*
|
|
616
618
|
* @example
|
|
617
619
|
* ```ts
|
|
@@ -1352,8 +1354,11 @@ export declare function driveHold(resolve: () => HTMLElement, name: string): Pro
|
|
|
1352
1354
|
*
|
|
1353
1355
|
* @remarks
|
|
1354
1356
|
* This is the one loop every traversal verb shares, over {@link stepFocus}. A step counts only when
|
|
1355
|
-
* focus lands on an element
|
|
1356
|
-
*
|
|
1357
|
+
* focus lands on an element. Consecutive landings on the same native segmented input continue
|
|
1358
|
+
* through its segments up to {@link FOCUS_SEGMENT_LIMIT} landings and count that control once.
|
|
1359
|
+
* A longer run or any other revisit ends the traversal. Any different landing starts a separate run.
|
|
1360
|
+
* The press cap is {@link FOCUS_SEGMENT_LIMIT} times the {@link FOCUSABLE_SELECTOR} candidate count
|
|
1361
|
+
* plus ten, so a page of segmented inputs has a budget for their segments and picker indicators.
|
|
1357
1362
|
*
|
|
1358
1363
|
* @example
|
|
1359
1364
|
* ```ts
|
|
@@ -1543,6 +1548,16 @@ export declare function findKeyframes(name: string): CSSKeyframesRule | undefine
|
|
|
1543
1548
|
*/
|
|
1544
1549
|
export declare function findRule(selector: string): CSSStyleRule | undefined;
|
|
1545
1550
|
|
|
1551
|
+
/**
|
|
1552
|
+
* Bounds consecutive focus landings and the Tab presses budgeted per segmented input.
|
|
1553
|
+
*
|
|
1554
|
+
* @remarks
|
|
1555
|
+
* Chromium measured nine landings on a datetime-local input with step="0.001": year, month,
|
|
1556
|
+
* day, hour, minute, second, millisecond, and meridiem segments, plus the picker indicator.
|
|
1557
|
+
* The budget covers those landings with one spare press per input.
|
|
1558
|
+
*/
|
|
1559
|
+
export declare const FOCUS_SEGMENT_LIMIT = 10;
|
|
1560
|
+
|
|
1546
1561
|
/**
|
|
1547
1562
|
* Names what sequential keyboard navigation can reach, before disabled and unrendered elements go.
|
|
1548
1563
|
*
|
|
@@ -2071,7 +2086,7 @@ export declare interface MediaOptions {
|
|
|
2071
2086
|
* Puts one element into the document and hands it straight back.
|
|
2072
2087
|
*
|
|
2073
2088
|
* @param element - The element to attach.
|
|
2074
|
-
* @returns The same element,
|
|
2089
|
+
* @returns The same element, appended to `document.body`.
|
|
2075
2090
|
*
|
|
2076
2091
|
* @remarks
|
|
2077
2092
|
* What this buys is the composition, not the attachment: the `append` method returns `void`, and
|
|
@@ -2201,7 +2216,7 @@ export declare function parseColor(value: string): Color | undefined;
|
|
|
2201
2216
|
* property is named by letters, digits, `_`, and `-` after its `--`. A name the scope leaves
|
|
2202
2217
|
* undeclared is not carried, so its `var()` fallback still applies.
|
|
2203
2218
|
*
|
|
2204
|
-
* The scope element is never written. The probe is
|
|
2219
|
+
* The scope element is never written. The probe is freshly created, so it has no earlier style to start a
|
|
2205
2220
|
* transition from, and a transition running on the scope keeps running: `currentColor` reads the
|
|
2206
2221
|
* color the scope shows at that moment, and the scope's geometry and scroll position stay as they
|
|
2207
2222
|
* were. No attribute, style, or child of the scope changes, so a `MutationObserver` on it records
|
|
@@ -2968,7 +2983,7 @@ export declare function readProtocolNode(element: Element): Promise<number>;
|
|
|
2968
2983
|
* Each frame on the way up adds its border and its padding, which is where its content starts,
|
|
2969
2984
|
* scales the point by the ratio of its painted width to its layout width, and adds its own position,
|
|
2970
2985
|
* so a tester iframe the runner scales or offsets is accounted for, and so is an iframe the page
|
|
2971
|
-
* itself nests, bordered, padded, or neither. The reading is of the layout
|
|
2986
|
+
* itself nests, bordered, padded, or neither. The reading is of the layout at the call: a box that moves
|
|
2972
2987
|
* afterwards moves the point it names. An element in a document no frame holds reads its own client
|
|
2973
2988
|
* point. A disconnected element has no layout, and its window still names the tester frame, so it is
|
|
2974
2989
|
* refused rather than read as that frame's corner.
|
|
@@ -3010,7 +3025,7 @@ export declare function readRefusal(name: string): string | undefined;
|
|
|
3010
3025
|
* sentence rather than a boolean. This fixes the resolver, translates the `unknown` a `catch` binds
|
|
3011
3026
|
* into `string | undefined`, and rethrows anything that is not an `Error` — a value no resolver
|
|
3012
3027
|
* raises, and one a caller reading a message would otherwise lose. `undefined` is rethrown with the
|
|
3013
|
-
* rest: a resolver that returned and
|
|
3028
|
+
* rest: a resolver that returned and an untrusted getter that threw `undefined` are different findings,
|
|
3014
3029
|
* which is why the `catch` is this function's own rather than a captured thrown value.
|
|
3015
3030
|
*
|
|
3016
3031
|
* It resolves rather than acts, so a target it reports `undefined` for is one an acting verb
|
|
@@ -3038,7 +3053,7 @@ export declare function readRefusal(role: string, name: string): string | undefi
|
|
|
3038
3053
|
* @remarks
|
|
3039
3054
|
* This reads and never acts. Focus arrives through the published verbs — `traverseAccessible`,
|
|
3040
3055
|
* `userEvent.keyboard` from `vitest/browser`, a real click — and this measures what the browser
|
|
3041
|
-
* painted
|
|
3056
|
+
* painted after it landed. A control that is not matching `:focus-visible` when the call is made
|
|
3042
3057
|
* reports nothing, because no measurement taken then would be about focus.
|
|
3043
3058
|
*
|
|
3044
3059
|
* Some controls are two elements: one that takes the focus and one a reader can see. A hidden radio
|
|
@@ -3081,7 +3096,7 @@ export declare function readRing(control: Element, worn?: Element): number | und
|
|
|
3081
3096
|
* A declared `role` wins outright, and its first token is the answer when several are listed.
|
|
3082
3097
|
* Otherwise the element's own anatomy decides: an anchor is a link only while it holds an `href`,
|
|
3083
3098
|
* an `input` takes the role {@link FIELD_ROLES} gives its type, a `select` is a combobox until it
|
|
3084
|
-
* offers several rows at once, a `section` is a region only
|
|
3099
|
+
* offers several rows at once, a `section` is a region only after something names it, and a `th`
|
|
3085
3100
|
* heads whichever axis its `scope` names. Every other tag answers from {@link IMPLICIT_ROLES},
|
|
3086
3101
|
* whose membership is the contract for what this can answer at all.
|
|
3087
3102
|
*
|
|
@@ -3569,6 +3584,9 @@ export declare function resolveFileInput(name: string): HTMLInputElement;
|
|
|
3569
3584
|
*/
|
|
3570
3585
|
export declare function resolveRendered(first: string, second?: string): HTMLElement;
|
|
3571
3586
|
|
|
3587
|
+
/** Names the native input types whose editable segments share one focused element. */
|
|
3588
|
+
export declare const SEGMENTED_INPUT_TYPES: readonly string[];
|
|
3589
|
+
|
|
3572
3590
|
/**
|
|
3573
3591
|
* Carries files from outside the page over a rendered target named by role and accessible name.
|
|
3574
3592
|
*
|
|
@@ -3599,7 +3617,7 @@ export declare function sendFileDrag(type: 'dragEnter' | 'dragOver' | 'dragCance
|
|
|
3599
3617
|
*
|
|
3600
3618
|
* @param method - The protocol method name.
|
|
3601
3619
|
* @param params - The protocol parameters. Omit them for a command that takes none.
|
|
3602
|
-
* @returns A promise resolving to the browser's reply
|
|
3620
|
+
* @returns A promise resolving to the browser's reply after the command completes.
|
|
3603
3621
|
* @throws Thrown when the provider exposes no DevTools session, or the command fails.
|
|
3604
3622
|
*
|
|
3605
3623
|
* @remarks
|
|
@@ -3646,7 +3664,7 @@ export declare function sendTouch(type: 'touchStart' | 'touchMove' | 'touchEnd'
|
|
|
3646
3664
|
* A pointer left over a control paints that control's hover, and a transition still running paints
|
|
3647
3665
|
* a fill between two states, so neither is a state the interface rests in. An endless animation, a
|
|
3648
3666
|
* spinner or a placeholder shimmer, stands at a different phase in every frame unless it is held at
|
|
3649
|
-
* the same one, so each is paused at its first frame. Call the resume
|
|
3667
|
+
* the same one, so each is paused at its first frame. Call the resume after the frame is shot; a
|
|
3650
3668
|
* capture that throws still owes it, so call it from a `finally` block.
|
|
3651
3669
|
*
|
|
3652
3670
|
* The subject is the whole document, its root element included. The pointer parks through
|
|
@@ -3753,7 +3771,7 @@ export declare function stageMedia(options: MediaOptions): Promise<void>;
|
|
|
3753
3771
|
*
|
|
3754
3772
|
* @remarks
|
|
3755
3773
|
* This depends on the runner's own tester layout, and that dependency is contract rather than an
|
|
3756
|
-
* accident: `vitest@4.1.
|
|
3774
|
+
* accident: `vitest@4.1.12` lays its tester out inside a smaller page, fits it by scaling the pane
|
|
3757
3775
|
* the tester sits in, and clips whatever overflows that pane. Layout inside the tester is
|
|
3758
3776
|
* unaffected — the tester reports the viewport it was given and every breakpoint answers to it —
|
|
3759
3777
|
* but a screenshot is taken off the page the runner painted, so a frame shot through that scale is
|
|
@@ -3819,7 +3837,9 @@ export declare interface StateOptions extends WaitOptions {
|
|
|
3819
3837
|
* through the provider, reads the landing with {@link readActiveElement}, and leaves every decision
|
|
3820
3838
|
* to the caller: what counts as an end, a revisit, or a stop is the consumer's, because the two
|
|
3821
3839
|
* consumers disagree. The press is the next one only after the consumer asks for the next landing, so
|
|
3822
|
-
* a consumer that stops reading stops pressing.
|
|
3840
|
+
* a consumer that stops reading stops pressing. A native segmented input can yield the same element
|
|
3841
|
+
* for successive segment landings. This generator preserves each landing; its consumers count that
|
|
3842
|
+
* control once while continuing through its segments, and end a run beyond {@link FOCUS_SEGMENT_LIMIT}.
|
|
3823
3843
|
*
|
|
3824
3844
|
* @example
|
|
3825
3845
|
* ```ts
|
|
@@ -3853,6 +3873,20 @@ export declare interface StorageOptions {
|
|
|
3853
3873
|
readonly quota?: number;
|
|
3854
3874
|
}
|
|
3855
3875
|
|
|
3876
|
+
/**
|
|
3877
|
+
* Determines whether a native input exposes separately editable segments under one focused element.
|
|
3878
|
+
*
|
|
3879
|
+
* @param element - The element whose native input type is read in its own document's realm.
|
|
3880
|
+
* @returns True if the element is an input with a type in {@link SEGMENTED_INPUT_TYPES}, checked
|
|
3881
|
+
* against its own document's `HTMLInputElement`; false otherwise, including a document with no window.
|
|
3882
|
+
*
|
|
3883
|
+
* @example
|
|
3884
|
+
* ```ts
|
|
3885
|
+
* supportsSegmentedFocus(document.createElement('button')) // false
|
|
3886
|
+
* ```
|
|
3887
|
+
*/
|
|
3888
|
+
export declare function supportsSegmentedFocus(element: Element): boolean;
|
|
3889
|
+
|
|
3856
3890
|
/**
|
|
3857
3891
|
* Taps an element's centre with emulated touch after its box settles.
|
|
3858
3892
|
*
|
|
@@ -3887,7 +3921,9 @@ export declare function tapTouch(element: Element, options?: StabilityOptions):
|
|
|
3887
3921
|
* @throws When one complete traversal cannot reach the target.
|
|
3888
3922
|
*
|
|
3889
3923
|
* @remarks
|
|
3890
|
-
* The loop is {@link driveTraversal} over {@link resolveRendered}.
|
|
3924
|
+
* The loop is {@link driveTraversal} over {@link resolveRendered}. Consecutive landings inside a
|
|
3925
|
+
* native segmented input continue through its segments up to {@link FOCUS_SEGMENT_LIMIT} landings.
|
|
3926
|
+
* A longer run or any other revisit ends the traversal.
|
|
3891
3927
|
*
|
|
3892
3928
|
* @example
|
|
3893
3929
|
* ```ts
|
|
@@ -3965,7 +4001,7 @@ export declare function typeInput(element: HTMLInputElement | HTMLTextAreaElemen
|
|
|
3965
4001
|
*
|
|
3966
4002
|
* @param element - The element whose own animations and descendants' animations to wait on.
|
|
3967
4003
|
* @param options - The time bounds and the abort signal.
|
|
3968
|
-
* @returns A promise resolving
|
|
4004
|
+
* @returns A promise resolving after every finite animation has stopped running.
|
|
3969
4005
|
* @throws An `Error` when the element is not in a document, when a bound is invalid, or when an
|
|
3970
4006
|
* animation is still running at the budget; or the abort reason.
|
|
3971
4007
|
*
|
|
@@ -4100,8 +4136,8 @@ export declare function waitForState(role: string, name: string, state: string,
|
|
|
4100
4136
|
*
|
|
4101
4137
|
* @param stop - Accepts the destination. Omit it to census the remaining document.
|
|
4102
4138
|
* @returns Every element focus reached, in order and each once, the accepted stop last.
|
|
4103
|
-
* @throws Thrown when the walk
|
|
4104
|
-
*
|
|
4139
|
+
* @throws Thrown when the walk exceeds its press cap, a key press rejects, or focus lands in a
|
|
4140
|
+
* frame from another origin.
|
|
4105
4141
|
*
|
|
4106
4142
|
* @remarks
|
|
4107
4143
|
* The walk records the focused element and then presses Tab through {@link stepFocus}, so it reaches
|
|
@@ -4110,8 +4146,14 @@ export declare function waitForState(role: string, name: string, state: string,
|
|
|
4110
4146
|
* innermost focused element {@link readActiveElement} reads, so a control inside an open shadow root
|
|
4111
4147
|
* or a same-origin frame is a stop of its own, and its host or frame element is not. The walk ends
|
|
4112
4148
|
* with an empty list when only the body holds focus, and where focus revisits a stop or returns to
|
|
4113
|
-
* the body.
|
|
4114
|
-
*
|
|
4149
|
+
* the body. Consecutive landings on the same native segmented input continue through its segments
|
|
4150
|
+
* up to {@link FOCUS_SEGMENT_LIMIT} landings, including the initial focused element, and count that
|
|
4151
|
+
* control once. A longer run or any other revisit, including a repeated button in a focus trap,
|
|
4152
|
+
* ends the walk. Any different landing starts a separate run.
|
|
4153
|
+
* The press cap is {@link FOCUS_SEGMENT_LIMIT} times {@link countElements}, including
|
|
4154
|
+
* open shadow roots and same-origin frames. It applies no rule about which stop counts: the
|
|
4155
|
+
* predicate sees each one and decides, so a consumer that refuses a hidden stop throws from its own
|
|
4156
|
+
* predicate.
|
|
4115
4157
|
*
|
|
4116
4158
|
* A closed shadow root cannot be entered, so its host stands for everything inside it, and a frame
|
|
4117
4159
|
* from another origin is refused because its controls cannot be named.
|
|
@@ -7,7 +7,7 @@ import { isArray, isError, isNumber, isRecord, isString, resolveField } from "@o
|
|
|
7
7
|
*
|
|
8
8
|
* @param method - The protocol method name.
|
|
9
9
|
* @param params - The protocol parameters. Omit them for a command that takes none.
|
|
10
|
-
* @returns A promise resolving to the browser's reply
|
|
10
|
+
* @returns A promise resolving to the browser's reply after the command completes.
|
|
11
11
|
* @throws Thrown when the provider exposes no DevTools session, or the command fails.
|
|
12
12
|
*
|
|
13
13
|
* @remarks
|
|
@@ -75,7 +75,7 @@ function build(tag, options) {
|
|
|
75
75
|
* Puts one element into the document and hands it straight back.
|
|
76
76
|
*
|
|
77
77
|
* @param element - The element to attach.
|
|
78
|
-
* @returns The same element,
|
|
78
|
+
* @returns The same element, appended to `document.body`.
|
|
79
79
|
*
|
|
80
80
|
* @remarks
|
|
81
81
|
* What this buys is the composition, not the attachment: the `append` method returns `void`, and
|
|
@@ -209,6 +209,23 @@ var FIELD_ROLES = Object.freeze({
|
|
|
209
209
|
* the one list either one reads.
|
|
210
210
|
*/
|
|
211
211
|
var FOCUSABLE_SELECTOR = "a[href], area[href], button, input, select, summary, textarea, [tabindex]";
|
|
212
|
+
/** Names the native input types whose editable segments share one focused element. */
|
|
213
|
+
var SEGMENTED_INPUT_TYPES = Object.freeze([
|
|
214
|
+
"date",
|
|
215
|
+
"time",
|
|
216
|
+
"datetime-local",
|
|
217
|
+
"month",
|
|
218
|
+
"week"
|
|
219
|
+
]);
|
|
220
|
+
/**
|
|
221
|
+
* Bounds consecutive focus landings and the Tab presses budgeted per segmented input.
|
|
222
|
+
*
|
|
223
|
+
* @remarks
|
|
224
|
+
* Chromium measured nine landings on a datetime-local input with step="0.001": year, month,
|
|
225
|
+
* day, hour, minute, second, millisecond, and meridiem segments, plus the picker indicator.
|
|
226
|
+
* The budget covers those landings with one spare press per input.
|
|
227
|
+
*/
|
|
228
|
+
var FOCUS_SEGMENT_LIMIT = 10;
|
|
212
229
|
/**
|
|
213
230
|
* Names the role a `th` carries for the header axis its `scope` names.
|
|
214
231
|
*
|
|
@@ -578,7 +595,7 @@ function measureContent() {
|
|
|
578
595
|
*
|
|
579
596
|
* @remarks
|
|
580
597
|
* This depends on the runner's own tester layout, and that dependency is contract rather than an
|
|
581
|
-
* accident: `vitest@4.1.
|
|
598
|
+
* accident: `vitest@4.1.12` lays its tester out inside a smaller page, fits it by scaling the pane
|
|
582
599
|
* the tester sits in, and clips whatever overflows that pane. Layout inside the tester is
|
|
583
600
|
* unaffected — the tester reports the viewport it was given and every breakpoint answers to it —
|
|
584
601
|
* but a screenshot is taken off the page the runner painted, so a frame shot through that scale is
|
|
@@ -2079,7 +2096,7 @@ async function releasePointer() {
|
|
|
2079
2096
|
* Each frame on the way up adds its border and its padding, which is where its content starts,
|
|
2080
2097
|
* scales the point by the ratio of its painted width to its layout width, and adds its own position,
|
|
2081
2098
|
* so a tester iframe the runner scales or offsets is accounted for, and so is an iframe the page
|
|
2082
|
-
* itself nests, bordered, padded, or neither. The reading is of the layout
|
|
2099
|
+
* itself nests, bordered, padded, or neither. The reading is of the layout at the call: a box that moves
|
|
2083
2100
|
* afterwards moves the point it names. An element in a document no frame holds reads its own client
|
|
2084
2101
|
* point. A disconnected element has no layout, and its window still names the tester frame, so it is
|
|
2085
2102
|
* refused rather than read as that frame's corner.
|
|
@@ -2286,7 +2303,9 @@ async function pressKeys(keys) {
|
|
|
2286
2303
|
* @throws When one complete traversal cannot reach the target.
|
|
2287
2304
|
*
|
|
2288
2305
|
* @remarks
|
|
2289
|
-
* The loop is {@link driveTraversal} over {@link resolveRendered}.
|
|
2306
|
+
* The loop is {@link driveTraversal} over {@link resolveRendered}. Consecutive landings inside a
|
|
2307
|
+
* native segmented input continue through its segments up to {@link FOCUS_SEGMENT_LIMIT} landings.
|
|
2308
|
+
* A longer run or any other revisit ends the traversal.
|
|
2290
2309
|
*
|
|
2291
2310
|
* @example
|
|
2292
2311
|
* ```ts
|
|
@@ -2424,7 +2443,9 @@ function containsNode(root, node) {
|
|
|
2424
2443
|
* through the provider, reads the landing with {@link readActiveElement}, and leaves every decision
|
|
2425
2444
|
* to the caller: what counts as an end, a revisit, or a stop is the consumer's, because the two
|
|
2426
2445
|
* consumers disagree. The press is the next one only after the consumer asks for the next landing, so
|
|
2427
|
-
* a consumer that stops reading stops pressing.
|
|
2446
|
+
* a consumer that stops reading stops pressing. A native segmented input can yield the same element
|
|
2447
|
+
* for successive segment landings. This generator preserves each landing; its consumers count that
|
|
2448
|
+
* control once while continuing through its segments, and end a run beyond {@link FOCUS_SEGMENT_LIMIT}.
|
|
2428
2449
|
*
|
|
2429
2450
|
* @example
|
|
2430
2451
|
* ```ts
|
|
@@ -2440,6 +2461,22 @@ async function* stepFocus(limit) {
|
|
|
2440
2461
|
}
|
|
2441
2462
|
}
|
|
2442
2463
|
/**
|
|
2464
|
+
* Determines whether a native input exposes separately editable segments under one focused element.
|
|
2465
|
+
*
|
|
2466
|
+
* @param element - The element whose native input type is read in its own document's realm.
|
|
2467
|
+
* @returns True if the element is an input with a type in {@link SEGMENTED_INPUT_TYPES}, checked
|
|
2468
|
+
* against its own document's `HTMLInputElement`; false otherwise, including a document with no window.
|
|
2469
|
+
*
|
|
2470
|
+
* @example
|
|
2471
|
+
* ```ts
|
|
2472
|
+
* supportsSegmentedFocus(document.createElement('button')) // false
|
|
2473
|
+
* ```
|
|
2474
|
+
*/
|
|
2475
|
+
function supportsSegmentedFocus(element) {
|
|
2476
|
+
const realm = element.ownerDocument.defaultView;
|
|
2477
|
+
return realm !== null && element instanceof realm.HTMLInputElement && SEGMENTED_INPUT_TYPES.includes(element.type);
|
|
2478
|
+
}
|
|
2479
|
+
/**
|
|
2443
2480
|
* Reaches the control a resolver returns, only through natural forward Tab traversal from the
|
|
2444
2481
|
* current focus.
|
|
2445
2482
|
*
|
|
@@ -2451,8 +2488,11 @@ async function* stepFocus(limit) {
|
|
|
2451
2488
|
*
|
|
2452
2489
|
* @remarks
|
|
2453
2490
|
* This is the one loop every traversal verb shares, over {@link stepFocus}. A step counts only when
|
|
2454
|
-
* focus lands on an element
|
|
2455
|
-
*
|
|
2491
|
+
* focus lands on an element. Consecutive landings on the same native segmented input continue
|
|
2492
|
+
* through its segments up to {@link FOCUS_SEGMENT_LIMIT} landings and count that control once.
|
|
2493
|
+
* A longer run or any other revisit ends the traversal. Any different landing starts a separate run.
|
|
2494
|
+
* The press cap is {@link FOCUS_SEGMENT_LIMIT} times the {@link FOCUSABLE_SELECTOR} candidate count
|
|
2495
|
+
* plus ten, so a page of segmented inputs has a budget for their segments and picker indicators.
|
|
2456
2496
|
*
|
|
2457
2497
|
* @example
|
|
2458
2498
|
* ```ts
|
|
@@ -2461,10 +2501,12 @@ async function* stepFocus(limit) {
|
|
|
2461
2501
|
*/
|
|
2462
2502
|
async function driveTraversal(resolve, name) {
|
|
2463
2503
|
resolve();
|
|
2464
|
-
const cap = document.querySelectorAll(FOCUSABLE_SELECTOR).length *
|
|
2504
|
+
const cap = document.querySelectorAll(FOCUSABLE_SELECTOR).length * 10 + 10;
|
|
2465
2505
|
const visited = /* @__PURE__ */ new Set();
|
|
2466
|
-
const
|
|
2506
|
+
const landings = [];
|
|
2467
2507
|
for await (const focused of stepFocus(cap)) {
|
|
2508
|
+
const previous = landings.at(-1);
|
|
2509
|
+
landings.push(focused);
|
|
2468
2510
|
if (focused === void 0) continue;
|
|
2469
2511
|
try {
|
|
2470
2512
|
const current = resolve();
|
|
@@ -2472,10 +2514,11 @@ async function driveTraversal(resolve, name) {
|
|
|
2472
2514
|
} catch {
|
|
2473
2515
|
continue;
|
|
2474
2516
|
}
|
|
2517
|
+
if (focused === previous && supportsSegmentedFocus(focused) && landings.length - landings.findLastIndex((landing) => landing !== focused) - 1 <= 10) continue;
|
|
2475
2518
|
if (visited.has(focused)) break;
|
|
2476
2519
|
visited.add(focused);
|
|
2477
|
-
trail.push(`${focused.tagName}:${focused.innerText.slice(0, 20)}`);
|
|
2478
2520
|
}
|
|
2521
|
+
const trail = [...new Set(landings)].filter((focused) => focused !== void 0).filter((focused) => visited.has(focused)).map((focused) => `${focused.tagName}:${focused.innerText.slice(0, 20)}`);
|
|
2479
2522
|
throw new Error(`Interactive target "${name}" is not reachable through forward Tab traversal: ${trail.join(" > ")}`);
|
|
2480
2523
|
}
|
|
2481
2524
|
/**
|
|
@@ -2484,8 +2527,8 @@ async function driveTraversal(resolve, name) {
|
|
|
2484
2527
|
*
|
|
2485
2528
|
* @param stop - Accepts the destination. Omit it to census the remaining document.
|
|
2486
2529
|
* @returns Every element focus reached, in order and each once, the accepted stop last.
|
|
2487
|
-
* @throws Thrown when the walk
|
|
2488
|
-
*
|
|
2530
|
+
* @throws Thrown when the walk exceeds its press cap, a key press rejects, or focus lands in a
|
|
2531
|
+
* frame from another origin.
|
|
2489
2532
|
*
|
|
2490
2533
|
* @remarks
|
|
2491
2534
|
* The walk records the focused element and then presses Tab through {@link stepFocus}, so it reaches
|
|
@@ -2494,8 +2537,14 @@ async function driveTraversal(resolve, name) {
|
|
|
2494
2537
|
* innermost focused element {@link readActiveElement} reads, so a control inside an open shadow root
|
|
2495
2538
|
* or a same-origin frame is a stop of its own, and its host or frame element is not. The walk ends
|
|
2496
2539
|
* with an empty list when only the body holds focus, and where focus revisits a stop or returns to
|
|
2497
|
-
* the body.
|
|
2498
|
-
*
|
|
2540
|
+
* the body. Consecutive landings on the same native segmented input continue through its segments
|
|
2541
|
+
* up to {@link FOCUS_SEGMENT_LIMIT} landings, including the initial focused element, and count that
|
|
2542
|
+
* control once. A longer run or any other revisit, including a repeated button in a focus trap,
|
|
2543
|
+
* ends the walk. Any different landing starts a separate run.
|
|
2544
|
+
* The press cap is {@link FOCUS_SEGMENT_LIMIT} times {@link countElements}, including
|
|
2545
|
+
* open shadow roots and same-origin frames. It applies no rule about which stop counts: the
|
|
2546
|
+
* predicate sees each one and decides, so a consumer that refuses a hidden stop throws from its own
|
|
2547
|
+
* predicate.
|
|
2499
2548
|
*
|
|
2500
2549
|
* A closed shadow root cannot be entered, so its host stands for everything inside it, and a frame
|
|
2501
2550
|
* from another origin is refused because its controls cannot be named.
|
|
@@ -2509,9 +2558,14 @@ async function walkFocus(stop) {
|
|
|
2509
2558
|
const first = readActiveElement();
|
|
2510
2559
|
if (first === void 0) return [];
|
|
2511
2560
|
const reached = [first];
|
|
2561
|
+
const landings = [first];
|
|
2512
2562
|
if (stop?.(first) === true) return reached;
|
|
2513
|
-
for await (const focused of stepFocus(countElements())) {
|
|
2514
|
-
if (focused === void 0
|
|
2563
|
+
for await (const focused of stepFocus(countElements() * 10)) {
|
|
2564
|
+
if (focused === void 0) return reached;
|
|
2565
|
+
const previous = landings.at(-1);
|
|
2566
|
+
landings.push(focused);
|
|
2567
|
+
if (focused === previous && supportsSegmentedFocus(focused) && landings.length - landings.findLastIndex((landing) => landing !== focused) - 1 <= 10) continue;
|
|
2568
|
+
if (reached.includes(focused)) return reached;
|
|
2515
2569
|
reached.push(focused);
|
|
2516
2570
|
if (stop?.(focused) === true) return reached;
|
|
2517
2571
|
}
|
|
@@ -2533,7 +2587,9 @@ async function walkFocus(stop) {
|
|
|
2533
2587
|
* {@link containsNode}, so a control inside an open shadow root or a same-origin frame that `root`
|
|
2534
2588
|
* holds is in the region, and `start` may sit inside one. A `start` that sits outside the region,
|
|
2535
2589
|
* as the control immediately before it, is the walk's origin and never its end, so the first Tab into the
|
|
2536
|
-
* region reaches its first stop.
|
|
2590
|
+
* region reaches its first stop. A native segmented input contributes one stop while consecutive
|
|
2591
|
+
* landings pass through its segments up to {@link FOCUS_SEGMENT_LIMIT} landings. A longer run or
|
|
2592
|
+
* any other revisit ends the walk.
|
|
2537
2593
|
*
|
|
2538
2594
|
* @example
|
|
2539
2595
|
* ```ts
|
|
@@ -2703,7 +2759,7 @@ function readText(element) {
|
|
|
2703
2759
|
* A declared `role` wins outright, and its first token is the answer when several are listed.
|
|
2704
2760
|
* Otherwise the element's own anatomy decides: an anchor is a link only while it holds an `href`,
|
|
2705
2761
|
* an `input` takes the role {@link FIELD_ROLES} gives its type, a `select` is a combobox until it
|
|
2706
|
-
* offers several rows at once, a `section` is a region only
|
|
2762
|
+
* offers several rows at once, a `section` is a region only after something names it, and a `th`
|
|
2707
2763
|
* heads whichever axis its `scope` names. Every other tag answers from {@link IMPLICIT_ROLES},
|
|
2708
2764
|
* whose membership is the contract for what this can answer at all.
|
|
2709
2765
|
*
|
|
@@ -2940,7 +2996,7 @@ async function waitForState(first, second, third, fourth) {
|
|
|
2940
2996
|
*
|
|
2941
2997
|
* @param element - The element whose own animations and descendants' animations to wait on.
|
|
2942
2998
|
* @param options - The time bounds and the abort signal.
|
|
2943
|
-
* @returns A promise resolving
|
|
2999
|
+
* @returns A promise resolving after every finite animation has stopped running.
|
|
2944
3000
|
* @throws An `Error` when the element is not in a document, when a bound is invalid, or when an
|
|
2945
3001
|
* animation is still running at the budget; or the abort reason.
|
|
2946
3002
|
*
|
|
@@ -3053,7 +3109,7 @@ function readAnimations(element) {
|
|
|
3053
3109
|
* A pointer left over a control paints that control's hover, and a transition still running paints
|
|
3054
3110
|
* a fill between two states, so neither is a state the interface rests in. An endless animation, a
|
|
3055
3111
|
* spinner or a placeholder shimmer, stands at a different phase in every frame unless it is held at
|
|
3056
|
-
* the same one, so each is paused at its first frame. Call the resume
|
|
3112
|
+
* the same one, so each is paused at its first frame. Call the resume after the frame is shot; a
|
|
3057
3113
|
* capture that throws still owes it, so call it from a `finally` block.
|
|
3058
3114
|
*
|
|
3059
3115
|
* The subject is the whole document, its root element included. The pointer parks through
|
|
@@ -4183,7 +4239,7 @@ function parseColor(value) {
|
|
|
4183
4239
|
* property is named by letters, digits, `_`, and `-` after its `--`. A name the scope leaves
|
|
4184
4240
|
* undeclared is not carried, so its `var()` fallback still applies.
|
|
4185
4241
|
*
|
|
4186
|
-
* The scope element is never written. The probe is
|
|
4242
|
+
* The scope element is never written. The probe is freshly created, so it has no earlier style to start a
|
|
4187
4243
|
* transition from, and a transition running on the scope keeps running: `currentColor` reads the
|
|
4188
4244
|
* color the scope shows at that moment, and the scope's geometry and scroll position stay as they
|
|
4189
4245
|
* were. No attribute, style, or child of the scope changes, so a `MutationObserver` on it records
|
|
@@ -4519,7 +4575,7 @@ function readContrast(element, floor) {
|
|
|
4519
4575
|
* @remarks
|
|
4520
4576
|
* This reads and never acts. Focus arrives through the published verbs — `traverseAccessible`,
|
|
4521
4577
|
* `userEvent.keyboard` from `vitest/browser`, a real click — and this measures what the browser
|
|
4522
|
-
* painted
|
|
4578
|
+
* painted after it landed. A control that is not matching `:focus-visible` when the call is made
|
|
4523
4579
|
* reports nothing, because no measurement taken then would be about focus.
|
|
4524
4580
|
*
|
|
4525
4581
|
* Some controls are two elements: one that takes the focus and one a reader can see. A hidden radio
|
|
@@ -5066,6 +5122,6 @@ function buildCensus() {
|
|
|
5066
5122
|
});
|
|
5067
5123
|
}
|
|
5068
5124
|
//#endregion
|
|
5069
|
-
export { ACCESSIBLE_ROLES, CANVAS_COLOR, CAPTURE_PANE, CAPTURE_STAGINGS, CONTENT_ROLES, FIELD_ROLES, FOCUSABLE_SELECTOR, HEADER_ROLES, IMPLICIT_ROLES, MEDIA_STAGE, POINTER_HOLD, adoptSheet, blendColor, build, buildCensus, buildContrast, buildDenial, buildEscapes, captureFrame, chooseAccessible, clearStorage, clickAccessible, clickAccessibleWithin, clickDisclosure, clipsOverflow, collectClippingAncestors, collectScrollRegions, collectTabStops, commitInput, computeNamePattern, computeOffset, containsNode, convertA98RGB, convertDisplayP3, convertLab, convertLinearSRGB, convertOKLab, convertProPhotoRGB, convertRec2020, convertSRGB, convertXYZD50, convertXYZD65, countElements, createChannel, createDragEvent, createHarness, createJournal, createKeyboardEvent, createPointerEvent, createPortfolio, createStorage, describeFocus, describeScrollRegions, describeTree, driveHold, driveTraversal, expandCaptures, extractOrphans, extractStyles, fillAccessible, findKeyframes, findRule, holdAccessible, holdAccessibleWithin, hoverAccessible, isOutsideViewport, isReachable, isRendered, matchesColor, measureContent, measureContrast, measureLuminance, mount, paintImage, parkPointer, parseCSSColor, parseColor, pressKeys, readAccessibilityNode, readActiveElement, readAnimations, readBackdrop, readCascade, readCensus, readClasses, readClipEdge, readClipMargin, readClippedBlock, readColorContrast, readContrast, readFocus, readFrame, readHit, readLayerNames, readLayers, readName, readPage, readPerception, readPixels, readProtocolNode, readProtocolPoint, readRefusal, readRing, readRole, readRootToken, readRows, readRules, readShotPixel, readStates, readStyle, readText, readToken, readValue, releaseMedia, releasePane, releasePointer, releaseTouch, removeDatabase, render, resolveAccessible, resolveAccessibleWithin, resolveFileInput, resolveRendered, sendFileDrag, sendProtocol, sendTouch, settleCapture, stageMedia, stagePane, stepFocus, tapTouch, traverseAccessible, traverseAccessibleWithin, typeAccessible, typeInput, waitForAnimations, waitForFrame, waitForStability, waitForState, walkFocus };
|
|
5125
|
+
export { ACCESSIBLE_ROLES, CANVAS_COLOR, CAPTURE_PANE, CAPTURE_STAGINGS, CONTENT_ROLES, FIELD_ROLES, FOCUSABLE_SELECTOR, FOCUS_SEGMENT_LIMIT, HEADER_ROLES, IMPLICIT_ROLES, MEDIA_STAGE, POINTER_HOLD, SEGMENTED_INPUT_TYPES, adoptSheet, blendColor, build, buildCensus, buildContrast, buildDenial, buildEscapes, captureFrame, chooseAccessible, clearStorage, clickAccessible, clickAccessibleWithin, clickDisclosure, clipsOverflow, collectClippingAncestors, collectScrollRegions, collectTabStops, commitInput, computeNamePattern, computeOffset, containsNode, convertA98RGB, convertDisplayP3, convertLab, convertLinearSRGB, convertOKLab, convertProPhotoRGB, convertRec2020, convertSRGB, convertXYZD50, convertXYZD65, countElements, createChannel, createDragEvent, createHarness, createJournal, createKeyboardEvent, createPointerEvent, createPortfolio, createStorage, describeFocus, describeScrollRegions, describeTree, driveHold, driveTraversal, expandCaptures, extractOrphans, extractStyles, fillAccessible, findKeyframes, findRule, holdAccessible, holdAccessibleWithin, hoverAccessible, isOutsideViewport, isReachable, isRendered, matchesColor, measureContent, measureContrast, measureLuminance, mount, paintImage, parkPointer, parseCSSColor, parseColor, pressKeys, readAccessibilityNode, readActiveElement, readAnimations, readBackdrop, readCascade, readCensus, readClasses, readClipEdge, readClipMargin, readClippedBlock, readColorContrast, readContrast, readFocus, readFrame, readHit, readLayerNames, readLayers, readName, readPage, readPerception, readPixels, readProtocolNode, readProtocolPoint, readRefusal, readRing, readRole, readRootToken, readRows, readRules, readShotPixel, readStates, readStyle, readText, readToken, readValue, releaseMedia, releasePane, releasePointer, releaseTouch, removeDatabase, render, resolveAccessible, resolveAccessibleWithin, resolveFileInput, resolveRendered, sendFileDrag, sendProtocol, sendTouch, settleCapture, stageMedia, stagePane, stepFocus, supportsSegmentedFocus, tapTouch, traverseAccessible, traverseAccessibleWithin, typeAccessible, typeInput, waitForAnimations, waitForFrame, waitForStability, waitForState, walkFocus };
|
|
5070
5126
|
|
|
5071
5127
|
//# sourceMappingURL=index.js.map
|