fix(accessibility): firefox with aria-invalid element (#29462)

Fixes https://github.com/microsoft/playwright/issues/29459
This commit is contained in:
Max Schmitt 2024-02-12 21:12:31 +01:00 committed by GitHub
parent 498b8bb269
commit fe81790221
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -245,7 +245,6 @@ class FFAXNode implements accessibility.AXNode {
const tokenProperties: Array<keyof channels.AXNode & keyof Protocol.Accessibility.AXTree> = [
'autocomplete',
'haspopup',
'invalid',
'orientation',
];
for (const tokenProperty of tokenProperties) {
@ -261,6 +260,8 @@ class FFAXNode implements accessibility.AXNode {
axNode.checked = this._payload.checked === true ? 'checked' : this._payload.checked === 'mixed' ? 'mixed' : 'unchecked';
if ('pressed' in this._payload)
axNode.pressed = this._payload.pressed === true ? 'pressed' : 'released';
if ('invalid' in this._payload)
axNode.invalid = this._payload.invalid === true ? 'true' : 'false';
return axNode;
}
}

View File

@ -348,3 +348,20 @@ it('should work when there is a title ', async ({ page }) => {
expect(snapshot.name).toBe('This is the title');
expect(snapshot.children[0].name).toBe('This is the content');
});
it('should work with aria-invalid accessibility tree', async ({ page, browserName, server }) => {
await page.goto(server.EMPTY_PAGE);
await page.setContent(`<a href="/hi" aria-invalid="true">WHO WE ARE</a>`);
expect(await page.accessibility.snapshot()).toEqual({
'role': browserName === 'firefox' ? 'document' : 'WebArea',
'name': '',
'children': [
{
'role': 'link',
'name': 'WHO WE ARE',
'invalid': 'true',
'value': browserName === 'firefox' ? `${server.PREFIX}/hi` : undefined
}
]
});
});