@orkestrel/test 0.0.29 → 0.0.30

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.
@@ -332,7 +332,7 @@ var CAPTURE_PANE = "data-capture-pane";
332
332
  * one restaging past the cap before it comes back down to the edge. Nothing measured needs a
333
333
  * fourth, so a fourth is the headroom that keeps a settling document off the refusal.
334
334
  */
335
- var CAPTURE_STAGINGS = 4;
335
+ var CAPTURE_STAGE_LIMIT = 4;
336
336
  /**
337
337
  * Names the tester root's attribute holding the media readings observed before the first stage.
338
338
  *
@@ -604,6 +604,8 @@ function measureContent() {
604
604
  * selector and the `--tester-transform`, `--tester-margin-left`, `--viewport-width`, and
605
605
  * `--viewport-height` custom properties are the runner's, so a Vitest release that renames any of
606
606
  * them reddens the size check that follows rather than writing a wrong frame.
607
+ * The custom-property overrides serve Vitest 4; `transform: none !important` on the pane and
608
+ * iframe also suppresses Vitest 5's direct CSS transform.
607
609
  *
608
610
  * Hand the pane straight back with {@link releasePane}. A tester pinned at a viewport taller than
609
611
  * the window puts its lower half beyond what a pointer can reach, so an ordinary press then fails
@@ -621,7 +623,8 @@ function measureContent() {
621
623
  * the shot replaces the node and takes any attribute of ours with it.
622
624
  *
623
625
  * The wait is two frames rather than a delay: the first carries the resize into layout and the
624
- * second is the paint a screenshot reads.
626
+ * second is the paint a screenshot reads. An already matching viewport needs no resize command;
627
+ * the staging rule, paint waits, and rendered-size check still run.
625
628
  *
626
629
  * The viewport the tester had before this staging is written onto that rule element as the
627
630
  * {@link CAPTURE_PANE} value, in `<width>x<height>` form, and {@link releasePane} hands it back.
@@ -635,7 +638,7 @@ function measureContent() {
635
638
  */
636
639
  async function stagePane(width, height) {
637
640
  const viewport = `${String(window.innerWidth)}x${String(window.innerHeight)}`;
638
- await page.viewport(width, height);
641
+ if (window.innerWidth !== width || window.innerHeight !== height) await page.viewport(width, height);
639
642
  const frame = window.frameElement;
640
643
  const pane = frame?.parentElement;
641
644
  const owner = pane?.ownerDocument;
@@ -646,9 +649,9 @@ async function stagePane(width, height) {
646
649
  rule.setAttribute(CAPTURE_PANE, viewport);
647
650
  rule.textContent = [
648
651
  `[${CAPTURE_PANE}],:has(>iframe[data-vitest])`,
649
- "{--tester-transform:none !important;--tester-margin-left:0px !important}",
652
+ "{--tester-transform:none !important;--tester-margin-left:0px !important;transform:none !important}",
650
653
  "iframe[data-vitest]",
651
- "{position:fixed !important;left:0 !important;top:0 !important;right:auto !important;",
654
+ "{transform:none !important;position:fixed !important;left:0 !important;top:0 !important;right:auto !important;",
652
655
  "bottom:auto !important;width:var(--viewport-width) !important;",
653
656
  "height:var(--viewport-height) !important;z-index:2147483647 !important}"
654
657
  ].join("");
@@ -674,7 +677,9 @@ async function stagePane(width, height) {
674
677
  * otherwise read the last capture's variant. The size comes off the {@link CAPTURE_PANE} value
675
678
  * {@link stagePane} wrote onto the rule element, which is the reading taken before the first
676
679
  * staging. Calling this on an unstaged pane finds no such value, so it changes nothing and resizes
677
- * nothing.
680
+ * nothing. A staged pane sends its saved size even when the tester already holds it, because the
681
+ * runner refits its frame scale only on a viewport request; a release that skipped it would leave
682
+ * the next case shooting through the staged scale.
678
683
  *
679
684
  * That hand-back is what makes {@link stagePane} and this pair a capture's staging rather than a
680
685
  * resize: the pair puts the tester back where it found it, so a suite that used it to reach a
@@ -868,12 +873,12 @@ async function stageMedia(options) {
868
873
  async function waitForStability(description, read, options) {
869
874
  const frames = options?.frames ?? 4;
870
875
  if (!Number.isInteger(frames) || frames < 1) throw new Error("Stability frames must be a positive integer");
871
- const readings = [read()];
876
+ const samples = [read()];
872
877
  await waitForCondition(description, async () => {
873
878
  await waitForFrame();
874
- readings.push(read());
875
- const tail = readings.slice(-(frames + 1));
876
- return tail.length > frames && tail.every((reading) => reading === tail[0]);
879
+ samples.push(read());
880
+ const tail = samples.slice(-(frames + 1));
881
+ return tail.length > frames && tail.every((sample) => sample === tail[0]);
877
882
  }, options);
878
883
  }
879
884
  /**
@@ -912,33 +917,33 @@ async function releaseMedia() {
912
917
  ];
913
918
  const staged = document.documentElement.getAttribute(MEDIA_STAGE);
914
919
  if (staged !== null) {
915
- const readings = staged.split("").map((value) => value === "1");
920
+ const matches = staged.split("").map((value) => value === "1");
916
921
  if (staged.length === 5) queries.push("(pointer: coarse)");
917
922
  await sendProtocol("Emulation.setEmulatedMedia", {
918
- media: readings[0] ? "print" : "screen",
923
+ media: matches[0] ? "print" : "screen",
919
924
  features: [
920
925
  {
921
926
  name: "prefers-reduced-motion",
922
- value: readings[1] ? "reduce" : "no-preference"
927
+ value: matches[1] ? "reduce" : "no-preference"
923
928
  },
924
929
  {
925
930
  name: "prefers-color-scheme",
926
- value: readings[2] ? "dark" : "light"
931
+ value: matches[2] ? "dark" : "light"
927
932
  },
928
933
  {
929
934
  name: "forced-colors",
930
- value: readings[3] ? "active" : "none"
935
+ value: matches[3] ? "active" : "none"
931
936
  }
932
937
  ]
933
938
  });
934
939
  if (staged.length === 5) await sendProtocol("Emulation.setTouchEmulationEnabled", {
935
- enabled: readings[4],
940
+ enabled: matches[4],
936
941
  maxTouchPoints: 1
937
942
  });
938
943
  try {
939
944
  await Promise.all(queries.map((query, index) => waitForCondition(query, async () => {
940
945
  await waitForFrame();
941
- return matchMedia(query).matches === readings[index];
946
+ return matchMedia(query).matches === matches[index];
942
947
  })));
943
948
  } catch (cause) {
944
949
  throw new Error("Media emulation did not clear from the tester", { cause });
@@ -962,14 +967,17 @@ async function releaseMedia() {
962
967
  * @param options - The path to write, the viewport to shoot at, and the element to shoot.
963
968
  * @returns The absolute path of the written frame, after it has been read back and matched.
964
969
  * @throws Thrown when the pane cannot be staged, when the document's height or an element frame's
965
- * element height never settles under {@link CAPTURE_STAGINGS} restagings, when the provider wrote
970
+ * element height never settles under {@link CAPTURE_STAGE_LIMIT} restagings, when the provider wrote
966
971
  * the frame somewhere else, and when the bytes on disk are not the ones this shot produced.
967
972
  *
968
973
  * @remarks
969
974
  * The path a screenshot call returns is the path it meant to write, so it is not evidence a file
970
- * exists. The file is read back through the runner's built-in `readFile` command and compared with
971
- * the shot itself, which is what separates a frame this run wrote from one an earlier run left
972
- * behind. The provider resolves `options.path` against the calling test file and returns an absolute
975
+ * exists. The {@link verifyFrame} helper compares the file with the shot itself. When the page
976
+ * registered a `readCapture` command, {@link readCaptureReader} returns it and the comparison uses
977
+ * SHA-256 digests computed in Node for the file and in the browser for the returned bytes. Otherwise
978
+ * the runner's built-in `readFile` command supplies the base64 comparison. A command failure
979
+ * propagates without falling back. The provider resolves `options.path`
980
+ * against the calling test file and returns an absolute
973
981
  * path, so the two are compared by the segments that survive resolving `.` and `..` lexically — the
974
982
  * refusal is what a provider resolving that path against a different base would trip.
975
983
  *
@@ -979,6 +987,8 @@ async function releaseMedia() {
979
987
  * than the document — a frame that reads as the surface down to the fold and as bare canvas after
980
988
  * it. The document is therefore laid out at the declared viewport first and, where it is taller
981
989
  * than that, the pane is staged again at the height the document needs, for the shot alone.
990
+ * Where the tester already has the declared viewport, the reading precedes the initial staging,
991
+ * so fixed content stages at its final height directly. Every staged height is still read again.
982
992
  *
983
993
  * That height is {@link measureContent}, never less than `options.height`, because the declared
984
994
  * viewport is the smallest frame a variant asks for. The reading is the content's own edge rather
@@ -1001,7 +1011,7 @@ async function releaseMedia() {
1001
1011
  *
1002
1012
  * The re-reading stops when the pane and the edge agree, which is the pane the shot is taken at. A
1003
1013
  * rule that adds height with every pane never reaches that point, so the re-reading is bounded by
1004
- * {@link CAPTURE_STAGINGS} and the shot is refused with
1014
+ * {@link CAPTURE_STAGE_LIMIT} and the shot is refused with
1005
1015
  * `Capture frame at <path> never settled after <n> restagings: <h> over a <h> pane` rather than
1006
1016
  * written at a height that is already wrong.
1007
1017
  *
@@ -1054,12 +1064,13 @@ async function captureFrame(options) {
1054
1064
  left: window.scrollX,
1055
1065
  top: window.scrollY
1056
1066
  };
1067
+ const prepared = window.innerWidth === options.width && window.innerHeight === options.height;
1057
1068
  try {
1058
- await stagePane(options.width, options.height);
1069
+ if (!prepared) await stagePane(options.width, options.height);
1059
1070
  let pane = options.height;
1060
1071
  let covered;
1061
1072
  let growth = 0;
1062
- for (let staging = 0;; staging += 1) {
1073
+ for (let stage = 0;; stage += 1) {
1063
1074
  let height = element?.getBoundingClientRect().height;
1064
1075
  if (element !== void 0 && height !== void 0 && height > options.height) {
1065
1076
  element.scrollIntoView({
@@ -1117,11 +1128,17 @@ async function captureFrame(options) {
1117
1128
  }
1118
1129
  }
1119
1130
  }
1120
- const reading = Math.max(height === void 0 ? measureContent() : Math.ceil(height), options.height);
1121
- if (covered !== void 0) growth = Math.max(0, reading - covered);
1122
- covered = reading;
1123
- if (pane === covered) break;
1124
- if (staging === 4) throw new Error(`Capture frame at ${options.path} never settled after ${String(4)} restagings: ${String(covered)} over a ${String(pane)} pane`);
1131
+ const extent = Math.max(height === void 0 ? measureContent() : Math.ceil(height), options.height);
1132
+ if (covered !== void 0) growth = Math.max(0, extent - covered);
1133
+ covered = extent;
1134
+ if (pane === covered) {
1135
+ if (prepared && stage === 0) {
1136
+ await stagePane(options.width, pane);
1137
+ continue;
1138
+ }
1139
+ break;
1140
+ }
1141
+ if (stage === 4) throw new Error(`Capture frame at ${options.path} never settled after ${String(4)} restagings: ${String(covered)} over a ${String(pane)} pane`);
1125
1142
  pane = covered + growth;
1126
1143
  await stagePane(options.width, pane);
1127
1144
  }
@@ -1164,14 +1181,7 @@ async function captureFrame(options) {
1164
1181
  else if (offset && style !== null) frame.setAttribute("style", style);
1165
1182
  }
1166
1183
  }
1167
- const segments = [];
1168
- for (const segment of options.path.replaceAll("\\", "/").split("/")) {
1169
- if (segment === "" || segment === ".") continue;
1170
- if (segment === "..") segments.pop();
1171
- else segments.push(segment);
1172
- }
1173
- if (!shot.path.replaceAll("\\", "/").endsWith(segments.join("/"))) throw new Error(`Capture frame was written to ${shot.path} where ${options.path} was asked for`);
1174
- if (await commands.readFile(shot.path, "base64") !== shot.base64) throw new Error(`Capture frame at ${options.path} is not the one this run shot`);
1184
+ await verifyFrame(shot, options.path, readCaptureReader());
1175
1185
  return shot.path;
1176
1186
  } finally {
1177
1187
  try {
@@ -1186,6 +1196,49 @@ async function captureFrame(options) {
1186
1196
  }
1187
1197
  }
1188
1198
  /**
1199
+ * Reads the optional disk-digest command the tester page registered.
1200
+ *
1201
+ * @returns The registered `readCapture` command, or undefined where none is registered.
1202
+ *
1203
+ * @remarks Vitest publishes only registered commands, so an unregistered `readCapture` reads as
1204
+ * undefined and a capture falls back to the base64 read-back. Outside a Vitest browser page, where
1205
+ * `commands` is no object, the command reads as undefined too, so importing this module never
1206
+ * throws there.
1207
+ * @example
1208
+ * ```ts
1209
+ * await verifyFrame(shot, '../../tmp/frame.png', readCaptureReader())
1210
+ * ```
1211
+ */
1212
+ function readCaptureReader() {
1213
+ if (typeof commands !== "object" || commands === null) return void 0;
1214
+ return readProperty(commands, "readCapture");
1215
+ }
1216
+ /**
1217
+ * Verifies a screenshot's destination and compares its returned bytes with the written file.
1218
+ *
1219
+ * @param shot - The provider's absolute path and base64 screenshot bytes.
1220
+ * @param path - The requested screenshot path, relative to the test file.
1221
+ * @param reader - The optional Node disk-digest command; omission uses Vitest's base64 read-back.
1222
+ * @throws Thrown when the destination differs, the bytes differ, or either reading fails.
1223
+ * @remarks Digest reads compare SHA-256 of the decoded shot with SHA-256 of the disk bytes.
1224
+ * Command failures propagate unchanged; they never select the base64 fallback.
1225
+ * @example
1226
+ * ```ts
1227
+ * await verifyFrame(shot, '../../tmp/frame.png', readCaptureReader())
1228
+ * ```
1229
+ */
1230
+ async function verifyFrame(shot, path, reader) {
1231
+ const segments = [];
1232
+ for (const segment of path.replaceAll("\\", "/").split("/")) {
1233
+ if (segment === "" || segment === ".") continue;
1234
+ if (segment === "..") segments.pop();
1235
+ else segments.push(segment);
1236
+ }
1237
+ if (!shot.path.replaceAll("\\", "/").endsWith(segments.join("/"))) throw new Error(`Capture frame was written to ${shot.path} where ${path} was asked for`);
1238
+ const expected = reader === void 0 ? shot.base64 : [...new Uint8Array(await crypto.subtle.digest("SHA-256", Uint8Array.from(atob(shot.base64), (character) => character.charCodeAt(0))))].map((byte) => byte.toString(16).padStart(2, "0")).join("");
1239
+ if ((reader === void 0 ? await commands.readFile(shot.path, "base64") : await reader(shot.path)) !== expected) throw new Error(`Capture frame at ${path} is not the one this run shot`);
1240
+ }
1241
+ /**
1189
1242
  * Decodes a base64 PNG and paints it, unscaled, onto a fresh offscreen 2D canvas.
1190
1243
  *
1191
1244
  * @param encoded - The image's bytes as base64 text, without a data-URL prefix.
@@ -1240,7 +1293,7 @@ async function paintImage(encoded) {
1240
1293
  *
1241
1294
  * @example
1242
1295
  * ```ts
1243
- * const reading = await readFrame(written)
1296
+ * const result = await readFrame(written)
1244
1297
  * ```
1245
1298
  */
1246
1299
  async function readFrame(path) {
@@ -1813,7 +1866,7 @@ function resolveFileInput(name) {
1813
1866
  * ```
1814
1867
  */
1815
1868
  async function chooseAccessible(name, files, options) {
1816
- if (options?.keyboard) await driveTraversal(() => resolveFileInput(name), name);
1869
+ if (options?.keyboard) await driveTraversal(() => resolveFileInput(name), name, (focused) => focused instanceof HTMLInputElement && focused.type === "file");
1817
1870
  const target = resolveFileInput(name);
1818
1871
  const command = readProperty(commands, "chooseFiles");
1819
1872
  if (typeof command !== "function") throw new Error("Register the chooseFiles browser command before choosing files");
@@ -2303,7 +2356,8 @@ async function pressKeys(keys) {
2303
2356
  * @throws When one complete traversal cannot reach the target.
2304
2357
  *
2305
2358
  * @remarks
2306
- * The loop is {@link driveTraversal} over {@link resolveRendered}. Consecutive landings inside a
2359
+ * The loop is {@link driveTraversal} over {@link resolveRendered}, with a conservative name check
2360
+ * before each arrival resolution. Consecutive landings inside a
2307
2361
  * native segmented input continue through its segments up to {@link FOCUS_SEGMENT_LIMIT} landings.
2308
2362
  * A longer run or any other revisit ends the traversal.
2309
2363
  *
@@ -2327,7 +2381,8 @@ async function traverseAccessible(name) {
2327
2381
  *
2328
2382
  * @remarks
2329
2383
  * The resolution is {@link resolveAccessibleWithin} and the loop is {@link driveTraversal}, so a
2330
- * twin of the same name earlier in the tab order is passed over rather than reached.
2384
+ * twin of the same name earlier in the tab order is passed over rather than reached. Candidates
2385
+ * retain the resolver's loose name match and must belong to a freshly resolved named region.
2331
2386
  *
2332
2387
  * @example
2333
2388
  * ```ts
@@ -2335,7 +2390,10 @@ async function traverseAccessible(name) {
2335
2390
  * ```
2336
2391
  */
2337
2392
  async function traverseAccessibleWithin(region, role, name) {
2338
- return driveTraversal(() => resolveAccessibleWithin(region, role, name), name);
2393
+ return driveTraversal(() => resolveAccessibleWithin(region, role, name), name, (focused) => matchesTraversalName(focused, name, false) && page.getByRole("region", {
2394
+ name: region,
2395
+ exact: true
2396
+ }).elements().some((container) => containsNode(container, focused)));
2339
2397
  }
2340
2398
  /**
2341
2399
  * Reads the HTML element that holds focus, following it into open shadow roots and same-origin
@@ -2477,12 +2535,50 @@ function supportsSegmentedFocus(element) {
2477
2535
  return realm !== null && element instanceof realm.HTMLInputElement && SEGMENTED_INPUT_TYPES.includes(element.type);
2478
2536
  }
2479
2537
  /**
2538
+ * Checks whether a landing can carry a requested accessible name without resolving the document.
2539
+ *
2540
+ * @param element - The element focus landed on.
2541
+ * @param name - The name the resolver matches.
2542
+ * @param exact - If `true`, compares exact names; if `false`, compares case-insensitive substrings.
2543
+ * Default: `true`.
2544
+ * @returns True if the name matches or its computation requires the resolver; false otherwise.
2545
+ *
2546
+ * @remarks
2547
+ * This is a conservative candidate check, not an accessible-name implementation. It compares a
2548
+ * nonempty `aria-label` without `aria-labelledby`, or the text of a plain native button or link.
2549
+ * Referenced labels, associated labels, descendants, shadow content, owned content, explicit roles,
2550
+ * generated content, and other naming rules fall through to the resolver. Empty requested names
2551
+ * also fall through because a role can prohibit naming. Whitespace, zero-width spaces, and soft
2552
+ * hyphens are normalized as in the provider's role query. Never use this check to accept a target.
2553
+ *
2554
+ * @example
2555
+ * ```ts
2556
+ * matchesTraversalName(document.createElement('input'), 'Attachments') // true
2557
+ * ```
2558
+ */
2559
+ function matchesTraversalName(element, name, exact = true) {
2560
+ const wanted = name.replaceAll(/[\u200b\u00ad]/g, "").trim().replaceAll(/\s+/g, " ");
2561
+ if (wanted.length === 0 || element.hasAttribute("aria-labelledby")) return true;
2562
+ const label = element.getAttribute("aria-label") ?? "";
2563
+ const realm = element.ownerDocument.defaultView;
2564
+ if (label.trim().length === 0) {
2565
+ if (realm === null || !(element instanceof realm.HTMLButtonElement || element instanceof realm.HTMLAnchorElement) || element.hasAttribute("role") || element.hasAttribute("aria-owns") || element.childElementCount > 0 || element.shadowRoot !== null || element instanceof realm.HTMLButtonElement && (element.labels?.length ?? 0) > 0 || element instanceof realm.HTMLAnchorElement && !element.hasAttribute("href")) return true;
2566
+ if (![realm.getComputedStyle(element, "::before"), realm.getComputedStyle(element, "::after")].every((style) => style.content === "none" || style.content === "normal")) return true;
2567
+ if ((element.textContent ?? "").trim().length === 0) return true;
2568
+ }
2569
+ const actual = (label.trim().length > 0 ? label : element.textContent ?? "").replaceAll(/[\u200b\u00ad]/g, "").trim().replaceAll(/\s+/g, " ");
2570
+ return exact ? actual === wanted : actual.toUpperCase().includes(wanted.toUpperCase());
2571
+ }
2572
+ /**
2480
2573
  * Reaches the control a resolver returns, only through natural forward Tab traversal from the
2481
2574
  * current focus.
2482
2575
  *
2483
- * @param resolve - The resolver that returns the target, called before the first step and again on
2484
- * every step, because a framework may replace the node between resolution and focus arrival.
2576
+ * @param resolve - The resolver called before traversal and at candidate arrivals, without retaining
2577
+ * its result between steps.
2485
2578
  * @param name - The target's name, as the refusal voices it.
2579
+ * @param candidate - The landing check; it must admit every element the resolver could return.
2580
+ * Default: the conservative exact-name check from {@link matchesTraversalName}. Supply a check
2581
+ * matching the resolver's semantics when it uses a label, region, or loose name.
2486
2582
  * @returns The target after the browser moves focus to it.
2487
2583
  * @throws When the resolver refuses, or one complete traversal cannot reach the target.
2488
2584
  *
@@ -2499,26 +2595,28 @@ function supportsSegmentedFocus(element) {
2499
2595
  * await driveTraversal(() => resolveRendered('Evaluate'), 'Evaluate')
2500
2596
  * ```
2501
2597
  */
2502
- async function driveTraversal(resolve, name) {
2598
+ async function driveTraversal(resolve, name, candidate) {
2503
2599
  resolve();
2504
2600
  const cap = document.querySelectorAll(FOCUSABLE_SELECTOR).length * 10 + 10;
2505
2601
  const visited = /* @__PURE__ */ new Set();
2506
- const landings = [];
2602
+ const stops = [];
2507
2603
  for await (const focused of stepFocus(cap)) {
2508
- const previous = landings.at(-1);
2509
- landings.push(focused);
2604
+ const previous = stops.at(-1);
2605
+ stops.push(focused);
2510
2606
  if (focused === void 0) continue;
2511
2607
  try {
2512
- const current = resolve();
2513
- if (focused === current) return current;
2608
+ if (candidate === void 0 ? matchesTraversalName(focused, name) : candidate(focused)) {
2609
+ const current = resolve();
2610
+ if (focused === current) return current;
2611
+ }
2514
2612
  } catch {
2515
2613
  continue;
2516
2614
  }
2517
- if (focused === previous && supportsSegmentedFocus(focused) && landings.length - landings.findLastIndex((landing) => landing !== focused) - 1 <= 10) continue;
2615
+ if (focused === previous && supportsSegmentedFocus(focused) && stops.length - stops.findLastIndex((entry) => entry !== focused) - 1 <= 10) continue;
2518
2616
  if (visited.has(focused)) break;
2519
2617
  visited.add(focused);
2520
2618
  }
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)}`);
2619
+ const trail = [...new Set(stops)].filter((focused) => focused !== void 0).filter((focused) => visited.has(focused)).map((focused) => `${focused.tagName}:${focused.innerText.slice(0, 20)}`);
2522
2620
  throw new Error(`Interactive target "${name}" is not reachable through forward Tab traversal: ${trail.join(" > ")}`);
2523
2621
  }
2524
2622
  /**
@@ -2558,13 +2656,13 @@ async function walkFocus(stop) {
2558
2656
  const first = readActiveElement();
2559
2657
  if (first === void 0) return [];
2560
2658
  const reached = [first];
2561
- const landings = [first];
2659
+ const stops = [first];
2562
2660
  if (stop?.(first) === true) return reached;
2563
2661
  for await (const focused of stepFocus(countElements() * 10)) {
2564
2662
  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;
2663
+ const previous = stops.at(-1);
2664
+ stops.push(focused);
2665
+ if (focused === previous && supportsSegmentedFocus(focused) && stops.length - stops.findLastIndex((entry) => entry !== focused) - 1 <= 10) continue;
2568
2666
  if (reached.includes(focused)) return reached;
2569
2667
  reached.push(focused);
2570
2668
  if (stop?.(focused) === true) return reached;
@@ -2969,11 +3067,11 @@ async function waitForState(first, second, third, fourth) {
2969
3067
  const absent = options?.absent ?? false;
2970
3068
  const description = `"${name}" to ${absent ? "stop announcing" : "announce"} "${state}"`;
2971
3069
  let observed = [];
2972
- let readings = 0;
3070
+ let count = 0;
2973
3071
  let refused;
2974
3072
  try {
2975
3073
  await waitForCondition(description, () => {
2976
- readings += 1;
3074
+ count += 1;
2977
3075
  try {
2978
3076
  observed = readStates(role === void 0 ? resolveRendered(name) : resolveRendered(role, name));
2979
3077
  } catch (thrown) {
@@ -2985,7 +3083,7 @@ async function waitForState(first, second, third, fourth) {
2985
3083
  } catch (cause) {
2986
3084
  if (refused !== void 0 && cause === refused.thrown) throw cause;
2987
3085
  if (cause === options?.signal?.reason) throw cause;
2988
- if (readings === 0) throw cause;
3086
+ if (count === 0) throw cause;
2989
3087
  if (!isError(cause)) throw cause;
2990
3088
  throw new Error(`${cause.message} (last states: ${JSON.stringify(observed)})`, { cause });
2991
3089
  }
@@ -5122,6 +5220,6 @@ function buildCensus() {
5122
5220
  });
5123
5221
  }
5124
5222
  //#endregion
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 };
5223
+ export { ACCESSIBLE_ROLES, CANVAS_COLOR, CAPTURE_PANE, CAPTURE_STAGE_LIMIT, 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, matchesTraversalName, measureContent, measureContrast, measureLuminance, mount, paintImage, parkPointer, parseCSSColor, parseColor, pressKeys, readAccessibilityNode, readActiveElement, readAnimations, readBackdrop, readCaptureReader, 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, verifyFrame, waitForAnimations, waitForFrame, waitForStability, waitForState, walkFocus };
5126
5224
 
5127
5225
  //# sourceMappingURL=index.js.map