fix(accessibility): don't filter everything when the page has a title (#2909)

This commit is contained in:
Joel Einbinder 2020-07-17 10:48:50 -07:00 committed by GitHub
parent d8bedd851d
commit 9140063c90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View file

@ -145,7 +145,7 @@ class CRAXNode implements accessibility.AXNode {
// Here and below: Android heuristics
if (this._hasFocusableChild())
return false;
if (this._focusable && this._name)
if (this._focusable && this._role !== 'WebArea' && this._name)
return true;
if (this._role === 'heading' && this._name)
return true;

View file

@ -148,7 +148,7 @@ class FFAXNode implements accessibility.AXNode {
// Here and below: Android heuristics
if (this._hasFocusableChild())
return false;
if (this._focusable && this._name)
if (this._focusable && this._role !== 'document' && this._name)
return true;
if (this._role === 'heading' && this._name)
return true;

View file

@ -347,4 +347,13 @@ describe('Accessibility', function() {
});
});
});
it('should work when there is a title ', async ({page}) => {
await page.setContent(`
<title>This is the title</title>
<div>This is the content</div>
`);
const snapshot = await page.accessibility.snapshot();
expect(snapshot.name).toBe('This is the title');
expect(snapshot.children[0].name).toBe('This is the content');
});
});