From 2c05d294a8ea599e3db4f4bc55047e64bb3a2bd0 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 14 Oct 2024 15:55:21 -0700 Subject: [PATCH] chore: fix webkit visibility check in aria matcher (#33102) --- .../src/server/injected/ariaSnapshot.ts | 8 ++------ tests/page/to-match-aria-snapshot.spec.ts | 14 +++++++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/playwright-core/src/server/injected/ariaSnapshot.ts b/packages/playwright-core/src/server/injected/ariaSnapshot.ts index b573569f8f0b1..8e08ae70160d0 100644 --- a/packages/playwright-core/src/server/injected/ariaSnapshot.ts +++ b/packages/playwright-core/src/server/injected/ariaSnapshot.ts @@ -16,7 +16,7 @@ import { escapeWithQuotes } from '@isomorphic/stringUtils'; import { beginAriaCaches, endAriaCaches, getAriaRole, getElementAccessibleName, isElementIgnoredForAria } from './roleUtils'; -import { isElementVisible } from './domUtils'; +import { isElementVisible, isElementStyleVisibilityVisible } from './domUtils'; type AriaNode = { role: string; @@ -59,11 +59,7 @@ export function generateAriaTree(rootElement: Element): AriaNode { return; const visible = isElementVisible(element); - const hasVisibleChildren = element.checkVisibility({ - opacityProperty: true, - visibilityProperty: true, - contentVisibilityAuto: true - }); + const hasVisibleChildren = isElementStyleVisibilityVisible(element); if (!hasVisibleChildren) return; diff --git a/tests/page/to-match-aria-snapshot.spec.ts b/tests/page/to-match-aria-snapshot.spec.ts index d1e0d7b91ef07..826f8cc90e9af 100644 --- a/tests/page/to-match-aria-snapshot.spec.ts +++ b/tests/page/to-match-aria-snapshot.spec.ts @@ -94,8 +94,20 @@ test('should allow text nodes', async ({ page }) => { `); }); +test('details visibility', async ({ page, browserName }) => { + await page.setContent(` +
+ Summary +
Details
+
+ `); + + await expect(page.locator('body')).toMatchAriaSnapshot(` + - group: Summary + `); +}); + test('integration test', async ({ page, browserName }) => { - test.fixme(browserName === 'webkit'); await page.setContent(`

Microsoft

Open source projects and samples from Microsoft