DevTools offline mode should not make cached requests fail
Categories
(DevTools :: General, defect, P2)
Tracking
(firefox132 fixed)
Tracking | Status | |
---|---|---|
firefox132 | --- | fixed |
People
(Reporter: manuel.berliat, Assigned: sekim)
References
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0
Steps to reproduce:
I tried to test out service workers in my angular application that i am developing locally.
I am quite new to this, and following what i saw online i implemented the service workers so that the page would still show in offline mode (if it has been loaded beforehand)
I went to the devtools, to the network tab and switched from "No Throttling" to offline
Actual results:
I got a page telling me that firefox was in offline mode. Not the page you get when disconnecting from the internet, but a page you only get when you go into the devtools and switch it to offline
Expected results:
As in every other browser, i wanted to still see the page and not just get notified about having turned on offline mode.
I now found out that there is such a feature, even in firefox. Only problem is that it turns the whole firefox window offline.
why do you make the life of devs trying to work with firefox harder than it has to be
Updated•1 year ago
|
Comment 1•1 year ago
|
||
Thanks for filing!
Can you share a bit more details:
- can you shared the page/application you are testing this on, and the extact steps for your scenario
- when you say that you don't get the same page when disconnecting from the internet, what do you get instead? Testing locally, I have the same result when using the offline mode or when disabling my internet connection
And overall, on small scenarios, I seem to see the same behavior on Chrome and Firefox, so you are probably testing things slightly differently, and we would need the exact steps to make sure we can reproduce. Maybe record a screencast if you can't share the app?
Reporter | ||
Comment 2•1 year ago
|
||
So I noticed it like this:
I am building an angular application and just implemented service workers - better said I updated my application so that when there is no more connection, information is preloaded and displayed even with no internet.
When testing this in firefox, I was able to see the service workers in the applications tab of the developer tools. When changing the online mode in the network tab from 'no throttling' to 'offline' I expected the browser to just display me the page that has been preloaded to work without internet.
Instead, after reloading, I got a black page with the following stated on it:
Offline mode
Firefox is currently in offline mode and can't browse the Web
-Press "Try Again" to switch to online mode and reload the page.
[button] Try Again [button]
When disconnecting From the Internet and reloading the application, I get the expected behaviour, so being shown the preloaded page.
When going to another Website with WiFi turned off, I get the following message:
Hmm. We’re having trouble finding that site.
We can’t connect to the server at www.mozilla.org.
If you entered the right address, you can:
Try again later
Check your network connection
Check that Firefox has permission to access the web (you might be connected but behind a firewall)
This is what I mean by having a different page when turning on offline mode.
Something I found out during my research:
The functionality which I expected to get by changing a single page to offline does only exist by turning on the menu bar, clicking on File and turning on 'Work Offline' which then puts the whole browser in offline mode.
The alternative is to turn off the WiFi whenever I need to test anything
TL;DR
The offline mode only shows the user, that offline mode is enabled, which is not the expected behaviour
I hope this clarifies my issue
Comment 3•1 year ago
|
||
Indeed, the page I was testing with didn't properly cache request so the behavior seemed identical for Work Offline / Offline mode / disabling WiFi. But with mozilla.org we can see that we don't even allow fully cached requests to succeed.
Properly cached requests should still succeed in offline mode from devtools.
And the API we use for offline mode makes all http requests fail.
https://searchfox.org/mozilla-central/rev/a9d6fb8ae147ebd1ff0d7886fd55c812d9b57378/dom/chrome-webidl/BrowsingContext.webidl#136-140
Feature was initially added in Bug 1156659. At the moment, it's still usable for JS apis relying on navigator.offline, but for more complex scenarios actually involving loading the page, it's effectively useless.
Updated•1 year ago
|
The attached patch fixes the issue, but could really use a test.
Comment 6•11 months ago
|
||
Sean, if you have any spare cycles, could you try writing a test for this?
You can have a look at https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/test/browser_net_throttling_profiles.js for an example.
The test should look something like:
Set profile to offline, check that request is blocked. Set profile to No throttling
, check that request works. Set profile to offline again, check that cached resource loaded. For this test devtools.cache.disabled should be set to false.
Assignee | ||
Comment 7•11 months ago
|
||
I can take a look.
Assignee | ||
Comment 8•11 months ago
|
||
Updated•11 months ago
|
Updated•11 months ago
|
Comment 10•11 months ago
|
||
Comment 11•11 months ago
|
||
Backed out 2 changesets (Bug 1907304) for causing failures in browser_net_offline_mode.js CLOSED TREE
Logs:
dt: https://treeherder.mozilla.org/logviewer?job_id=473514481&repo=autoland&lineNumber=8731
TV: https://treeherder.mozilla.org/logviewer?job_id=473514448&repo=autoland&lineNumber=2431
Backout: https://hg.mozilla.org/integration/autoland/rev/ef10408825c67a085dd242c238ddcc94b3224750
Assignee | ||
Updated•11 months ago
|
Comment 12•11 months ago
|
||
Comment 13•11 months ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/6c9ae0f94b04
https://hg.mozilla.org/mozilla-central/rev/b2e4005c5cfa
Description
•