|
1 | | -export default async function test({ page, addFinding, url } = {}) { |
2 | | - console.log('test plugin'); |
3 | | - // Check for horizontal scrolling at 320x256 viewport |
| 1 | +export default async function reflowScan({ page, addFinding, url } = {}) { |
| 2 | + console.log('reflow plugin'); |
| 3 | + // Check for horizontal scrolling at 320x256 viewport |
4 | 4 | try { |
5 | 5 | await page.setViewportSize({ width: 320, height: 256 }); |
6 | 6 | const scrollWidth = await page.evaluate(() => document.documentElement.scrollWidth); |
7 | 7 | const clientWidth = await page.evaluate(() => document.documentElement.clientWidth); |
8 | 8 |
|
9 | 9 | // If horizontal scroll is required (with 1px tolerance for rounding) |
10 | 10 | if (scrollWidth > clientWidth + 1) { |
11 | | - const htmlSnippet = await page.evaluate(() => { |
12 | | - return `<html lang="${document.documentElement.lang || 'en'}">`; |
13 | | - }); |
14 | | - |
15 | | - addFinding({ |
16 | | - scannerType: 'viewport', |
17 | | - ruleId: 'horizontal-scroll-320x256', |
| 11 | + await addFinding({ |
| 12 | + scannerType: 'reflow-scan', |
18 | 13 | url, |
19 | | - html: htmlSnippet.replace(/'/g, "'"), |
20 | | - problemShort: 'page requires horizontal scrolling at 320x256 viewport', |
| 14 | + problemShort: 'Page requires horizontal scrolling at 320x256 viewport', |
21 | 15 | problemUrl: 'https://www.w3.org/WAI/WCAG21/Understanding/reflow.html', |
22 | | - solutionShort: 'ensure content is responsive and does not require horizontal scrolling at small viewport sizes', |
| 16 | + solutionShort: 'Ensure content is responsive and does not require horizontal scrolling at small viewport sizes', |
23 | 17 | solutionLong: `The page has a scroll width of ${scrollWidth}px but a client width of only ${clientWidth}px at 320x256 viewport, requiring horizontal scrolling. This violates WCAG 2.1 Level AA Success Criterion 1.4.10 (Reflow).` |
24 | 18 | }); |
25 | 19 | } |
26 | 20 | } catch (e) { |
27 | 21 | console.error('Error checking horizontal scroll:', e); |
28 | 22 | } |
29 | | - |
30 | 23 | } |
31 | 24 |
|
32 | | -export const name = 'test-plugin'; |
| 25 | +export const name = 'reflow-scan'; |
0 commit comments