Snapshot never shows checkbox/radio state on real Chrome: tristate AX values are strings, the renderer compares booleans
Problem
The accessibility snapshot is supposed to serialize form-control state (checked, selected, expanded, ...), but on real Chrome no checkbox or radio ever shows a state bit: a checked checkbox and an unchecked one render identical lines, and act check reports success with no change since last snapshot even though the state did change.
Root cause
checked is a CDP tristate property. Real Chrome sends it as a string:
{ "name": "checked", "value": { "type": "tristate", "value": "true" } }
(You can see this in the repo's own captured fixture: packages/browseros-agent/crates/browseros-core/tests/data/captured/form/get-full-ax-tree.json.) But both renderers only compare against JavaScript booleans:
packages/browseros-agent/packages/browser-core/src/core/snapshot/render.ts→formatStates():if (v === true) states.push('checked'),else if (v === 'mixed') ...packages/browseros-agent/crates/browseros-core/src/snapshot/render.rs→format_states():value == Some(&Value::Bool(true)),Value::String("mixed")
So "true"/"false" strings match neither branch and the state is silently dropped on real devices. Only the unit-test fixtures (which use real booleans) make it look like it works. Note selected/disabled/expanded are plain boolean/booleanOrUndefined and do render — only the tristate checked is affected.
Steps to reproduce
- Open
https://the-internet.herokuapp.com/checkboxes. - Snapshot; check the first checkbox via
act { kind: "check" }. - Snapshot again and read the diff.
Expected: the line gains a checked state (ideally checked/unchecked so "unchecked" is distinguishable from "no checked semantics"). Actual: identical lines, diff says no change.
Suggested fix
- Accept both shapes in
formatStates/format_states: booleans and"true"/"false"/"mixed"strings. - While here: report
uncheckedexplicitly (the AX property is always present for checkbox/radio/switch), and letstrVal/str_valfall back to numeric values sospinbutton/numberinputs don't lose their value (typeof value === 'string'currently drops them).
I have a small patch series that does exactly this (both renderers, plus tests) and would be happy to send a PR.