Skip to content

fix(audit_keyboard): resolve every aria-labelledby id reference - #280

Merged
JustasMonkev merged 2 commits into
mainfrom
claude/tender-ramanujan-wr347b
Oct 16, 2026
Merged

JustasMonkev merged 2 commits into
mainfrom
claude/tender-ramanujan-wr347b

Conversation

@JustasMonkev

@JustasMonkev JustasMonkev commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Upstream change

In roleUtils.ts, upstream used to split ID reference lists with split(' '). It now splits them on ASCII whitespace (/[ \t\n\f\r]+/), so tab- and newline-separated aria-labelledby and aria-describedby lists resolve.   still does not count as a separator.

Why it matters here

The upstream fix reaches our snapshots only when we upgrade Playwright. But audit_keyboard computes its own accessible name inside the page (src/tools/auditKeyboard.ts), and that code had a worse version of the same bug: it passed the whole aria-labelledby value to document.getElementById. So aria-labelledby="verb noun" resolved to nothing, and the stop fell back to its title or text content. That wrong name shows up in the report and the step lines. It also feeds buildFingerprint (used for loop detection) and skip-link detection.

Fix

  • Split aria-labelledby on ASCII whitespace, the same way upstream does, and join the trimmed text of every referenced element that resolves.
  • Look up IDs with the element's own getRootNode(), the same as upstream. This does not add shadow-DOM support: the probe starts from document.activeElement, which stops at a shadow host, so focus inside a shadow root is still out of scope.
  • The rest of the fallback order is unchanged: aria-label → labelledby → title → <label> → text.

Tests

  • New integration test in tests/tools-auditKeyboard.integration.test.ts: a button with aria-labelledby=" verb\tnoun missing ". It is now named Save draft. On main the test fails with expected 'Fallback text' to be 'Save draft'.
  • All 46 tests in tests/tools-auditKeyboard* pass, and npm run lint is clean. I ran the integration tests on the sandbox's Chromium 1194 (PLAYWRIGHT_MCP_EXECUTABLE_PATH, PLAYWRIGHT_MCP_SANDBOX=false).

Other upstream MCP commits reviewed since #277 (no action)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Cu5QoT8BnTsfG9oqYzX1TK

aria-labelledby is a list of IDs separated by ASCII whitespace, but the
keyboard audit passed the whole attribute to getElementById. A control
labelled by more than one element (or with stray whitespace) got no
labelledby name and fell back to its title or text content, which also
feeds stop fingerprints and skip-link detection.

Split the list on ASCII whitespace like upstream Playwright now does
(microsoft/playwright#43361), resolve each ID in the element's own tree
root, and join the referenced texts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cu5QoT8BnTsfG9oqYzX1TK
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T03:29:15.620327Z fc2d1d0 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8ca8e89e-9d60-4907-b946-24ca84091d12
📥 Commits

Reviewing files that changed from the base of the PR and between 52e1783 and 36146d4.

📒 Files selected for processing: 2
  • src/tools/auditKeyboard.ts
  • tests/tools-auditKeyboard.integration.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The keyboard focus probe now resolves whitespace-separated aria-labelledby IDs in the focused element’s own tree and combines their text for the accessible-name fallback. An integration test checks the resulting stop name.

Changes: Accessible name resolution

Layer / File(s) Summary
Resolve label references
src/tools/auditKeyboard.ts, tests/tools-auditKeyboard.integration.test.ts
The probe resolves each referenced ID and joins the trimmed text. The fixture and integration test cover whitespace-separated IDs, a missing ID, and the expected name Save draft.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: claude

Merge Risk: ⚪ Minimal · up to 36146

The label-reference change and its integration test present no identified merge-blocking risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: resolving every ID referenced by aria-labelledby in audit_keyboard.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread src/tools/auditKeyboard.ts Resolved
The focus probe reads document.activeElement, which stops at a shadow
host, so references inside shadow roots are never reached.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cu5QoT8BnTsfG9oqYzX1TK
@JustasMonkev
JustasMonkev merged commit f482a77 into main Oct 16, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants