fix(web): read visibility as rendered, null box, checkable values, embedded names
Web reads now report what renders, Playwright's way, and keep accessibility-tree exclusion separate. Fixes bug bash B51, B52, N46, N48, N49.
-
Render visibility vs a11y exclusion (
packages/web/src/in-page/read-semantics.ts):isHidden(states.hidden, sotoBeVisible/toBeHidden/isVisible/waitFor/visible: true) no longer treatsaria-hiddenas hidden. A decorative spinner markedaria-hiddenstays visible until it leaves.hidesSubtreestill dropsaria-hiddenand inert subtrees from the agent's observation, and role queries still skip them. -
content-visibility: hidden: content under it (slotted content included) reads hidden. The element keeps its own box. The tree walk does not descend into it, and the element reports none of its own text, which matches itsinnerText. -
N46: text directly under a
display: contents; visibility: hiddenelement reads hidden. It paints nothing, but Playwright calls it visible, so this is a deliberate difference, written down in the docs. -
N49:
visibility: hiddenno longer prunes the whole subtree in the tree walk, because a child can setvisibility: visibleand paint again.display: nonestill prunes. -
visible: truenarrowing: a new selector enginee2e-shown(packages/web/src/shown-selector.ts) runs the reader's ownhiddencheck inside Playwright's chain. It replacesfilter({ visible: true })plus the old:not([aria-hidden])step, sofirst(), filters, and scopes agree withtoBeVisible()by construction. -
B52:
rectisnullwhen the element has no layout box.boundingBox()on adisplay: nonenode therefore returnsnull, matching Playwright, not{0,0,0,0}.- A checkbox or radio now reports its DOM
value(onby default) in a locator read, whatever its checked state. The observation tree still leaves that value out, as it does for an option's. getByDisplayValueno longer treats checkboxes and radios as candidates.
-
N48: an embedded control now adds to an accessible name the way Playwright's role selector reads it:
- a textbox or searchbox adds its value
- a select or listbox adds its selected options
- a range widget adds
aria-valuetext, elsearia-valuenow, else itsvalue
A secure field adds nothing. Label text, which
getByLabelmatches, still leaves values out. 9 axe-core conformance cases now agree and were removed fromtests/conformance/expected.txt. -
Docs:
docs/reference/screen.mdxnow covers visibility semantics, anullbox, and checkable values. A row indocs/migrate/playwright.mdxnow saysselectOption('x')matches the label only, where Playwright matches the value or the label; the table had said "same". The skill text and a changeset are updated too.
Verified
Ran it locally: yes
The scratch project /tmp/oskar-fix-web-visibility-reads/ runs the real built CLI (node packages/e2e/dist/cli/bin.js run --reporter list) against a static server. main uses an @e2e-dev/web dist built from origin/main; the branch uses this branch's dist.
| case | main | this branch |
|---|---|---|
B51 toBeHidden on an aria-hidden spinner that is removed after 900ms | isVisible() is false on the rendered spinner, so toBeHidden passes at once | passes after 959ms, count 0 |
B51 button under content-visibility: hidden, toBeHidden | fails: observed visible | passes |
B52 boundingBox() on display: none | {"x":0,"y":0,"width":0,"height":0} | null |
B52 checkbox inputValue() / toHaveValue('on'), radio toHaveValue('monthly') | "", "not a form control" | on, passes |
N46 display: contents; visibility: hidden text, toBeHidden | fails: observed visible | passes |
N48 toHaveAccessibleName('Flash the screen 3 times') | "Flash the screen times" | passes, and getByRole finds it |
getByText('Save', { visible: true }).first() with a hidden display: contents twin first | picks the invisible twin | picks the button |
N49 agent observation (e2e mcp, observe) | button "Child visible" missing | listed |
The observation through e2e mcp on the same page:
main:
#n6004 text="Invisible text" testid="dc"
#n6005 button "Flash the screen times" testid="flash"
#n6006 textbox value="3"
#n6007 text="Plan"
branch:
#n6004 button "Flash the screen 3 times" text="Flash the screen times" testid="flash"
#n6005 textbox value="3"
#n6006 button "Child visible" testid="vischild"
#n6007 text="Plan"
Tests in packages/web/tests/integration/ check each case against Playwright as the oracle (isHidden(), boundingBox(), inputValue(), getByRole({ name, exact })): visibility.test.ts, read-node-names.test.ts, read-node-checked.test.ts, lifecycle.test.ts. Run against main's src, 12 of them fail. Also run:
pnpm check,pnpm test,pnpm test:testbed,pnpm test:web-benchmark: all pass.- Crosscheck against the benchmark (
CROSSCHECK_BENCHMARK_URL): passes.crosscheck/expected.txtis unchanged. - Web-benchmark
test:agentreplay: identical on main and this branch (25 replayed · 2 handed off · 4 missed, same 7 failures). The 7 come from no localAI_GATEWAY_API_KEY, so no committed recording changes.