@orkestrel/test 0.0.19 → 0.0.21
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 +222 -12
- package/dist/src/browser/index.js +263 -22
- package/dist/src/browser/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -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
|
}
|
|
@@ -2402,6 +2530,97 @@ function readPixels(element, property, pseudo) {
|
|
|
2402
2530
|
return Number.isFinite(measured) ? measured : 0;
|
|
2403
2531
|
}
|
|
2404
2532
|
/**
|
|
2533
|
+
* Measures the row a clipping element cuts its content off at, in document coordinates.
|
|
2534
|
+
*
|
|
2535
|
+
* @param element - The element to read.
|
|
2536
|
+
* @returns The element's overflow clip edge in CSS pixels from the document's top, or the
|
|
2537
|
+
* `undefined` value for an element that clips nothing, as the {@link clipsOverflow} helper reports
|
|
2538
|
+
* it.
|
|
2539
|
+
*
|
|
2540
|
+
* @remarks
|
|
2541
|
+
* An `overflow-y` value of the `hidden` keyword, the `auto` keyword, or the `scroll` keyword stops
|
|
2542
|
+
* the content at the padding box, whatever the element's `overflow-clip-margin` value says. A
|
|
2543
|
+
* `clip` overflow and a paint containment over a `visible` overflow start the edge from the box the
|
|
2544
|
+
* computed `overflow-clip-margin` value names (the `border-box` keyword, the `padding-box` keyword,
|
|
2545
|
+
* or the `content-box` keyword, and the padding box where the value names none) and expand it by
|
|
2546
|
+
* the length the {@link readClipMargin} helper reads. So a bordered or padded frame whose clip
|
|
2547
|
+
* margin names no box ends at its padding box plus the margin, where the browser stops painting its
|
|
2548
|
+
* content, rather than at its border box plus the margin. The computed value drops the
|
|
2549
|
+
* `padding-box` keyword because it is the default, which is why a value carrying no keyword reads
|
|
2550
|
+
* from the padding box.
|
|
2551
|
+
*
|
|
2552
|
+
* The edge is the bottom one, because that is the edge a reading of the document's height meets.
|
|
2553
|
+
*
|
|
2554
|
+
* @example
|
|
2555
|
+
* ```ts
|
|
2556
|
+
* const edge = readClipEdge(frame)
|
|
2557
|
+
* if (edge !== undefined && edge < bottom) bottom = edge
|
|
2558
|
+
* ```
|
|
2559
|
+
*/
|
|
2560
|
+
function readClipEdge(element) {
|
|
2561
|
+
if (!clipsOverflow(element)) return void 0;
|
|
2562
|
+
const border = element.getBoundingClientRect().bottom + window.scrollY;
|
|
2563
|
+
const padding = border - readPixels(element, "border-bottom-width");
|
|
2564
|
+
const overflow = readStyle(element, "overflow-y");
|
|
2565
|
+
if (overflow !== "clip" && overflow !== "visible") return padding;
|
|
2566
|
+
const margin = readStyle(element, "overflow-clip-margin");
|
|
2567
|
+
if (margin.includes("border-box")) return border + readClipMargin(element);
|
|
2568
|
+
if (margin.includes("content-box")) return padding - readPixels(element, "padding-bottom") + readClipMargin(element);
|
|
2569
|
+
return padding + readClipMargin(element);
|
|
2570
|
+
}
|
|
2571
|
+
/**
|
|
2572
|
+
* Measures how far past its own box a clipping element lets its content show.
|
|
2573
|
+
*
|
|
2574
|
+
* @param element - The element to read.
|
|
2575
|
+
* @returns The computed `overflow-clip-margin` length in CSS pixels where the element's computed
|
|
2576
|
+
* `overflow-y` value is the `clip` keyword or its clip comes from paint containment alone, and zero
|
|
2577
|
+
* for every other element.
|
|
2578
|
+
*
|
|
2579
|
+
* @remarks
|
|
2580
|
+
* The `overflow-clip-margin` property expands the clip edge of a `clip` overflow and of a paint
|
|
2581
|
+
* containment over a `visible` overflow and has no effect on an `overflow-y` value of the `hidden`
|
|
2582
|
+
* keyword, the `auto` keyword, or the `scroll` keyword, whose content stops at the padding box
|
|
2583
|
+
* whatever the property says. The computed value can carry a visual-box keyword beside the length,
|
|
2584
|
+
* so the length is read wherever it sits in the value.
|
|
2585
|
+
*
|
|
2586
|
+
* @example
|
|
2587
|
+
* ```ts
|
|
2588
|
+
* readClipMargin(build('div', { attributes: { style: 'overflow: clip; overflow-clip-margin: 20px' } })) // 20
|
|
2589
|
+
* ```
|
|
2590
|
+
*/
|
|
2591
|
+
function readClipMargin(element) {
|
|
2592
|
+
const overflow = readStyle(element, "overflow-y");
|
|
2593
|
+
if (overflow !== "clip" && !(overflow === "visible" && clipsOverflow(element))) return 0;
|
|
2594
|
+
const length = /(-?\d*\.?\d+)px/u.exec(readStyle(element, "overflow-clip-margin"));
|
|
2595
|
+
return length === null ? 0 : Number.parseFloat(length[1] ?? "0");
|
|
2596
|
+
}
|
|
2597
|
+
/**
|
|
2598
|
+
* Reports whether an element clips its descendants' overflow.
|
|
2599
|
+
*
|
|
2600
|
+
* @param element - The element to read.
|
|
2601
|
+
* @returns True if the element's computed `overflow-y` value is other than the `visible` keyword or
|
|
2602
|
+
* its computed `contain` value carries paint containment (the `paint` keyword, the `content`
|
|
2603
|
+
* keyword, or the `strict` keyword); false otherwise.
|
|
2604
|
+
*
|
|
2605
|
+
* @remarks
|
|
2606
|
+
* A scroll container (the `auto` keyword or the `scroll` keyword) keeps what overflows inside its
|
|
2607
|
+
* own scrollable area, and a clipping one (the `hidden` keyword or the `clip` keyword) and a
|
|
2608
|
+
* paint-contained one discard it, so in every case the rows a descendant lays out past the
|
|
2609
|
+
* element's clip edge, which the {@link readClipEdge} helper measures, are no part of the
|
|
2610
|
+
* document's content edge. The vertical axis alone decides, because the `overflow-x` property and
|
|
2611
|
+
* the `overflow-y` property compute independently under the `clip` keyword, and a horizontal clip
|
|
2612
|
+
* ends nothing below the element.
|
|
2613
|
+
*
|
|
2614
|
+
* @example
|
|
2615
|
+
* ```ts
|
|
2616
|
+
* clipsOverflow(build('div', { attributes: { style: 'overflow: clip' } })) // true
|
|
2617
|
+
* clipsOverflow(build('div')) // false
|
|
2618
|
+
* ```
|
|
2619
|
+
*/
|
|
2620
|
+
function clipsOverflow(element) {
|
|
2621
|
+
return readStyle(element, "overflow-y") !== "visible" || /\b(?:paint|content|strict)\b/u.test(readStyle(element, "contain"));
|
|
2622
|
+
}
|
|
2623
|
+
/**
|
|
2405
2624
|
* Measures the row the document's own content ends on, in document coordinates.
|
|
2406
2625
|
*
|
|
2407
2626
|
* @returns The content edge, rounded up to a whole row.
|
|
@@ -2417,11 +2636,21 @@ function readPixels(element, property, pseudo) {
|
|
|
2417
2636
|
* against the viewport answers what that viewport actually laid out.
|
|
2418
2637
|
*
|
|
2419
2638
|
* Each element contributes its client rectangle's bottom edge in document coordinates plus its own
|
|
2420
|
-
* bottom margin, which sits outside that rectangle, and the largest contribution wins.
|
|
2421
|
-
*
|
|
2422
|
-
*
|
|
2423
|
-
*
|
|
2424
|
-
*
|
|
2639
|
+
* bottom margin, which sits outside that rectangle, and the largest contribution wins. An ancestor
|
|
2640
|
+
* that clips its overflow caps the contribution at that ancestor's clip edge, which the
|
|
2641
|
+
* {@link readClipEdge} helper measures, because the rows a descendant lays out past a clipping
|
|
2642
|
+
* frame are cut, scrolled, or discarded rather than added to the document: a viewport-height
|
|
2643
|
+
* specimen inside a bounded frame ends, for this reading, where the frame ends, so a taller pane
|
|
2644
|
+
* does not read back as a taller document. The clip edge of a `clip` overflow, and of a paint
|
|
2645
|
+
* containment over a `visible` overflow, is read from the box the frame's `overflow-clip-margin`
|
|
2646
|
+
* value selects, the padding box by default, and expanded by that value's length; a hidden or
|
|
2647
|
+
* scrolling frame stops at its padding box. The frame's own contribution stays its border-box
|
|
2648
|
+
* bottom plus its bottom margin, so a bordered frame still ends the reading under its border.
|
|
2649
|
+
* Taking the largest is what handles a collapsed margin without asking whether it collapsed: a
|
|
2650
|
+
* child margin that collapses out through its parent is counted once, at the child, and one the
|
|
2651
|
+
* parent's padding holds in is counted once, at the parent. The body's and the root's own bottom
|
|
2652
|
+
* padding and margin sit under every child rather than beside them, so they are added after the
|
|
2653
|
+
* walk.
|
|
2425
2654
|
*
|
|
2426
2655
|
* The sum is rounded up because a box can end part way through a row and a frame cannot hold part
|
|
2427
2656
|
* of one.
|
|
@@ -2434,7 +2663,11 @@ function readPixels(element, property, pseudo) {
|
|
|
2434
2663
|
function measureContent() {
|
|
2435
2664
|
let edge = 0;
|
|
2436
2665
|
for (const element of document.body.querySelectorAll("*")) {
|
|
2437
|
-
|
|
2666
|
+
let bottom = element.getBoundingClientRect().bottom + window.scrollY + readPixels(element, "margin-bottom");
|
|
2667
|
+
for (let frame = element.parentElement; frame !== null && frame !== document.body; frame = frame.parentElement) {
|
|
2668
|
+
const limit = readClipEdge(frame);
|
|
2669
|
+
if (limit !== void 0 && limit < bottom) bottom = limit;
|
|
2670
|
+
}
|
|
2438
2671
|
if (bottom > edge) edge = bottom;
|
|
2439
2672
|
}
|
|
2440
2673
|
return Math.ceil(edge + readPixels(document.body, "padding-bottom") + readPixels(document.body, "margin-bottom") + readPixels(document.documentElement, "padding-bottom") + readPixels(document.documentElement, "margin-bottom"));
|
|
@@ -2552,17 +2785,20 @@ async function releasePane() {
|
|
|
2552
2785
|
if (Number.isFinite(width) && Number.isFinite(height)) await page.viewport(width, height);
|
|
2553
2786
|
}
|
|
2554
2787
|
/**
|
|
2555
|
-
* Stages the tester's print medium
|
|
2788
|
+
* Stages the tester's print medium, motion preference, and forced colours through the browser
|
|
2789
|
+
* provider.
|
|
2556
2790
|
*
|
|
2557
2791
|
* @param options - The media axes to override.
|
|
2558
|
-
* @returns A promise resolving after a bounded read-back for `print: true`
|
|
2559
|
-
* `
|
|
2792
|
+
* @returns A promise resolving after a bounded read-back for `print: true`, either `motion` value,
|
|
2793
|
+
* and either `forced` value. A `print: false` stage is sent and followed by a frame wait without a
|
|
2794
|
+
* read-back.
|
|
2560
2795
|
* @throws Thrown when no axis is supplied or a staged query does not reach the tester.
|
|
2561
2796
|
*
|
|
2562
2797
|
* @remarks
|
|
2563
2798
|
* If `print` is true, uses print; if false, uses screen. If `motion` is true, uses no preference;
|
|
2564
|
-
* if false, uses reduced motion.
|
|
2565
|
-
*
|
|
2799
|
+
* if false, uses reduced motion. If `forced` is true, uses active forced colours; if false, uses
|
|
2800
|
+
* none. The print medium, reduced motion, colour scheme, and forced colours keep their effective
|
|
2801
|
+
* readings when omitted. Any other emulated feature the provider configured
|
|
2566
2802
|
* is cleared. Each staged query waits up to 1000 milliseconds, polling every 10 milliseconds.
|
|
2567
2803
|
* A refused read-back restores the carried pre-call readings before throwing and can take two
|
|
2568
2804
|
* budgets. A restoration failure is attached as the refusal's cause. Register
|
|
@@ -2577,16 +2813,17 @@ async function releasePane() {
|
|
|
2577
2813
|
async function stageMedia(options) {
|
|
2578
2814
|
const print = options.print;
|
|
2579
2815
|
const motion = options.motion;
|
|
2580
|
-
|
|
2816
|
+
const forced = options.forced;
|
|
2817
|
+
if (print === void 0 && motion === void 0 && forced === void 0) throw new Error("Media emulation was staged with nothing to emulate");
|
|
2581
2818
|
const media = matchMedia("print").matches ? "print" : "screen";
|
|
2582
2819
|
const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
2583
2820
|
const dark = matchMedia("(prefers-color-scheme: dark)").matches;
|
|
2584
|
-
const
|
|
2821
|
+
const active = matchMedia("(forced-colors: active)").matches;
|
|
2585
2822
|
if (!document.documentElement.hasAttribute("data-media-stage")) document.documentElement.setAttribute(MEDIA_STAGE, [
|
|
2586
2823
|
media === "print",
|
|
2587
2824
|
reduced,
|
|
2588
2825
|
dark,
|
|
2589
|
-
|
|
2826
|
+
active
|
|
2590
2827
|
].map(Number).join(""));
|
|
2591
2828
|
const features = [
|
|
2592
2829
|
{
|
|
@@ -2595,7 +2832,7 @@ async function stageMedia(options) {
|
|
|
2595
2832
|
},
|
|
2596
2833
|
{
|
|
2597
2834
|
name: "forced-colors",
|
|
2598
|
-
value:
|
|
2835
|
+
value: active ? "active" : "none"
|
|
2599
2836
|
},
|
|
2600
2837
|
{
|
|
2601
2838
|
name: "prefers-reduced-motion",
|
|
@@ -2605,11 +2842,15 @@ async function stageMedia(options) {
|
|
|
2605
2842
|
const queries = [];
|
|
2606
2843
|
if (print === true) queries.push("print");
|
|
2607
2844
|
if (motion !== void 0) queries.push(`(prefers-reduced-motion: ${motion ? "no-preference" : "reduce"})`);
|
|
2845
|
+
if (forced !== void 0) queries.push(`(forced-colors: ${forced ? "active" : "none"})`);
|
|
2608
2846
|
await sendProtocol("Emulation.setEmulatedMedia", {
|
|
2609
2847
|
media: print === void 0 ? media : print ? "print" : "screen",
|
|
2610
2848
|
features: features.map((feature) => feature.name === "prefers-reduced-motion" && motion !== void 0 ? {
|
|
2611
2849
|
name: feature.name,
|
|
2612
2850
|
value: motion ? "no-preference" : "reduce"
|
|
2851
|
+
} : feature.name === "forced-colors" && forced !== void 0 ? {
|
|
2852
|
+
name: feature.name,
|
|
2853
|
+
value: forced ? "active" : "none"
|
|
2613
2854
|
} : feature)
|
|
2614
2855
|
});
|
|
2615
2856
|
await waitForFrame();
|
|
@@ -3531,6 +3772,6 @@ function createHarness(options) {
|
|
|
3531
3772
|
};
|
|
3532
3773
|
}
|
|
3533
3774
|
//#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 };
|
|
3775
|
+
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, clipsOverflow, 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, readClipEdge, readClipMargin, 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
3776
|
|
|
3536
3777
|
//# sourceMappingURL=index.js.map
|