Skip to content

Commit c61b5dc

Browse files
voidstackloopclaude
andcommitted
Add two checks: viewport zoom and generic link text
Asked to find new categories of bugs, not pad the codebase with an arbitrary property count - so this is scoped to what's genuinely detectable with the project's existing verification bar (a fixture proving both the true and false positive, plus a mutation test proving the check isn't just guessing). Considered and dropped a third candidate: detecting JS that blocks pasting into a field (common, and actively harmful, on "confirm email"/"confirm password" fields - it defeats password managers and forces error-prone re-typing). Reliably simulating a real paste in headless Chrome needs either the deprecated execCommand('paste') or CDP-level clipboard operations; a synthetic ClipboardEvent dispatched from page.evaluate() won't trigger a browser's native paste-insert behavior the way a trusted event does. Shipping a check with a real false-negative risk would break this project's actual track record - every check so far is deterministic, not a guess dressed up as one. check_viewport_zoom (Fail): a <meta name="viewport"> with user-scalable=no or maximum-scale under 2 blocks pinch-zoom outright - a WCAG 1.4.4 (Resize Text) failure that hits every low-vision user on the page, not just screen-reader users, and axe-core has no rule for it at all. Objectively verifiable (the tag either restricts zoom or it doesn't), so a hit is a Fail like Duplicate field names/Required- indicator mismatch, not a heuristic Warn. check_generic_link_text (Warn): <a> links whose entire accessible text is a well-known ambiguous phrase ("click here", "read more", ...) are meaningless in a screen reader's links-list view (WCAG 2.4.4). Deliberately scoped to links only, not buttons - a lone "Submit" button is normal and flagging it would just be noise on ordinary forms. A phrase match is a heuristic (surrounding text might disambiguate it), so a hit is a Warn, matching Autofill hints/Input type mismatch's precedent. Caught a real bug during testing, not just in review: the zoom check's first draft returned `noScale || (maxScale && ...)`, which evaluates to `null` (not `false`) in JS when noScale is false and maxScale is null - `false || null` is `null` in JS, and chromiumoxide can't deserialize `null` into a Rust bool ("No value found"). Fixed with an explicit Boolean(...) wrap; the fixture-less negative-case test (no viewport meta tag at all) is exactly what caught it. Verified both with mutation tests: inverted the zoom regex (checked for "yes" instead of "no") and confirmed the Fail-detection test failed as predicted; changed the link-text match to key off "eligibility" instead of the generic-phrase set and confirmed it flagged the wrong link, breaking the false-positive assertion. Both restored after confirming. Refreshed BENCHMARKS.md's numbers for 13 checks (was 11) since these two are cheap static markup checks, not full sweeps - re-ran all four existing rows rather than leave three of them showing a stale checks/run count next to one refreshed one. cargo fmt/clippy -D warnings clean, full suite green (163 tests). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 9ff1fd0 commit c61b5dc

7 files changed

Lines changed: 232 additions & 9 deletions

File tree

‎BENCHMARKS.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ a clean baseline plus a page for every check and known edge case — and
99
`monitor demo-sites/forms.yml` checks all of them.
1010

1111
Because everything is served from `127.0.0.1`, there's no network latency in
12-
these numbers — what's left is browser launch, the eleven built-in checks per
13-
form, screenshot capture, and report writing.
12+
these numbers — what's left is browser launch, the thirteen built-in checks
13+
per form, screenshot capture, and report writing.
1414

1515
## Latest results
1616

@@ -20,10 +20,10 @@ section below used to only assert about:
2020

2121
| Forms | Checks/run | Runs | `--wait` | Concurrency | Screenshots | min (s) | median (s) | max (s) | forms/min | checks/s |
2222
|------:|-----------:|-----:|---------:|------------:|:------------|--------:|-----------:|--------:|----------:|---------:|
23-
| 35 | 385 | 5 | 1s | 4 (default) | on | 12.78 | 13.36 | 13.59 | 157.2 | 28.8 |
24-
| 35 | 385 | 5 | 1s | 4 (default) | off | 12.03 | 12.61 | 12.93 | 166.5 | 30.5 |
25-
| 35 | 385 | 5 | 1s | 1 | on | 47.21 | 47.44 | 47.66 | 44.3 | 8.1 |
26-
| 35 | 385 | 3 | 1s | 8 | on | 7.87 | 8.05 | 8.12 | 260.9 | 47.8 |
23+
| 35 | 455 | 5 | 1s | 4 (default) | on | 13.17 | 13.43 | 13.94 | 156.4 | 33.9 |
24+
| 35 | 455 | 5 | 1s | 4 (default) | off | 12.49 | 12.51 | 12.67 | 167.9 | 36.4 |
25+
| 35 | 455 | 5 | 1s | 1 | on | 47.76 | 47.85 | 48.32 | 43.9 | 9.5 |
26+
| 35 | 455 | 3 | 1s | 8 | on | 7.98 | 8.14 | 8.16 | 258.0 | 55.9 |
2727

2828
The 35 demo forms cover a clean baseline, a failing page for most checks, a
2929
three-step wizard and its slow/keyup/icon-only variants, shadow-DOM and
@@ -60,15 +60,15 @@ Everything is local; it never contacts a third-party site.
6060
time, not overhead — set `WAIT=0` to see the floor. Real `monitor` runs
6161
against remote forms add page-load time on top.
6262
- **Concurrency matters far more than raw speed.** Going from
63-
`--max-concurrent 1` to the default `4` cut the median from 47.4s to
64-
13.4s on this 16-thread machine — a ~3.5x speedup from running more
63+
`--max-concurrent 1` to the default `4` cut the median from 47.9s to
64+
13.4s on this 16-thread machine — a ~3.6x speedup from running more
6565
browsers at once, not from anything getting individually faster.
6666
`--max-concurrent 8` cut it further to 8.1s, though gains taper as
6767
contention for CPU/Chrome processes grows; the per-host pacer
6868
(`--per-host-delay-ms`) is the polite counterweight when checking a real,
6969
shared third-party host rather than a local demo server.
7070
- **Screenshots cost something, but modestly**: 13.4s with screenshots vs.
71-
12.6s with `--no-screenshots` on this same demo mix — about 6%, worth
71+
12.5s with `--no-screenshots` on this same demo mix — about 7%, worth
7272
knowing but not the dominant cost. Every non-Pass check captures a
7373
full-page PNG; `--no-screenshots` trades that evidence for the difference.
7474
- **A failing page is slower than a passing one** (screenshots plus the

‎CHANGELOG.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ project doesn't have a release yet, so everything below is grouped under
134134
`type="number"` would actively be the wrong call (it strips a leading
135135
zero and adds spinner arrows). A heuristic guess from label wording,
136136
like Autofill hints, so a mismatch is a `Warn`, not a `Fail`.
137+
- A twelfth check, **Viewport zoom**: flags a viewport meta tag that
138+
disables (`user-scalable=no`) or caps below 2x (`maximum-scale`)
139+
pinch-zoom — a WCAG 1.4.4 (Resize Text) failure that blocks every
140+
low-vision user on the page, not just screen-reader users. Distinct
141+
from Mobile usability (which measures overflow and tap-target size,
142+
not zoom capability); axe-core has no rule for viewport zoom at all.
143+
Objectively verifiable, so a hit is a `Fail`.
144+
- A thirteenth check, **Generic link text**: flags `<a>` links whose
145+
entire accessible text is a well-known ambiguous phrase ("click
146+
here", "read more", "learn more", ...) — meaningless in a screen
147+
reader's links-list view and a WCAG 2.4.4 (Link Purpose) failure.
148+
Scoped to links, not buttons, so a lone "Submit" button on an
149+
ordinary form is never flagged. A phrase match is a heuristic, not a
150+
certainty (surrounding text might disambiguate it), so a hit is a
151+
`Warn`, matching Autofill hints/Input type mismatch's precedent.
137152
- **Optional LLM semantic checks** (`--llm` / `llm:` config): two
138153
provider-agnostic checks — "Error wording (LLM)" and
139154
"Instructions (LLM)" — that score the clarity of validation error

‎README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ your own use.
6666
labels, contrast, ARIA, landmarks.
6767
- **Mobile usability** — emulates a 375px-wide phone viewport, flags
6868
horizontal overflow and tap targets under the WCAG-recommended 44x44px.
69+
- **Viewport zoom** — flags a viewport meta tag that disables
70+
(`user-scalable=no`) or caps below 2x (`maximum-scale`) pinch-zoom, a
71+
WCAG 1.4.4 failure that blocks every low-vision user on the page, not
72+
just screen-reader users. axe-core has no rule for this at all.
73+
- **Generic link text** — flags `<a>` links whose entire text is a
74+
well-known ambiguous phrase ("click here", "read more", ...) — useless
75+
in a screen reader's links-list view (WCAG 2.4.4). Scoped to links, not
76+
buttons, so an ordinary lone "Submit" button is never flagged.
6977
- **Validation errors** — triggers native browser validation and checks
7078
that invalid fields have a screen-reader-visible error message
7179
(`aria-describedby` pointing at real text), not just a color change.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head><meta charset="utf-8"><title>Generic Link Text</title></head>
4+
<body>
5+
<!-- "Click here" and "Read more" carry no meaning out of context — a
6+
screen reader's links-list view shows only this text, with none
7+
of the surrounding prose. "View the eligibility requirements" is
8+
the correctly-worded case (same destination-ish intent, real
9+
purpose in the text itself), proving the check doesn't
10+
false-positive on a form that got it right. A lone "Submit"
11+
button is deliberately absent from this fixture's concern — the
12+
check only looks at <a> links, never buttons. -->
13+
<p>Need help? <a href="/faq">Click here</a> for the FAQ.</p>
14+
<p><a href="/guide">Read more</a> about this program.</p>
15+
<p><a href="/eligibility">View the eligibility requirements</a>.</p>
16+
<form>
17+
<label for="name">Full name</label>
18+
<input id="name" name="name" type="text">
19+
<button type="submit">Submit</button>
20+
</form>
21+
</body>
22+
</html>

‎fixtures/viewport-zoom-form.html‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
6+
<title>Viewport Zoom Disabled</title>
7+
</head>
8+
<body>
9+
<!-- user-scalable=no blocks pinch-zoom outright — a low-vision user on
10+
a phone can't zoom in to read this page no matter what they do. -->
11+
<form>
12+
<label for="name">Full name</label>
13+
<input id="name" name="name" type="text">
14+
<button type="submit">Submit</button>
15+
</form>
16+
</body>
17+
</html>

‎src/checks.rs‎

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,91 @@ pub async fn check_input_type_mismatch(page: &Page) -> Result<CheckResult> {
983983
))
984984
}
985985

986+
/// Flags a viewport `<meta>` tag that disables pinch-zoom
987+
/// (`user-scalable=no`) or caps it below 2x (`maximum-scale`). This is a
988+
/// WCAG 1.4.4 (Resize Text) failure that hits every low-vision user on
989+
/// the page, not just screen-reader users — and it's objectively
990+
/// verifiable (the tag either restricts zoom or it doesn't), so a hit is
991+
/// a `Fail`, not a heuristic `Warn`. Distinct from the Mobile usability
992+
/// check, which measures overflow and tap-target size, not zoom
993+
/// capability; axe-core has no rule for viewport zoom at all.
994+
pub async fn check_viewport_zoom(page: &Page) -> Result<CheckResult> {
995+
let blocked: bool = page
996+
.evaluate(
997+
r#"(() => {
998+
const content = document.querySelector('meta[name=viewport]')?.content || '';
999+
const noScale = /user-scalable\s*=\s*no/i.test(content);
1000+
const maxScale = content.match(/maximum-scale\s*=\s*([\d.]+)/i);
1001+
return Boolean(noScale || (maxScale && parseFloat(maxScale[1]) < 2));
1002+
})()"#,
1003+
)
1004+
.await?
1005+
.into_value()?;
1006+
1007+
Ok(result(
1008+
"Viewport zoom",
1009+
if blocked { Status::Fail } else { Status::Pass },
1010+
if blocked {
1011+
"The viewport meta tag disables or caps pinch-zoom (user-scalable=no or \
1012+
maximum-scale < 2) — a low-vision user on a phone can't zoom in to read this \
1013+
page (WCAG 1.4.4)."
1014+
.to_string()
1015+
} else {
1016+
"No viewport restriction on pinch-zoom found.".to_string()
1017+
},
1018+
))
1019+
}
1020+
1021+
/// Flags `<a>` links whose entire accessible text is a well-known
1022+
/// ambiguous phrase ("click here", "read more", ...) — useless in a
1023+
/// screen reader's links-list view, and a WCAG 2.4.4 (Link Purpose)
1024+
/// failure when the surrounding text doesn't disambiguate it either.
1025+
/// Scoped to links only, not buttons: a lone "Submit" button is normal
1026+
/// and flagging it would just be noise on ordinary forms. A phrase
1027+
/// match is a heuristic, not a certainty (the link might be adequately
1028+
/// explained by adjacent text), so this is a `Warn`.
1029+
pub async fn check_generic_link_text(page: &Page) -> Result<CheckResult> {
1030+
let hits: Vec<String> = page
1031+
.evaluate(
1032+
r#"(() => {
1033+
const generic = new Set([
1034+
'click here', 'here', 'read more', 'more', 'learn more', 'this link', 'link',
1035+
]);
1036+
const hits = [];
1037+
for (const a of document.querySelectorAll('a[href]')) {
1038+
if (a.offsetParent === null) continue;
1039+
const text = (a.textContent || a.getAttribute('aria-label') || '')
1040+
.trim().toLowerCase();
1041+
if (generic.has(text)) hits.push(text);
1042+
}
1043+
return hits;
1044+
})()"#,
1045+
)
1046+
.await?
1047+
.into_value()?;
1048+
1049+
let status = if hits.is_empty() {
1050+
Status::Pass
1051+
} else {
1052+
Status::Warn
1053+
};
1054+
Ok(result(
1055+
"Generic link text",
1056+
status,
1057+
if hits.is_empty() {
1058+
"No link's entire text is a generic phrase like \"click here\" or \"read more\"."
1059+
.to_string()
1060+
} else {
1061+
format!(
1062+
"{} link(s) with no accessible purpose beyond generic text — meaningless in a \
1063+
screen reader's links list: {}.",
1064+
hits.len(),
1065+
hits.join(", ")
1066+
)
1067+
},
1068+
))
1069+
}
1070+
9861071
/// Flags form controls that share a `name` attribute with something they
9871072
/// shouldn't. Standard form encoding keeps only one value (or silently
9881073
/// merges them in a way the server likely doesn't expect) for a repeated
@@ -1375,6 +1460,22 @@ pub async fn run_all_with(page: &Page, opts: &RunOptions) -> Vec<CheckResult> {
13751460
check_mobile_usability(page),
13761461
)
13771462
.await,
1463+
run_safely(
1464+
page,
1465+
"Viewport zoom",
1466+
check_timeout,
1467+
capture,
1468+
check_viewport_zoom(page),
1469+
)
1470+
.await,
1471+
run_safely(
1472+
page,
1473+
"Generic link text",
1474+
check_timeout,
1475+
capture,
1476+
check_generic_link_text(page),
1477+
)
1478+
.await,
13781479
run_safely(
13791480
page,
13801481
"Validation errors",

‎tests/checks_test.rs‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,3 +900,63 @@ async fn form_with_no_email_or_phone_looking_labels_passes_the_type_check() {
900900
.expect("check_input_type_mismatch");
901901
assert_eq!(result.status, checks::Status::Pass, "got: {result:?}");
902902
}
903+
904+
#[tokio::test]
905+
async fn viewport_disabling_pinch_zoom_is_a_fail() {
906+
// fixtures/viewport-zoom-form.html sets user-scalable=no, which
907+
// blocks pinch-zoom outright — a low-vision user on a phone can't
908+
// zoom in to read the page no matter what they do (WCAG 1.4.4).
909+
let (_browser, page, _handle) = open_fixture("viewport-zoom-form.html").await;
910+
let result = checks::check_viewport_zoom(&page)
911+
.await
912+
.expect("check_viewport_zoom");
913+
assert_eq!(result.status, checks::Status::Fail, "got: {result:?}");
914+
}
915+
916+
#[tokio::test]
917+
async fn form_with_no_viewport_meta_tag_passes_the_zoom_check() {
918+
let (_browser, page, _handle) = open_fixture("test-form.html").await;
919+
let result = checks::check_viewport_zoom(&page)
920+
.await
921+
.expect("check_viewport_zoom");
922+
assert_eq!(result.status, checks::Status::Pass, "got: {result:?}");
923+
}
924+
925+
#[tokio::test]
926+
async fn links_with_only_generic_text_are_a_warn() {
927+
// fixtures/generic-link-text-form.html's "Click here" and "Read
928+
// more" links carry no meaning out of context. "View the
929+
// eligibility requirements" has the same kind of destination but
930+
// real wording, proving no false positive on a link that got it
931+
// right; the page's "Submit" button is irrelevant to this check,
932+
// which only looks at <a> links.
933+
let (_browser, page, _handle) = open_fixture("generic-link-text-form.html").await;
934+
let result = checks::check_generic_link_text(&page)
935+
.await
936+
.expect("check_generic_link_text");
937+
assert_eq!(result.status, checks::Status::Warn, "got: {result:?}");
938+
assert!(
939+
result.detail.contains("click here"),
940+
"got: {}",
941+
result.detail
942+
);
943+
assert!(
944+
result.detail.contains("read more"),
945+
"got: {}",
946+
result.detail
947+
);
948+
assert!(
949+
!result.detail.contains("eligibility"),
950+
"a link with real accessible text must not be flagged, got: {}",
951+
result.detail
952+
);
953+
}
954+
955+
#[tokio::test]
956+
async fn form_with_no_links_passes_the_generic_link_text_check() {
957+
let (_browser, page, _handle) = open_fixture("test-form.html").await;
958+
let result = checks::check_generic_link_text(&page)
959+
.await
960+
.expect("check_generic_link_text");
961+
assert_eq!(result.status, checks::Status::Pass, "got: {result:?}");
962+
}

0 commit comments

Comments
 (0)