@orkestrel/test 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/browser/index.d.ts +130 -7
- package/dist/src/browser/index.js +152 -16
- package/dist/src/browser/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -975,6 +975,54 @@ export declare function describeFocus(element: Element): string;
|
|
|
975
975
|
*/
|
|
976
976
|
export declare function describeTree(element: Element): string;
|
|
977
977
|
|
|
978
|
+
/**
|
|
979
|
+
* Holds the primary pointer button on the control a resolver returns, through the browser provider.
|
|
980
|
+
*
|
|
981
|
+
* @param resolve - The resolver that returns the target, called after the held-pointer refusal.
|
|
982
|
+
* @param name - The target's name, as the refusals voice it.
|
|
983
|
+
* @returns A promise resolving after the control enters its pressed state.
|
|
984
|
+
* @throws Thrown when a pointer is already held, the resolver refuses, the target stays outside
|
|
985
|
+
* the viewport after scrolling, or the press misses. A missed press that also fails to release
|
|
986
|
+
* carries the release rejection as its cause.
|
|
987
|
+
*
|
|
988
|
+
* @remarks
|
|
989
|
+
* This is the one pointer drive every hold verb shares: the held-marker refusal, a scroll that
|
|
990
|
+
* brings a wholly off-viewport target into view and a refusal for one that stays outside, the
|
|
991
|
+
* centre mapped through the tester iframe's painted scale into page coordinates, the trusted move
|
|
992
|
+
* and press, the marker, a frame wait, and the `:active` read-back that releases before refusing a
|
|
993
|
+
* missed press. The refusal precedes resolution, so a double hold is refused before an absent
|
|
994
|
+
* name is.
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* ```ts
|
|
998
|
+
* await driveHold(() => resolveAccessible('Apply'), 'Apply')
|
|
999
|
+
* await releasePointer()
|
|
1000
|
+
* ```
|
|
1001
|
+
*/
|
|
1002
|
+
export declare function driveHold(resolve: () => HTMLElement, name: string): Promise<void>;
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Reaches the control a resolver returns, only through natural forward Tab traversal from the
|
|
1006
|
+
* current focus.
|
|
1007
|
+
*
|
|
1008
|
+
* @param resolve - The resolver that returns the target, called before the first step and again on
|
|
1009
|
+
* every step, because a framework may replace the node between resolution and focus arrival.
|
|
1010
|
+
* @param name - The target's name, as the refusal voices it.
|
|
1011
|
+
* @returns The target after the browser moves focus to it.
|
|
1012
|
+
* @throws When the resolver refuses, or one complete traversal cannot reach the target.
|
|
1013
|
+
*
|
|
1014
|
+
* @remarks
|
|
1015
|
+
* This is the one loop every traversal verb shares. A step counts only when focus lands on an
|
|
1016
|
+
* element, the traversal is over when focus revisits one, and the cap is counted off
|
|
1017
|
+
* {@link FOCUSABLE_SELECTOR}.
|
|
1018
|
+
*
|
|
1019
|
+
* @example
|
|
1020
|
+
* ```ts
|
|
1021
|
+
* await driveTraversal(() => resolveRendered('Evaluate'), 'Evaluate')
|
|
1022
|
+
* ```
|
|
1023
|
+
*/
|
|
1024
|
+
export declare function driveTraversal(resolve: () => HTMLElement, name: string): Promise<HTMLElement>;
|
|
1025
|
+
|
|
978
1026
|
/**
|
|
979
1027
|
* Configures one built element: its class list, its text, and its attributes.
|
|
980
1028
|
*
|
|
@@ -1292,7 +1340,7 @@ export declare const HEADER_ROLES: Readonly<Record<string, string>>;
|
|
|
1292
1340
|
* reading verifies delivery. A missed press releases before refusing; if that release also
|
|
1293
1341
|
* rejects, the refusal carries it as its cause. Register {@link releasePointer} in teardown
|
|
1294
1342
|
* before holding; release can produce a click on the pressed control. A rejected button-down send
|
|
1295
|
-
* leaves no hold marker.
|
|
1343
|
+
* leaves no hold marker. The hold itself is {@link driveHold}.
|
|
1296
1344
|
*
|
|
1297
1345
|
* @example
|
|
1298
1346
|
* ```ts
|
|
@@ -1319,6 +1367,30 @@ export declare function holdAccessible(name: string): Promise<void>;
|
|
|
1319
1367
|
*/
|
|
1320
1368
|
export declare function holdAccessible(role: string, name: string): Promise<void>;
|
|
1321
1369
|
|
|
1370
|
+
/**
|
|
1371
|
+
* Holds the primary pointer button on one control by role and accessible-name text inside a named
|
|
1372
|
+
* region.
|
|
1373
|
+
*
|
|
1374
|
+
* @param region - The containing region's exact accessible name.
|
|
1375
|
+
* @param role - The control's exact ARIA role.
|
|
1376
|
+
* @param name - The rendered accessible-name text that identifies the control in that region.
|
|
1377
|
+
* @returns A promise resolving after the control enters its pressed state.
|
|
1378
|
+
* @throws Thrown when a pointer is already held, the region refuses the target, or the press
|
|
1379
|
+
* misses. A missed press that also fails to release carries the release rejection as its cause.
|
|
1380
|
+
*
|
|
1381
|
+
* @remarks
|
|
1382
|
+
* The resolution is {@link resolveAccessibleWithin} and the hold is {@link driveHold}, so a twin
|
|
1383
|
+
* of the same name in another region is left alone. Register {@link releasePointer} in teardown
|
|
1384
|
+
* before holding.
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```ts
|
|
1388
|
+
* await holdAccessibleWithin('Ledger', 'button', 'Apply')
|
|
1389
|
+
* await releasePointer()
|
|
1390
|
+
* ```
|
|
1391
|
+
*/
|
|
1392
|
+
export declare function holdAccessibleWithin(region: string, role: string, name: string): Promise<void>;
|
|
1393
|
+
|
|
1322
1394
|
/**
|
|
1323
1395
|
* Hovers one visible, focus-reachable control by its accessible name through the browser provider.
|
|
1324
1396
|
*
|
|
@@ -1617,12 +1689,14 @@ export declare function measureLuminance(color: Color): number;
|
|
|
1617
1689
|
*/
|
|
1618
1690
|
export declare const MEDIA_STAGE = "data-media-stage";
|
|
1619
1691
|
|
|
1620
|
-
/** Configures the tester's print medium and
|
|
1692
|
+
/** Configures the tester's print medium, motion preference, and forced colours. */
|
|
1621
1693
|
export declare interface MediaOptions {
|
|
1622
1694
|
/** Determines whether the tester lays out for print. Omit it to leave the medium alone. */
|
|
1623
1695
|
readonly print?: boolean;
|
|
1624
1696
|
/** Determines whether the tester prefers motion. Omit it to leave the preference alone. */
|
|
1625
1697
|
readonly motion?: boolean;
|
|
1698
|
+
/** Determines whether the tester runs under forced colours. Omit it to leave the colours alone. */
|
|
1699
|
+
readonly forced?: boolean;
|
|
1626
1700
|
}
|
|
1627
1701
|
|
|
1628
1702
|
/**
|
|
@@ -2618,6 +2692,28 @@ export declare function resolveAccessible(name: string): HTMLElement;
|
|
|
2618
2692
|
*/
|
|
2619
2693
|
export declare function resolveAccessible(role: string, name: string): HTMLElement;
|
|
2620
2694
|
|
|
2695
|
+
/**
|
|
2696
|
+
* Resolves one human-reachable control by role and accessible-name text inside a named region.
|
|
2697
|
+
*
|
|
2698
|
+
* @param region - The containing region's exact accessible name.
|
|
2699
|
+
* @param role - The control's exact ARIA role.
|
|
2700
|
+
* @param name - The rendered accessible-name text that identifies the control in that region.
|
|
2701
|
+
* @returns The one reachable element carrying that role and name inside the region.
|
|
2702
|
+
* @throws When the named control is absent, unreachable, or ambiguous inside the region.
|
|
2703
|
+
*
|
|
2704
|
+
* @remarks
|
|
2705
|
+
* The region's name is matched exactly and the control's name loosely, over a computed name that
|
|
2706
|
+
* includes hidden subtrees, so a glyph joins the text rather than displacing it. One pass answers
|
|
2707
|
+
* this: a control the region cannot reach is refused whether it is absent or hidden. This is the
|
|
2708
|
+
* resolver the region-scoped verbs share.
|
|
2709
|
+
*
|
|
2710
|
+
* @example
|
|
2711
|
+
* ```ts
|
|
2712
|
+
* resolveAccessibleWithin('Ledger', 'button', 'Monthly income')
|
|
2713
|
+
* ```
|
|
2714
|
+
*/
|
|
2715
|
+
export declare function resolveAccessibleWithin(region: string, role: string, name: string): HTMLElement;
|
|
2716
|
+
|
|
2621
2717
|
/**
|
|
2622
2718
|
* Resolves one rendered, focus-reachable interactive element without requiring it to intersect the
|
|
2623
2719
|
* viewport yet.
|
|
@@ -2663,17 +2759,20 @@ export declare function resolveRendered(first: string, second?: string): HTMLEle
|
|
|
2663
2759
|
export declare function sendProtocol(method: string, params: Readonly<Record<string, unknown>>): Promise<void>;
|
|
2664
2760
|
|
|
2665
2761
|
/**
|
|
2666
|
-
* Stages the tester's print medium
|
|
2762
|
+
* Stages the tester's print medium, motion preference, and forced colours through the browser
|
|
2763
|
+
* provider.
|
|
2667
2764
|
*
|
|
2668
2765
|
* @param options - The media axes to override.
|
|
2669
|
-
* @returns A promise resolving after a bounded read-back for `print: true`
|
|
2670
|
-
* `
|
|
2766
|
+
* @returns A promise resolving after a bounded read-back for `print: true`, either `motion` value,
|
|
2767
|
+
* and either `forced` value. A `print: false` stage is sent and followed by a frame wait without a
|
|
2768
|
+
* read-back.
|
|
2671
2769
|
* @throws Thrown when no axis is supplied or a staged query does not reach the tester.
|
|
2672
2770
|
*
|
|
2673
2771
|
* @remarks
|
|
2674
2772
|
* If `print` is true, uses print; if false, uses screen. If `motion` is true, uses no preference;
|
|
2675
|
-
* if false, uses reduced motion.
|
|
2676
|
-
*
|
|
2773
|
+
* if false, uses reduced motion. If `forced` is true, uses active forced colours; if false, uses
|
|
2774
|
+
* none. The print medium, reduced motion, colour scheme, and forced colours keep their effective
|
|
2775
|
+
* readings when omitted. Any other emulated feature the provider configured
|
|
2677
2776
|
* is cleared. Each staged query waits up to 1000 milliseconds, polling every 10 milliseconds.
|
|
2678
2777
|
* A refused read-back restores the carried pre-call readings before throwing and can take two
|
|
2679
2778
|
* budgets. A restoration failure is attached as the refusal's cause. Register
|
|
@@ -2781,6 +2880,9 @@ export declare interface StorageOptions {
|
|
|
2781
2880
|
* @returns The target after the browser moves focus to it.
|
|
2782
2881
|
* @throws When one complete traversal cannot reach the target.
|
|
2783
2882
|
*
|
|
2883
|
+
* @remarks
|
|
2884
|
+
* The loop is {@link driveTraversal} over {@link resolveRendered}.
|
|
2885
|
+
*
|
|
2784
2886
|
* @example
|
|
2785
2887
|
* ```ts
|
|
2786
2888
|
* await traverseAccessible('Evaluate')
|
|
@@ -2788,6 +2890,27 @@ export declare interface StorageOptions {
|
|
|
2788
2890
|
*/
|
|
2789
2891
|
export declare function traverseAccessible(name: string): Promise<HTMLElement>;
|
|
2790
2892
|
|
|
2893
|
+
/**
|
|
2894
|
+
* Reaches a control by role and accessible-name text inside a named region, only through natural
|
|
2895
|
+
* forward Tab traversal from the current focus.
|
|
2896
|
+
*
|
|
2897
|
+
* @param region - The containing region's exact accessible name.
|
|
2898
|
+
* @param role - The control's exact ARIA role.
|
|
2899
|
+
* @param name - The rendered accessible-name text that identifies the control in that region.
|
|
2900
|
+
* @returns The target after the browser moves focus to it.
|
|
2901
|
+
* @throws When the region refuses the target, or one complete traversal cannot reach it.
|
|
2902
|
+
*
|
|
2903
|
+
* @remarks
|
|
2904
|
+
* The resolution is {@link resolveAccessibleWithin} and the loop is {@link driveTraversal}, so a
|
|
2905
|
+
* twin of the same name earlier in the tab order is passed over rather than reached.
|
|
2906
|
+
*
|
|
2907
|
+
* @example
|
|
2908
|
+
* ```ts
|
|
2909
|
+
* await traverseAccessibleWithin('Ledger', 'button', 'Evaluate')
|
|
2910
|
+
* ```
|
|
2911
|
+
*/
|
|
2912
|
+
export declare function traverseAccessibleWithin(region: string, role: string, name: string): Promise<HTMLElement>;
|
|
2913
|
+
|
|
2791
2914
|
/**
|
|
2792
2915
|
* Replaces a named field's value through focus, select-all, deletion, and real keystrokes.
|
|
2793
2916
|
*
|
|
@@ -503,6 +503,29 @@ async function clickAccessible(first, second) {
|
|
|
503
503
|
* ```
|
|
504
504
|
*/
|
|
505
505
|
async function clickAccessibleWithin(region, role, name) {
|
|
506
|
+
await userEvent.click(resolveAccessibleWithin(region, role, name));
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Resolves one human-reachable control by role and accessible-name text inside a named region.
|
|
510
|
+
*
|
|
511
|
+
* @param region - The containing region's exact accessible name.
|
|
512
|
+
* @param role - The control's exact ARIA role.
|
|
513
|
+
* @param name - The rendered accessible-name text that identifies the control in that region.
|
|
514
|
+
* @returns The one reachable element carrying that role and name inside the region.
|
|
515
|
+
* @throws When the named control is absent, unreachable, or ambiguous inside the region.
|
|
516
|
+
*
|
|
517
|
+
* @remarks
|
|
518
|
+
* The region's name is matched exactly and the control's name loosely, over a computed name that
|
|
519
|
+
* includes hidden subtrees, so a glyph joins the text rather than displacing it. One pass answers
|
|
520
|
+
* this: a control the region cannot reach is refused whether it is absent or hidden. This is the
|
|
521
|
+
* resolver the region-scoped verbs share.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```ts
|
|
525
|
+
* resolveAccessibleWithin('Ledger', 'button', 'Monthly income')
|
|
526
|
+
* ```
|
|
527
|
+
*/
|
|
528
|
+
function resolveAccessibleWithin(region, role, name) {
|
|
506
529
|
const reachable = page.getByRole("region", {
|
|
507
530
|
name: region,
|
|
508
531
|
exact: true
|
|
@@ -515,7 +538,7 @@ async function clickAccessibleWithin(region, role, name) {
|
|
|
515
538
|
if (reachable.length > 1) throw new Error(`Interactive target "${name}" is ambiguous across ${reachable.length} elements inside "${region}"`);
|
|
516
539
|
const [target] = reachable;
|
|
517
540
|
if (!(target instanceof HTMLElement)) throw new Error(`Interactive target "${name}" could not be resolved inside "${region}"`);
|
|
518
|
-
|
|
541
|
+
return target;
|
|
519
542
|
}
|
|
520
543
|
/**
|
|
521
544
|
* Opens or closes one native details disclosure by its rendered summary.
|
|
@@ -573,10 +596,67 @@ async function hoverAccessible(first, second) {
|
|
|
573
596
|
await userEvent.hover(resolveRendered(first, second));
|
|
574
597
|
}
|
|
575
598
|
async function holdAccessible(first, second) {
|
|
599
|
+
await driveHold(() => second === void 0 ? resolveAccessible(first) : resolveAccessible(first, second), second ?? first);
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Holds the primary pointer button on one control by role and accessible-name text inside a named
|
|
603
|
+
* region.
|
|
604
|
+
*
|
|
605
|
+
* @param region - The containing region's exact accessible name.
|
|
606
|
+
* @param role - The control's exact ARIA role.
|
|
607
|
+
* @param name - The rendered accessible-name text that identifies the control in that region.
|
|
608
|
+
* @returns A promise resolving after the control enters its pressed state.
|
|
609
|
+
* @throws Thrown when a pointer is already held, the region refuses the target, or the press
|
|
610
|
+
* misses. A missed press that also fails to release carries the release rejection as its cause.
|
|
611
|
+
*
|
|
612
|
+
* @remarks
|
|
613
|
+
* The resolution is {@link resolveAccessibleWithin} and the hold is {@link driveHold}, so a twin
|
|
614
|
+
* of the same name in another region is left alone. Register {@link releasePointer} in teardown
|
|
615
|
+
* before holding.
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```ts
|
|
619
|
+
* await holdAccessibleWithin('Ledger', 'button', 'Apply')
|
|
620
|
+
* await releasePointer()
|
|
621
|
+
* ```
|
|
622
|
+
*/
|
|
623
|
+
async function holdAccessibleWithin(region, role, name) {
|
|
624
|
+
await driveHold(() => resolveAccessibleWithin(region, role, name), name);
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Holds the primary pointer button on the control a resolver returns, through the browser provider.
|
|
628
|
+
*
|
|
629
|
+
* @param resolve - The resolver that returns the target, called after the held-pointer refusal.
|
|
630
|
+
* @param name - The target's name, as the refusals voice it.
|
|
631
|
+
* @returns A promise resolving after the control enters its pressed state.
|
|
632
|
+
* @throws Thrown when a pointer is already held, the resolver refuses, the target stays outside
|
|
633
|
+
* the viewport after scrolling, or the press misses. A missed press that also fails to release
|
|
634
|
+
* carries the release rejection as its cause.
|
|
635
|
+
*
|
|
636
|
+
* @remarks
|
|
637
|
+
* This is the one pointer drive every hold verb shares: the held-marker refusal, a scroll that
|
|
638
|
+
* brings a wholly off-viewport target into view and a refusal for one that stays outside, the
|
|
639
|
+
* centre mapped through the tester iframe's painted scale into page coordinates, the trusted move
|
|
640
|
+
* and press, the marker, a frame wait, and the `:active` read-back that releases before refusing a
|
|
641
|
+
* missed press. The refusal precedes resolution, so a double hold is refused before an absent
|
|
642
|
+
* name is.
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* ```ts
|
|
646
|
+
* await driveHold(() => resolveAccessible('Apply'), 'Apply')
|
|
647
|
+
* await releasePointer()
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
async function driveHold(resolve, name) {
|
|
576
651
|
const held = document.documentElement.getAttribute(POINTER_HOLD);
|
|
577
652
|
if (held !== null) throw new Error(`Pointer is already held at ${held}`);
|
|
578
|
-
const target =
|
|
653
|
+
const target = resolve();
|
|
654
|
+
if (isOutsideViewport(target.getBoundingClientRect())) target.scrollIntoView({
|
|
655
|
+
block: "nearest",
|
|
656
|
+
behavior: "instant"
|
|
657
|
+
});
|
|
579
658
|
const box = target.getBoundingClientRect();
|
|
659
|
+
if (isOutsideViewport(box)) throw new Error(`Interactive target "${name}" is unreachable after scrolling`);
|
|
580
660
|
const frame = window.frameElement?.getBoundingClientRect();
|
|
581
661
|
const scale = frame === void 0 ? 1 : frame.width / window.innerWidth;
|
|
582
662
|
const x = (frame?.left ?? 0) + (box.left + box.width / 2) * scale;
|
|
@@ -600,9 +680,9 @@ async function holdAccessible(first, second) {
|
|
|
600
680
|
try {
|
|
601
681
|
await releasePointer();
|
|
602
682
|
} catch (cause) {
|
|
603
|
-
throw new Error(`Interactive target "${
|
|
683
|
+
throw new Error(`Interactive target "${name}" did not enter the pressed state`, { cause });
|
|
604
684
|
}
|
|
605
|
-
throw new Error(`Interactive target "${
|
|
685
|
+
throw new Error(`Interactive target "${name}" did not enter the pressed state`);
|
|
606
686
|
}
|
|
607
687
|
}
|
|
608
688
|
/**
|
|
@@ -734,13 +814,61 @@ async function pressKeys(keys) {
|
|
|
734
814
|
* @returns The target after the browser moves focus to it.
|
|
735
815
|
* @throws When one complete traversal cannot reach the target.
|
|
736
816
|
*
|
|
817
|
+
* @remarks
|
|
818
|
+
* The loop is {@link driveTraversal} over {@link resolveRendered}.
|
|
819
|
+
*
|
|
737
820
|
* @example
|
|
738
821
|
* ```ts
|
|
739
822
|
* await traverseAccessible('Evaluate')
|
|
740
823
|
* ```
|
|
741
824
|
*/
|
|
742
825
|
async function traverseAccessible(name) {
|
|
743
|
-
resolveRendered(name);
|
|
826
|
+
return driveTraversal(() => resolveRendered(name), name);
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Reaches a control by role and accessible-name text inside a named region, only through natural
|
|
830
|
+
* forward Tab traversal from the current focus.
|
|
831
|
+
*
|
|
832
|
+
* @param region - The containing region's exact accessible name.
|
|
833
|
+
* @param role - The control's exact ARIA role.
|
|
834
|
+
* @param name - The rendered accessible-name text that identifies the control in that region.
|
|
835
|
+
* @returns The target after the browser moves focus to it.
|
|
836
|
+
* @throws When the region refuses the target, or one complete traversal cannot reach it.
|
|
837
|
+
*
|
|
838
|
+
* @remarks
|
|
839
|
+
* The resolution is {@link resolveAccessibleWithin} and the loop is {@link driveTraversal}, so a
|
|
840
|
+
* twin of the same name earlier in the tab order is passed over rather than reached.
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```ts
|
|
844
|
+
* await traverseAccessibleWithin('Ledger', 'button', 'Evaluate')
|
|
845
|
+
* ```
|
|
846
|
+
*/
|
|
847
|
+
async function traverseAccessibleWithin(region, role, name) {
|
|
848
|
+
return driveTraversal(() => resolveAccessibleWithin(region, role, name), name);
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Reaches the control a resolver returns, only through natural forward Tab traversal from the
|
|
852
|
+
* current focus.
|
|
853
|
+
*
|
|
854
|
+
* @param resolve - The resolver that returns the target, called before the first step and again on
|
|
855
|
+
* every step, because a framework may replace the node between resolution and focus arrival.
|
|
856
|
+
* @param name - The target's name, as the refusal voices it.
|
|
857
|
+
* @returns The target after the browser moves focus to it.
|
|
858
|
+
* @throws When the resolver refuses, or one complete traversal cannot reach the target.
|
|
859
|
+
*
|
|
860
|
+
* @remarks
|
|
861
|
+
* This is the one loop every traversal verb shares. A step counts only when focus lands on an
|
|
862
|
+
* element, the traversal is over when focus revisits one, and the cap is counted off
|
|
863
|
+
* {@link FOCUSABLE_SELECTOR}.
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* ```ts
|
|
867
|
+
* await driveTraversal(() => resolveRendered('Evaluate'), 'Evaluate')
|
|
868
|
+
* ```
|
|
869
|
+
*/
|
|
870
|
+
async function driveTraversal(resolve, name) {
|
|
871
|
+
resolve();
|
|
744
872
|
const cap = document.querySelectorAll(FOCUSABLE_SELECTOR).length * 3 + 10;
|
|
745
873
|
const visited = /* @__PURE__ */ new Set();
|
|
746
874
|
const trail = [];
|
|
@@ -750,7 +878,7 @@ async function traverseAccessible(name) {
|
|
|
750
878
|
if (!(focused instanceof HTMLElement) || focused === document.body) continue;
|
|
751
879
|
let current;
|
|
752
880
|
try {
|
|
753
|
-
current =
|
|
881
|
+
current = resolve();
|
|
754
882
|
} catch {
|
|
755
883
|
continue;
|
|
756
884
|
}
|
|
@@ -2552,17 +2680,20 @@ async function releasePane() {
|
|
|
2552
2680
|
if (Number.isFinite(width) && Number.isFinite(height)) await page.viewport(width, height);
|
|
2553
2681
|
}
|
|
2554
2682
|
/**
|
|
2555
|
-
* Stages the tester's print medium
|
|
2683
|
+
* Stages the tester's print medium, motion preference, and forced colours through the browser
|
|
2684
|
+
* provider.
|
|
2556
2685
|
*
|
|
2557
2686
|
* @param options - The media axes to override.
|
|
2558
|
-
* @returns A promise resolving after a bounded read-back for `print: true`
|
|
2559
|
-
* `
|
|
2687
|
+
* @returns A promise resolving after a bounded read-back for `print: true`, either `motion` value,
|
|
2688
|
+
* and either `forced` value. A `print: false` stage is sent and followed by a frame wait without a
|
|
2689
|
+
* read-back.
|
|
2560
2690
|
* @throws Thrown when no axis is supplied or a staged query does not reach the tester.
|
|
2561
2691
|
*
|
|
2562
2692
|
* @remarks
|
|
2563
2693
|
* If `print` is true, uses print; if false, uses screen. If `motion` is true, uses no preference;
|
|
2564
|
-
* if false, uses reduced motion.
|
|
2565
|
-
*
|
|
2694
|
+
* if false, uses reduced motion. If `forced` is true, uses active forced colours; if false, uses
|
|
2695
|
+
* none. The print medium, reduced motion, colour scheme, and forced colours keep their effective
|
|
2696
|
+
* readings when omitted. Any other emulated feature the provider configured
|
|
2566
2697
|
* is cleared. Each staged query waits up to 1000 milliseconds, polling every 10 milliseconds.
|
|
2567
2698
|
* A refused read-back restores the carried pre-call readings before throwing and can take two
|
|
2568
2699
|
* budgets. A restoration failure is attached as the refusal's cause. Register
|
|
@@ -2577,16 +2708,17 @@ async function releasePane() {
|
|
|
2577
2708
|
async function stageMedia(options) {
|
|
2578
2709
|
const print = options.print;
|
|
2579
2710
|
const motion = options.motion;
|
|
2580
|
-
|
|
2711
|
+
const forced = options.forced;
|
|
2712
|
+
if (print === void 0 && motion === void 0 && forced === void 0) throw new Error("Media emulation was staged with nothing to emulate");
|
|
2581
2713
|
const media = matchMedia("print").matches ? "print" : "screen";
|
|
2582
2714
|
const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
2583
2715
|
const dark = matchMedia("(prefers-color-scheme: dark)").matches;
|
|
2584
|
-
const
|
|
2716
|
+
const active = matchMedia("(forced-colors: active)").matches;
|
|
2585
2717
|
if (!document.documentElement.hasAttribute("data-media-stage")) document.documentElement.setAttribute(MEDIA_STAGE, [
|
|
2586
2718
|
media === "print",
|
|
2587
2719
|
reduced,
|
|
2588
2720
|
dark,
|
|
2589
|
-
|
|
2721
|
+
active
|
|
2590
2722
|
].map(Number).join(""));
|
|
2591
2723
|
const features = [
|
|
2592
2724
|
{
|
|
@@ -2595,7 +2727,7 @@ async function stageMedia(options) {
|
|
|
2595
2727
|
},
|
|
2596
2728
|
{
|
|
2597
2729
|
name: "forced-colors",
|
|
2598
|
-
value:
|
|
2730
|
+
value: active ? "active" : "none"
|
|
2599
2731
|
},
|
|
2600
2732
|
{
|
|
2601
2733
|
name: "prefers-reduced-motion",
|
|
@@ -2605,11 +2737,15 @@ async function stageMedia(options) {
|
|
|
2605
2737
|
const queries = [];
|
|
2606
2738
|
if (print === true) queries.push("print");
|
|
2607
2739
|
if (motion !== void 0) queries.push(`(prefers-reduced-motion: ${motion ? "no-preference" : "reduce"})`);
|
|
2740
|
+
if (forced !== void 0) queries.push(`(forced-colors: ${forced ? "active" : "none"})`);
|
|
2608
2741
|
await sendProtocol("Emulation.setEmulatedMedia", {
|
|
2609
2742
|
media: print === void 0 ? media : print ? "print" : "screen",
|
|
2610
2743
|
features: features.map((feature) => feature.name === "prefers-reduced-motion" && motion !== void 0 ? {
|
|
2611
2744
|
name: feature.name,
|
|
2612
2745
|
value: motion ? "no-preference" : "reduce"
|
|
2746
|
+
} : feature.name === "forced-colors" && forced !== void 0 ? {
|
|
2747
|
+
name: feature.name,
|
|
2748
|
+
value: forced ? "active" : "none"
|
|
2613
2749
|
} : feature)
|
|
2614
2750
|
});
|
|
2615
2751
|
await waitForFrame();
|
|
@@ -3531,6 +3667,6 @@ function createHarness(options) {
|
|
|
3531
3667
|
};
|
|
3532
3668
|
}
|
|
3533
3669
|
//#endregion
|
|
3534
|
-
export { ACCESSIBLE_ROLES, CANVAS_COLOR, CAPTURE_PANE, CAPTURE_STAGINGS, CONTENT_ROLES, FIELD_ROLES, FOCUSABLE_SELECTOR, HEADER_ROLES, IMPLICIT_ROLES, MEDIA_STAGE, POINTER_HOLD, blendColor, build, buildCensus, buildContrast, buildDenial, buildEscapes, captureFrame, clearStorage, clickAccessible, clickAccessibleWithin, clickDisclosure, commitInput, computeNamePattern, convertA98RGB, convertDisplayP3, convertLab, convertLinearSRGB, convertOKLab, convertProPhotoRGB, convertRec2020, convertSRGB, convertXYZD50, convertXYZD65, createChannel, createDragEvent, createHarness, createJournal, createPointerEvent, createPortfolio, createStorage, describeFocus, describeTree, expandCaptures, extractOrphans, extractStyles, fillAccessible, findKeyframes, findRule, holdAccessible, hoverAccessible, isOutsideViewport, isReachable, isRendered, matchesColor, measureContent, measureContrast, measureLuminance, mount, parseCSSColor, parseColor, pressKeys, readBackdrop, readCascade, readCensus, readClasses, readContrast, readFocus, readFrame, readHit, readLayers, readName, readPage, readPerception, readPixels, readRefusal, readRing, readRole, readRootToken, readRows, readRules, readStates, readStyle, readText, readToken, readValue, releaseMedia, releasePane, releasePointer, removeDatabase, render, resolveAccessible, resolveRendered, sendProtocol, stageMedia, stagePane, traverseAccessible, typeAccessible, typeInput, waitForAnimations, waitForFrame, waitForState };
|
|
3670
|
+
export { ACCESSIBLE_ROLES, CANVAS_COLOR, CAPTURE_PANE, CAPTURE_STAGINGS, CONTENT_ROLES, FIELD_ROLES, FOCUSABLE_SELECTOR, HEADER_ROLES, IMPLICIT_ROLES, MEDIA_STAGE, POINTER_HOLD, blendColor, build, buildCensus, buildContrast, buildDenial, buildEscapes, captureFrame, clearStorage, clickAccessible, clickAccessibleWithin, clickDisclosure, commitInput, computeNamePattern, convertA98RGB, convertDisplayP3, convertLab, convertLinearSRGB, convertOKLab, convertProPhotoRGB, convertRec2020, convertSRGB, convertXYZD50, convertXYZD65, createChannel, createDragEvent, createHarness, createJournal, createPointerEvent, createPortfolio, createStorage, describeFocus, describeTree, driveHold, driveTraversal, expandCaptures, extractOrphans, extractStyles, fillAccessible, findKeyframes, findRule, holdAccessible, holdAccessibleWithin, hoverAccessible, isOutsideViewport, isReachable, isRendered, matchesColor, measureContent, measureContrast, measureLuminance, mount, parseCSSColor, parseColor, pressKeys, readBackdrop, readCascade, readCensus, readClasses, readContrast, readFocus, readFrame, readHit, readLayers, readName, readPage, readPerception, readPixels, readRefusal, readRing, readRole, readRootToken, readRows, readRules, readStates, readStyle, readText, readToken, readValue, releaseMedia, releasePane, releasePointer, removeDatabase, render, resolveAccessible, resolveAccessibleWithin, resolveRendered, sendProtocol, stageMedia, stagePane, traverseAccessible, traverseAccessibleWithin, typeAccessible, typeInput, waitForAnimations, waitForFrame, waitForState };
|
|
3535
3671
|
|
|
3536
3672
|
//# sourceMappingURL=index.js.map
|