* Einmal mit der Tabulatortaste durch den Zustand. * * Gemessen werden drei Dinge: die Reihenfolge (folgt sie dem Dokument), die * Falle (kommt Tab aus einem Element nicht mehr heraus) und der Fokusring (ist * an dem Element, auf dem der Fokus steht, ueberhaupt etwas anders als vorher). * Der d
(page, expected)
| 4650 | * Skript ist fuer diese Frage nicht dasselbe. |
| 4651 | */ |
| 4652 | async function tabWalk(page, expected) { |
| 4653 | const resting = await page.evaluate( |
| 4654 | ({ selector, exclusions }) => { |
| 4655 | const out = {}; |
| 4656 | for (const node of document.querySelectorAll(selector)) { |
| 4657 | if (globalThis.__w12.excluded(node, exclusions) || !globalThis.__w12.shown(node)) { |
| 4658 | continue; |
| 4659 | } |
| 4660 | const entry = globalThis.__w12.describe(node); |
| 4661 | out[entry.selector + '#' + entry.nth] = globalThis.__w12.styleOf(node); |
| 4662 | } |
| 4663 | return out; |
| 4664 | }, |
| 4665 | { selector: CONTROL_SELECTOR, exclusions: COLLECT_EXCLUSIONS.map((entry) => entry.selector) }, |
| 4666 | ); |
| 4667 | |
| 4668 | const order = await page.evaluate( |
| 4669 | ({ selector, exclusions }) => { |
| 4670 | const out = []; |
| 4671 | for (const node of document.querySelectorAll(selector)) { |
| 4672 | if (globalThis.__w12.excluded(node, exclusions) || !globalThis.__w12.shown(node)) { |
| 4673 | continue; |
| 4674 | } |
| 4675 | if (node.tabIndex < 0) { |
| 4676 | continue; |
| 4677 | } |
| 4678 | const entry = globalThis.__w12.describe(node); |
| 4679 | out.push(entry.selector + '#' + entry.nth); |
| 4680 | } |
| 4681 | return out; |
| 4682 | }, |
| 4683 | { selector: CONTROL_SELECTOR, exclusions: COLLECT_EXCLUSIONS.map((entry) => entry.selector) }, |
| 4684 | ); |
| 4685 | |
| 4686 | const positive = await page.evaluate(() => |
| 4687 | [...document.querySelectorAll('[tabindex]')] |
| 4688 | .filter((node) => node.tabIndex > 0) |
| 4689 | .map((node) => node.getAttribute('data-testid') ?? node.tagName)); |
| 4690 | |
| 4691 | await page.evaluate(() => { |
| 4692 | if (document.activeElement instanceof HTMLElement) { |
| 4693 | document.activeElement.blur(); |
| 4694 | } |
| 4695 | }); |
| 4696 | |
| 4697 | const visited = []; |
| 4698 | const focusVisible = {}; |
| 4699 | let trap = false; |
| 4700 | let trapAt = ''; |
| 4701 | let stuck = 0; |
| 4702 | let previous = ''; |
| 4703 | const budget = Math.min(260, Math.max(60, (expected + 12) * 2)); |
| 4704 | for (let step = 0; step < budget; step += 1) { |
| 4705 | await page.keyboard.press('Tab'); |
| 4706 | const active = await page.evaluate(() => globalThis.__w12.active()); |
| 4707 | if (active.body) { |
| 4708 | previous = ''; |
| 4709 | stuck = 0; |