Skip to content

[Bug]: Test flakiness due to racy utility world creation #39360

@hbenl

Description

@hbenl

Version

1.58.2

Steps to reproduce

Run the tests "should dispose context on navigation" and "should dispose context on cross-origin navigation" with the Bidi protocol.

Expected behavior

The tests are stable

Actual behavior

The tests are flaky

Additional context

These tests are flaky because they use the _contextIdToContext map to check whether all expected execution contexts have been created. However, Playwright does not guarantee that the utility context is created when Page.ready arrives (see this comment for Juggler, BiDi has the same issue). Usually this isn't a problem because utility evaluations will wait for that context to appear, it only becomes a problem in these tests.
I think the tests should also wait for the utility world to be created (see #39332).

Environment

System:
    OS: macOS 26.2
    CPU: (12) arm64 Apple M3 Pro
    Memory: 2.87 GB / 36.00 GB
  Binaries:
    Node: 24.7.0 - /Users/hbenl/.nvm/versions/node/v24.7.0/bin/node
    Yarn: 1.22.22 - /Users/hbenl/Documents/firefox/full-build/firefox/node_modules/.bin/yarn
    npm: 11.5.1 - /Users/hbenl/.nvm/versions/node/v24.7.0/bin/npm
    pnpm: 10.15.1 - /Users/hbenl/.nvm/versions/node/v24.7.0/bin/pnpm
  Languages:
    Bash: 3.2.57 - /bin/bash

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions