Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(accessibility): snapshot the accessibility tree #3470

Merged
merged 11 commits into from Nov 2, 2018

Conversation

JoelEinbinder
Copy link
Collaborator

This adds page.accessibility.snapshot(). It serializes and returns the accessibility tree for the page. By default, uninteresting nodes are filtered out of the snapshot.

fixes #2033

docs/api.md Outdated Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
docs/api.md Show resolved Hide resolved
docs/api.md Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
lib/Accessibility.js Outdated Show resolved Hide resolved
lib/Accessibility.js Show resolved Hide resolved
lib/Accessibility.js Show resolved Hide resolved
* @return {boolean}
*/
_isPlainTextField() {
if (this._richlyEditable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get a test for this? a

*/
_hasFocusableChild() {
for (const child of this._children) {
if (child._focusable || child._hasFocusableChild())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O(n^2)!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cached

const {it, fit, xit} = testRunner;
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;

fdescribe('Accessibility', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'll probably won't happy...

docs/api.md Outdated
@@ -3431,3 +3502,5 @@ TimeoutError is emitted whenever certain operations are terminated due to timeou
[UnixTime]: https://en.wikipedia.org/wiki/Unix_time "Unix Time"
[SecurityDetails]: #class-securitydetails "SecurityDetails"
[Worker]: #class-worker "Worker"
[Accessibility]: #class-accessibility "Accessibility"
[AXNode]: #accessibilitysnapshotoptions "Accessibility"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AXNode

docs/api.md Outdated
An example of logging the focused node's name:
```js
const snapshot = await page.accessibility.snapshot();
const node = findNode(snapshot, node => node.focused);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findFocusedNode?

@JoelEinbinder
Copy link
Collaborator Author

The heuristics don't seem very accurate, especially with regards to editable nodes. I'm going to write some more tests and compare against NVDA on windows.

@@ -1982,6 +1988,71 @@ Shortcut for [(await worker.executionContext()).evaluateHandle(pageFunction, ...
#### worker.url()
- returns: <[string]>

### class: Accessibility
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might have wildly different output.

Blink - Chrome's rendering engine - has a concept of "accessibility tree", which is than translated into different platform-specific APIs. Accessibility namespace gives users
access to the Blink Accessibility Tree.

Most of the accessibility tree gets filtered out when converting from Blink AX Tree to Platform-specific AX-Tree or by screen readers themselves. By default, Puppeteer tries to approximate this filtering, exposing only the "interesting" nodes of the tree.

break;
}

if (this._role === 'combobox' && !this._expanded)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Here and below: android heuristics

docs/api.md Outdated Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
@aslushnikov aslushnikov merged commit 9ba3261 into puppeteer:master Nov 2, 2018
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.

Feature request: Inspect screen reader output
3 participants