feat: add page.accessibility CDP domain API#595
Open
myabc wants to merge 1 commit into
Open
Conversation
page.accessibility CDP domain APIpage.accessibility CDP domain API
There was a problem hiding this comment.
Pull request overview
This PR introduces a first-class page.accessibility domain API for interacting with Chrome DevTools Protocol (CDP) Accessibility domain data through Ferrum, plus a Node#axnode convenience accessor and accompanying RBS + specs.
Changes:
- Add
Ferrum::Accessibility(domain wrapper) andFerrum::Accessibility::AXNode(value object) to encapsulate CDP Accessibility queries. - Expose the API via
Page#accessibility,Browser#accessibilitydelegation, andNode#axnode. - Add unit + browser-driven specs, test fixture pages, and update RBS + CHANGELOG.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/unit/accessibility/ax_node_spec.rb | Adds unit coverage for AXNode behavior and immutability. |
| spec/support/views/accessibility.erb | Adds a fixture page for accessibility tree querying tests. |
| spec/support/views/accessibility_iframe.erb | Adds an iframe fixture page for cross-frame accessibility tests. |
| spec/support/views/accessibility_iframe_child.erb | Adds iframe child content for frame-resident node accessibility tests. |
| spec/node_spec.rb | Adds integration coverage for Node#axnode. |
| spec/accessibility_spec.rb | Adds browser-driven coverage for page.accessibility APIs (node_for/partial_tree/query/root/value, incl. iframe). |
| sig/ferrum/page.rbs | Exposes Page#accessibility in RBS. |
| sig/ferrum/node.rbs | Exposes Node#axnode in RBS. |
| sig/ferrum/accessibility/ax_node.rbs | Adds RBS signature for Accessibility::AXNode. |
| sig/ferrum/accessibility.rbs | Adds RBS signature for Ferrum::Accessibility. |
| lib/ferrum/page.rb | Wires Accessibility into Page initialization and adds accessor docs. |
| lib/ferrum/node.rb | Adds Node#axnode convenience method. |
| lib/ferrum/browser.rb | Delegates accessibility from Browser to the current page. |
| lib/ferrum/accessibility/ax_node.rb | Implements AXNode value object and deep-freeze. |
| lib/ferrum/accessibility.rb | Implements the Accessibility domain wrapper methods. |
| CHANGELOG.md | Documents the new page.accessibility API and Node#axnode. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
73968b8 to
2ba5186
Compare
Expose a first-class `page.accessibility` domain object (mirroring Ferrum::Network) wrapping the CDP Accessibility domain, replacing ad-hoc `Accessibility.getPartialAXTree` command calls downstream. - Ferrum::Accessibility (page.accessibility, delegated as browser.accessibility): node_for, partial_tree, snapshot, query, root, enable/disable. Node-scoped commands run on the node's own page so they resolve correctly across same-process iframes. - Ferrum::Accessibility::AXNode value object: role, name, description, value, properties, ignored?, ignored_reasons, node_id, backend_dom_node_id, child_ids, to_h. Params are deep-frozen for immutability; value is untyped since CDP AXValue.value may be a string, number, or boolean. - Ferrum::Node#axnode convenience, mirroring #computed_style. Adds RBS signatures, specs (unit and browser-driven, including subtree scoping and iframe coverage), fixtures, and a CHANGELOG entry.
2ba5186 to
f93a0ac
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Reading an element's computed accessibility properties (role, name, description, ARIA state) under Ferrum means reaching past the public API into raw CDP:
This leaks the CDP wire shape into callers, is undiscoverable, and leaves no home for the rest of the Accessibility domain.
Fix
Add a first-class
page.accessibilitydomain object, mirroringFerrum::Network:node_for,partial_tree,snapshot,query,root,enable/disable. Node-scoped commands run on the node's own page, so they resolve correctly across same-process iframes.Ferrum::Accessibility::AXNodevalue object wraps a CDP AXNode:role,name,description,value,properties,ignored?,ignored_reasons,node_id,backend_dom_node_id,child_ids,to_h. Params are deep-frozen;valueisuntypedsince CDPAXValue.valuemay be a string, number, or boolean.Ferrum::Node#axnodeconvenience, mirroring#computed_style.Query commands work without
Accessibility.enable(that governs live events only);enable/disableare thin wrappers.rootusesgetFullAXTree(depth: 1)andqueryfalls back to the document root node id, because CDPgetRootAXNode/queryAXTreerequire those respectively.Testing
RBS signatures plus unit and browser-driven specs, including subtree-scoping proof and same-process iframe coverage for
node_for,partial_tree, andquery. CHANGELOG updated.Downstream validation
🤖 Validated against a real consumer:
capybara_accessible_selectors#157(Cuprite driver support) resolves computedname/role/descriptionfrom the accessibility tree.Swapping its hand-rolled
Accessibility.getPartialAXTree+ ignored-node filtering + hash-digging fornode.axnode&.name/.role/.descriptionremoved the raw-CDP coupling entirely. Full suite green on Cuprite — 1813 examples, 0 failures.Before:
After: