From acf110722003809a7a96d987f365b5d555aae17b Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Tue, 10 Dec 2024 14:04:18 -0800 Subject: [PATCH] chore: ignore checkbox/radio value in aria (#33941) --- .../src/server/injected/ariaSnapshot.ts | 6 ++++-- tests/page/page-aria-snapshot.spec.ts | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/playwright-core/src/server/injected/ariaSnapshot.ts b/packages/playwright-core/src/server/injected/ariaSnapshot.ts index d541646f0e..84537cddd7 100644 --- a/packages/playwright-core/src/server/injected/ariaSnapshot.ts +++ b/packages/playwright-core/src/server/injected/ariaSnapshot.ts @@ -158,8 +158,10 @@ function toAriaNode(element: Element): AriaNode | null { if (roleUtils.kAriaSelectedRoles.includes(role)) result.selected = roleUtils.getAriaSelected(element); - if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) - result.children = [element.value]; + if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) { + if (element.type !== 'checkbox' && element.type !== 'radio') + result.children = [element.value]; + } return result; } diff --git a/tests/page/page-aria-snapshot.spec.ts b/tests/page/page-aria-snapshot.spec.ts index 81e1beadfa..77dc45a01e 100644 --- a/tests/page/page-aria-snapshot.spec.ts +++ b/tests/page/page-aria-snapshot.spec.ts @@ -421,6 +421,18 @@ it('should treat input value as text in templates', async ({ page }) => { `); }); +it('should not use on as checkbox value', async ({ page }) => { + await page.setContent(` + + + `); + + await checkAndMatchSnapshot(page.locator('body'), ` + - checkbox + - radio + `); +}); + it('should respect aria-owns', async ({ page }) => { await page.setContent(`