Skip to content

[Regression]: Firefox page crashes on getByRole with a name when aria-labelledby is also read in the main world #43967

Closed

Description

@bartech-lab

Last Good Version

1.64.1

First Bad Version

1.65.0

Steps to reproduce

  1. Clone https://github.com/bartech-lab/firefox-aria-reflection-crash
  2. npm ci
  3. npx playwright install firefox
  4. npm test
  5. You should see 2 failures with "Page crashed", and 3 control tests passing

The failing test is:

await page.setContent(`<span id="l">Save</span><button id="b" aria-labelledby="l"></button>`);
await page.evaluate(() => document.getElementById('b').ariaLabelledByElements);
await page.getByRole('button', { name: 'Save' }).click({ trial: true });

Expected behavior

The test passes, as it does on Chromium and WebKit.

Actual behavior

locator.click: Page crashed. The Firefox content process exits on signal 11.

20 of 20 runs crash, in either read order. The controls pass 30 of 30: main world twice, utility world twice, and no aria-labelledby. It also reproduces on main at 58d69dc.

The test does not need its own read. A real suite hit this in two ways:

  • locator.dispatchEvent() resolves getByRole in the main world, then an action or assertion resolves it in the utility world.
  • getByRole in the utility world, then an @axe-core/playwright scan. A plain page.evaluate of the property crashes at the same point. I did not identify which axe call crashes.

Additional context

This is a Firefox bug, which #43577 exposed by reading element.ariaLabelledByElements in the utility world. It also crashes stock Firefox 159.0.1 and Nightly 162.0a1 with an extension content script: https://bugzilla.mozilla.org/show_bug.cgi?id=2090055, with a tested patch. Playwright's Firefox 157 crashes too when a custom selector engine does the same read.

I would like to work on this. I have a change ready for a PR if you approve it:

const attribute = element.getAttribute('aria-labelledby');
const refs = attribute ? getIdRefs(element, attribute) : element.ariaLabelledByElements;

One added line in SE-060 crashes Firefox without this change and passes with it. npm run flint passes.

Limit: this does not cover references set from script. If a page sets ariaLabelledByElements and reads it back, the attribute is empty, so Playwright still reads the property and Firefox still crashes. Only the Firefox fix closes that case, so you may prefer to carry it in your Firefox patches, which I did not try.

Environment

  System:
    OS: Linux 7.2 EndeavourOS
    CPU: (16) x64 AMD Ryzen 7 9800X3D 8-Core Processor
    Memory: 37.05 GB / 60.20 GB
    Container: Yes
  Binaries:
    Node: 26.13.0 - /usr/bin/node
    npm: 12.2.2 - /usr/bin/npm
    Deno: 2.9.8 - /usr/bin/deno
  Languages:
    Bash: 5.3.20 - /usr/bin/bash
  npmPackages:
    @playwright/test: 1.65.0 => 1.65.0

Activity

  1. bartech-lab commented on Nov 6, 2026

    @bartech-lab
    Author

    The full change, with the test, is on this branch if it helps you decide: main...bartech-lab:playwright:fix-43967

  2. github-actions commented on Nov 6, 2026

    @github-actions
  3. microsoft-playwright-automation commented on Nov 6, 2026

    @microsoft-playwright-automation
    Contributor

    Hi, I'm the Playwright bot and I reproduced this on the current checkout.

    Reproduced in Firefox 159.0 (build 1573), on Linux, at 58d69dcc392af3a6994eab0323dc2e883f05f396 (1.66.0-next). Chromium and WebKit pass. Direct property reads in the page and an isolated world also crash Firefox, without any role-selector logic. This confirms a Firefox defect, consistent with Mozilla bug 2090055.

    The attribute fallback would not fix script-set label references: that case also crashes here. The complete fix belongs in Firefox; the upstream patch is proposed but was not verified in this run.

    Condensed reproduction and results
    await page.setContent('<span id="l">Save</span><button id="b" aria-labelledby="l"></button>');
    await page.evaluate(() => { void document.getElementById('b')!.ariaLabelledByElements; });
    await page.getByRole('button', { name: 'Save' }).click({ trial: true });

    Tested headless on Ubuntu 24.04.5 x86-64, using Chromium 158.0.8127.18, Firefox 159.0 and WebKit 27.2:

    Scenario Firefox Chromium / WebKit
    Main-world read, then role trial click Crash Pass
    Role trial click, then main-world read Crash Pass
    Main-world read, then direct isolated-world read Crash Pass
    Direct isolated-world read, then main-world read Crash Pass
    Two main-world reads Pass Pass
    Two isolated-world reads Pass Pass
    No aria-labelledby, read in both worlds Pass Pass
    Script-set label references, main-world read, then role trial click Crash Pass

    I also extended the existing SE-060 should support name test with a main-world property read before its accessible-name assertion:

    npm run test -- selectors-role.spec.ts --grep 'SE-060' --project=chromium-page --project=firefox-page --project=webkit-page --workers=1 --retries=0 --reporter=line
    DEBUG=pw:browser npm run ftest -- selectors-role.spec.ts --grep 'SE-060' --workers=1 --retries=0 --reporter=line

    Chromium and WebKit passed; Firefox crashed in both runs. The debug log confirms that the content process exited on signal 11.

    The upstream source has an unchecked write through aUseCachedValue in Element::GetAttrAssociatedElementsForBindings, matching the two-world trigger. No reporter project or third-party branch was executed. Published versions and headed mode were not tested.

    Blocked-by: https://github.com/microsoft/playwright-browsers/issues/2682

    Triaged on Linux by the Playwright bot - agent run

  4. socrastein commented on Nov 7, 2026

    @socrastein

    Another way in, in case it helps: getByLabel triggers it too, and so does a plain getByRole/getByLabel lookup followed by an @axe-core/playwright scan. Running axe-core 4.14.0's 105 rules one at a time after getByLabel, only aria-prohibited-attr and hidden-content crash, so those are the main-world reads in axe. Minimal page: <div aria-labelledby="x"></div>. The element type doesn't matter, and neither does whether the id exists. Replacing aria-labelledby with aria-label, or skipping the locator, passes.

    Also reproduced on Windows 10 (19045, Node 22.23.3) with Playwright 1.65.0's Firefox build 1572, so it isn't Linux-specific.

  5. jokoso commented on Nov 8, 2026

    @jokoso

    evaluateAll after a named getByRole lookup also seems to be triggering this.

  6. pavelfeldman commented on Nov 9, 2026

    @pavelfeldman
    Member

    Should be fixed in the next FF roll

  7. 21 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions