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

Support emulation of network conditions #776

Open
whimboo opened this issue Sep 18, 2024 · 3 comments
Open

Support emulation of network conditions #776

whimboo opened this issue Sep 18, 2024 · 3 comments
Labels
enhancement New feature or request needs-discussion Issues to be discussed by the working group

Comments

@whimboo
Copy link
Contributor

whimboo commented Sep 18, 2024

Currently, network condition emulation applies globally to the browser (if possible at all), but it would be very useful to emulate network disconnection or throttling for specific browsing contexts (such as tabs or windows) independently.

This feature would provide more control over testing scenarios where individual contexts simulate network loss or restricted connectivity, while other contexts remain unaffected.

Use Cases

  1. Simulating Network Outages for Specific Tabs: Being able to emulate a network outage for a single tab or window while keeping other tabs connected. This is useful for testing progressive web apps (PWAs), handling network errors in single-page applications, or multi-tab synchronization.

  2. Multi-Context Testing: Testing how different contexts react to network issues independently. This is especially useful in applications where different parts of the app rely on separate network calls (e.g., one window working while another goes offline).

  3. Offline-First Applications: Testing apps that are designed to work offline in a more realistic scenario where only certain windows/tabs experience network issues, rather than the entire browser being set to offline mode.

Proposal

Introduce an API to WebDriver BiDi that allows specifying custom network conditions (e.g., offline, latency, download/upload throttling) for specific browsing contexts, rather than affecting the entire browser.

The API could look like:

  • Command to set network offline for a specific context:
    {
      "method": "network.setNetworkConditions",
      "params": {
        "contexts": [ids],  // The IDs of the browsing contexts or undefined for global settings
        "offline": true,           // Set network to offline
        "latency": 0,              // Optionally set latency
        "downloadThroughput": -1,  // Optional: Disable downloads
        "uploadThroughput": -1     // Optional: Disable uploads
      }
    }

Benefits

  • Granular Control: This feature allows testing different network conditions in a more targeted way, improving the ability to simulate real-world scenarios for developers building resilient, network-dependent applications.
  • Better Testing for PWAs: Many progressive web apps require granular control over network state to properly test offline functionality.
  • Non-disruptive Testing: Since this feature would apply to specific browsing contexts, it allows for more controlled testing without affecting the entire browser or other ongoing operations.

Questions

  • Are there any known limitations that might prevent isolating network conditions for individual browsing contexts?

References

@whimboo whimboo added enhancement New feature or request needs-discussion Issues to be discussed by the working group labels Sep 18, 2024
@juliandescottes
Copy link
Contributor

Are there any known limitations that might prevent isolating network conditions for individual browsing contexts?

If the question is on the implementation side, on Firefox we support Network Throttling in DevTools scoped by tab. So it shouldn't be an issue.

@css-meeting-bot
Copy link
Member

The Browser Testing and Tools Working Group just discussed emulator - Support emulation of network conditions.

The full IRC log of that discussion <AutomatedTester> topic: emulator - Support emulation of network conditions
<AutomatedTester> github: https://github.com//issues/776
<dmurph> q+ I have a question about testing / interception new navigables (github issue https://github.com//issues/756), it's on the topic bank - would that be possible to quickly check in about?
<dmurph> q+ to ask about github issue: https://github.com//issues/756
<jgraham> q?

@css-meeting-bot
Copy link
Member

The Browser Testing and Tools Working Group just discussed Emulation - Support emulation of network conditions.

The full IRC log of that discussion <AutomatedTester> topic: Emulation - Support emulation of network conditions
<AutomatedTester> github: https://github.com//issues/776
<jgraham> q+
<AutomatedTester> AutomatedTester: This is something that is regularly coming up to allow people to test their applications and make sure they are useable offline as well as making sure that service workers are installed properly and application is usable in "low" network areas
<AutomatedTester> ack jgraham
<AutomatedTester> jgraham: There are clear uses and I am in favour of working on this. I wonder if setOffline should be a separate command and isn't related to emulating the network
<AutomatedTester> ... and I don't think we should be using magic numbers here
<AutomatedTester> ... I also think the spec work here will be very intricate. we can't just use Fetch here
<AutomatedTester> q?
<sadym> q+
<AutomatedTester> ack sadym
<AutomatedTester> sadym: having offline and throughput will be good
<AutomatedTester> ... and I am in favour of dropping `-1` as a value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-discussion Issues to be discussed by the working group
Projects
None yet
Development

No branches or pull requests

3 participants