Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Using context.setOffline(true) before loading causes Webkit error #34402

Open
kristojorg opened this issue Jan 20, 2025 · 2 comments
Open

Comments

@kristojorg
Copy link
Contributor

Version

1.49.1

Steps to reproduce

  1. Clone repo: https://github.com/kristojorg/pw-repro
  2. npm install
  3. npm run test

Expected behavior

All tests pass

Actual behavior

The webkit and Firefox tests for "works offline when immediately setting browser to offline" fail, while the chrome version succeeds.

Additional context

I am not sure which behavior is correct. I ran in to this while trying to test an app in "offline mode" where I only allowed localhost requests and everything else failed. I also set context.setOffline(true) in order to trigger the navigator.online flag which my app uses internally. However, both webkit and firefox fail when setting them to offline before loading a page.

In addition, if you use the "show browsers" option, any subsequent tests will fail for Webkit after the "works offline when immediately setting browser to offline" test. This might be because the webkit browser is actually running into a bug itself.

In any case, I would expect these to behave the same across browsers. In addition, it might be useful to update the docs with instructions about how to test this scenario. I have included a working example using page.addlistener("load") to set the network offline only after the page loads.

Environment

System:
    OS: macOS 15.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 200.11 MB / 32.00 GB
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v20.17.0/bin/npm
    bun: 1.1.34 - /opt/homebrew/bin/bun
  IDEs:
    VSCode: 1.96.3 - /usr/local/bin/code
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.49.1 => 1.49.1
@Schweinepriester
Copy link

I believe we are facing the same issue at my company.

I tried https://github.com/kristojorg/pw-repro with @playwright/[email protected] instead of 1.49.1, but behaves the same.

@pavelfeldman
Copy link
Member

"offline mode" where I only allowed localhost requests and everything else failed.

What is the user scenario that you are testing? Could you describe your objecting, expectations and the actual result?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants