Skip to content

Commit a51dc50

Browse files
fix(accessibiltiy): ignore new roles that came with new chromium (#6329)
1 parent f4b8c3a commit a51dc50

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/server/chromium/crAccessibility.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class CRAXNode implements accessibility.AXNode {
7575
private _isTextOnlyObject(): boolean {
7676
const role = this._role;
7777
return (role === 'LineBreak' || role === 'text' ||
78-
role === 'InlineTextBox');
78+
role === 'InlineTextBox' || role === 'StaticText');
7979
}
8080

8181
private _hasFocusableChild(): boolean {
@@ -145,7 +145,7 @@ class CRAXNode implements accessibility.AXNode {
145145
// Here and below: Android heuristics
146146
if (this._hasFocusableChild())
147147
return false;
148-
if (this._focusable && this._role !== 'WebArea' && this._name)
148+
if (this._focusable && this._role !== 'WebArea' && this._role !== 'RootWebArea' && this._name)
149149
return true;
150150
if (this._role === 'heading' && this._name)
151151
return true;
@@ -199,6 +199,17 @@ class CRAXNode implements accessibility.AXNode {
199199
return this.isLeafNode() && !!this._name;
200200
}
201201

202+
normalizedRole() {
203+
switch (this._role) {
204+
case 'RootWebArea':
205+
return 'WebArea';
206+
case 'StaticText':
207+
return 'text';
208+
default:
209+
return this._role;
210+
}
211+
}
212+
202213
serialize(): types.SerializedAXNode {
203214
const properties: Map<string, number | string | boolean> = new Map();
204215
for (const property of this._payload.properties || [])
@@ -207,7 +218,7 @@ class CRAXNode implements accessibility.AXNode {
207218
properties.set('description', this._payload.description.value);
208219

209220
const node: {[x in keyof types.SerializedAXNode]: any} = {
210-
role: this._role,
221+
role: this.normalizedRole(),
211222
name: this._payload.name ? (this._payload.name.value || '') : '',
212223
};
213224

@@ -236,7 +247,7 @@ class CRAXNode implements accessibility.AXNode {
236247
for (const booleanProperty of booleanProperties) {
237248
// WebArea's treat focus differently than other nodes. They report whether their frame has focus,
238249
// not whether focus is specifically on the root node.
239-
if (booleanProperty === 'focused' && this._role === 'WebArea')
250+
if (booleanProperty === 'focused' && (this._role === 'WebArea' || this._role === 'RootWebArea'))
240251
continue;
241252
const value = properties.get(booleanProperty);
242253
if (!value)

0 commit comments

Comments
 (0)