-
Notifications
You must be signed in to change notification settings - Fork 55
emulation.setNetworkConditions
#948
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
base: main
Are you sure you want to change the base?
Conversation
909666e
to
4b304a6
Compare
emulation.setNetworkConditions
3e9d492
to
7d5df6c
Compare
7d5df6c
to
5a54342
Compare
5a54342
to
08b8e65
Compare
emulation.setNetworkConditions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we discuss this again with the working group (if it was discussed recently, I'm missing the summary) ?
1. Let |emulated network conditions| be the result of | ||
[=get emulated network conditions=] with |related navigables|. | ||
|
||
1. If |emulated network conditions| is not null and | ||
|emulated network conditions|'s [=emulated-network-conditions-struct/offline=] is | ||
true, return ([=network error=], "<code>complete</code>"). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the added value of an offline emulation which only rejects on beforeRequestSent
. It seems you can easily implement this with addIntercept + failRequest? Even if we ignore navigator.online, an offline mode should impact ongoing requests, websockets, allow you to test service workers etc... I feel like a limited feature like this would be more confusing than anything else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under impression that this was discussed in the WG? I do not think the offline mode should apply to ongoing requests and with this it should apply to web sockets and service worker requests as they have to start via fetch? The advantage is that you do no pay the cost of interception and have a dedicated command that can be extended with further aspects specific to the network condition emulation. The question I would have if this allows successfully testing the offline mode behavior of the browser which is probably a bit more than failing the network requests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under impression that this was discussed in the WG?
I thought so as well, but I wanted to check the details and I can't find any summary for this discussion. So I'm just giving my feedback based on what is currently proposed. I couldn't find a matching topic in the last 6 meetings, but maybe this was discussed informally?
For service workers, I would need to check in details. I was thinking about a fetch request which gets captured by an already registered service worker, returning a response from the cache. This should still work in offline mode, but not sure that's the case here?
For websocket, is fetch used for anything but establishing the connection at https://websockets.spec.whatwg.org/#concept-websocket-establish ? I was thinking about ws messages on an already open websocket.
The question I would have if this allows successfully testing the offline mode behavior of the browser which is probably a bit more than failing the network requests?
I think the answer to this is no, but I don't know if the offline mode is completely specified.
But if the WG agreed to have something that only blocks new fetch requests as an offline mode, I don't mean to block the PR (would be great if I could find the discussion though :) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not attending unfortunately so I do not know for sure :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember such a discussion and broadly agree with Julian's concerns here; I'd certainly expect that in offline mode navigatior.onLine
should be false, and for the offline
event to fire when the state changes. I also agree it would be extremely surprising if e.g. open websockets (or server sent events eventsources) continue to work in "offline" mode.
Addressing #776
Implement offline emulation.
Out of scope: HTML
navigator.onLine
.Preview | Diff