Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: revise interesting classification for AXNodes (#6334)
  • Loading branch information
johanbay committed Aug 14, 2020
1 parent 13ea347 commit 7b24e54
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion new-docs/puppeteer.snapshotoptions.interestingonly.md
Expand Up @@ -4,7 +4,7 @@

## SnapshotOptions.interestingOnly property

Prune unintersting nodes from the tree.
Prune uninteresting nodes from the tree.

<b>Signature:</b>

Expand Down
4 changes: 2 additions & 2 deletions new-docs/puppeteer.snapshotoptions.md
Expand Up @@ -15,6 +15,6 @@ export interface SnapshotOptions

| Property | Type | Description |
| --- | --- | --- |
| [interestingOnly](./puppeteer.snapshotoptions.interestingonly.md) | boolean | Prune unintersting nodes from the tree. |
| [root](./puppeteer.snapshotoptions.root.md) | [ElementHandle](./puppeteer.elementhandle.md) | Prune unintersting nodes from the tree. |
| [interestingOnly](./puppeteer.snapshotoptions.interestingonly.md) | boolean | Prune uninteresting nodes from the tree. |
| [root](./puppeteer.snapshotoptions.root.md) | [ElementHandle](./puppeteer.elementhandle.md) | Root node to get the accessibility tree for |

2 changes: 1 addition & 1 deletion new-docs/puppeteer.snapshotoptions.root.md
Expand Up @@ -4,7 +4,7 @@

## SnapshotOptions.root property

Prune unintersting nodes from the tree.
Root node to get the accessibility tree for

<b>Signature:</b>

Expand Down
15 changes: 7 additions & 8 deletions src/common/Accessibility.ts
Expand Up @@ -96,12 +96,12 @@ export interface SerializedAXNode {
*/
export interface SnapshotOptions {
/**
* Prune unintersting nodes from the tree.
* Prune uninteresting nodes from the tree.
* @defaultValue true
*/
interestingOnly?: boolean;
/**
* Prune unintersting nodes from the tree.
* Root node to get the accessibility tree for
* @defaultValue The root node of the entire page.
*/
root?: ElementHandle;
Expand Down Expand Up @@ -244,12 +244,14 @@ class AXNode {
private _hidden = false;
private _name: string;
private _role: string;
private _ignored: boolean;
private _cachedHasFocusableChild?: boolean;

constructor(payload: Protocol.Accessibility.AXNode) {
this.payload = payload;
this._name = this.payload.name ? this.payload.name.value : '';
this._role = this.payload.role ? this.payload.role.value : 'Unknown';
this._ignored = this.payload.ignored;

for (const property of this.payload.properties || []) {
if (property.name === 'editable') {
Expand All @@ -264,11 +266,7 @@ class AXNode {
private _isPlainTextField(): boolean {
if (this._richlyEditable) return false;
if (this._editable) return true;
return (
this._role === 'textbox' ||
this._role === 'ComboBox' ||
this._role === 'searchbox'
);
return this._role === 'textbox' || this._role === 'searchbox';
}

private _isTextOnlyObject(): boolean {
Expand Down Expand Up @@ -354,6 +352,7 @@ class AXNode {
case 'tab':
case 'textbox':
case 'tree':
case 'treeitem':
return true;
default:
return false;
Expand All @@ -362,7 +361,7 @@ class AXNode {

public isInteresting(insideControl: boolean): boolean {
const role = this._role;
if (role === 'Ignored' || this._hidden) return false;
if (role === 'Ignored' || this._hidden || this._ignored) return false;

if (this._focusable || this._richlyEditable) return true;

Expand Down

0 comments on commit 7b24e54

Please sign in to comment.