playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Bug]: ariaSnapshot hides `visibility: visible` inside `visibility: hidden`

Open Skn0tt opened this issue 7 months ago • 2 comments

Version

tot

Steps to reproduce

it('repro', async ({ page }) => {
  await page.setContent(`
    <div style="visibility: hidden;">
      <div style="visibility: visible;">
        <button>Button</button>
      </div>
    </div>
  `);

  await checkAndMatchSnapshot(page.locator('body'), `
    - button "Button"
  `);
});

Expected behavior

I expect the inner button to be in the snapshot.

Actual behavior

The snapshot is empty.

Additional context

Chromium considers it visible:

Image

Maybe it's this case that we don't implement:

https://github.com/microsoft/playwright/blob/3c248ed163ff760eb064777130cfe9eb244a8323/packages/injected/src/roleUtils.ts#L263-L265

Environment

System:
    OS: macOS 15.5
    CPU: (12) arm64 Apple M3 Pro
    Memory: 145.89 MB / 18.00 GB
  Binaries:
    Node: 23.11.0 - ~/.local/state/fnm_multishells/12301_1749718398620/bin/node
    npm: 11.4.1 - ~/.local/state/fnm_multishells/12301_1749718398620/bin/npm
    pnpm: 10.6.5 - /opt/homebrew/bin/pnpm
  IDEs:
    VSCode: 1.100.3 - /opt/homebrew/bin/code
  Languages:
    Bash: 3.2.57 - /bin/bash

Skn0tt avatar Jun 12 '25 10:06 Skn0tt

This issue discusses the problem: https://github.com/w3c/aria/issues/1055

Going by that and Chromium, what we're observing seems like a bug. I'll take a stab at fixing.

Skn0tt avatar Jun 13 '25 07:06 Skn0tt

I put up a possible fix: https://github.com/microsoft/playwright/pull/36316 We'll need to think deep about the right spec interpretation though, before we ship that.

Skn0tt avatar Jun 16 '25 14:06 Skn0tt