From 9140063c90c0c9a901c88e8a7207e43e96be038b Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Fri, 17 Jul 2020 10:48:50 -0700 Subject: [PATCH] fix(accessibility): don't filter everything when the page has a title (#2909) --- src/chromium/crAccessibility.ts | 2 +- src/firefox/ffAccessibility.ts | 2 +- test/accessibility.jest.js | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/chromium/crAccessibility.ts b/src/chromium/crAccessibility.ts index fe3be4d201..b5eba7ab65 100644 --- a/src/chromium/crAccessibility.ts +++ b/src/chromium/crAccessibility.ts @@ -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; diff --git a/src/firefox/ffAccessibility.ts b/src/firefox/ffAccessibility.ts index dd9bf3570a..e757b05c28 100644 --- a/src/firefox/ffAccessibility.ts +++ b/src/firefox/ffAccessibility.ts @@ -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; diff --git a/test/accessibility.jest.js b/test/accessibility.jest.js index 508a4250ff..aedbb73ef8 100644 --- a/test/accessibility.jest.js +++ b/test/accessibility.jest.js @@ -347,4 +347,13 @@ describe('Accessibility', function() { }); }); }); + it('should work when there is a title ', async ({page}) => { + await page.setContent(` + This is the title +
This is the content
+ `); + const snapshot = await page.accessibility.snapshot(); + expect(snapshot.name).toBe('This is the title'); + expect(snapshot.children[0].name).toBe('This is the content'); + }); });