w3c / webdriver-bidi

Bidirectional WebDriver protocol for browser automation
https://w3c.github.io/webdriver-bidi/
363 stars 40 forks source link

Explicit behavior for removing last `NetworkIntercept` #663

Closed Lightning00Blade closed 7 months ago

Lightning00Blade commented 7 months ago

Currently there is an implicit behavior when removing the last intercept from the session's intercept map. Let's say we do the following steps:

  1. We subscribe to the network module
  2. We add network interception for URL A (phase BeforeRequestSent).
  3. We make a fetch request from the page to URL A.
  4. The BeforeRequestSent get emitted and event get a isBlocked: true and intecepts: [ "<ID>" ]
  5. We remove the network interception.
  6. The request continues to wait for a network.continueRequest command

The question here is if this would be the expected from the user?

I think we should either:

Note: This was discovered as CDP's behavior is to continue the request if interception is removed.

juliandescottes commented 7 months ago

The first option sounds good. Since the intercept is only really necessary to block the request I think the current behavior is fine, and calling it out explicitly in the spec could be enough.

OrKoN commented 7 months ago

I think it's worth mentioning as non-normative note (first option) because the spec already defined this behavior. About CDP implementation: we will need to keep the interception on, until the last request is handled, and auto-continue new requests.