Closed Bug 1907304 Opened 1 year ago Closed 11 months ago

DevTools offline mode should not make cached requests fail

Categories

(DevTools :: General, defect, P2)

Firefox 127
defect

Tracking

(firefox132 fixed)

RESOLVED FIXED
132 Branch
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

Component: Untriaged → General
Product: Firefox → DevTools

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?

Flags: needinfo?(manuel.berliat)

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

Flags: needinfo?(manuel.berliat)

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.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P2
Summary: dev tools offline mode is completely useless → DevTools offline mode should not make cached requests fail
Flags: needinfo?(valentin.gosu)

The attached patch fixes the issue, but could really use a test.

Flags: needinfo?(valentin.gosu)

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.

Flags: needinfo?(sekim)
See Also: → 1156659

I can take a look.

Assignee: nobody → sekim
Flags: needinfo?(sekim)
Attachment #9421636 - Attachment description: WIP: Bug 1907304 - Write a test for DevTools offline mode not making cached requests fail r=valentin → Bug 1907304 - Write a test for DevTools offline mode not making cached requests fail r=valentin
Attachment #9419322 - Attachment description: WIP: Bug 1907304 - Check forceOffline BC flag _after_ opening the cache r=#necko → Bug 1907304 - Check forceOffline BC flag _after_ opening the cache r=#necko
Pushed by sekim@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c872b365b709 Check forceOffline BC flag _after_ opening the cache r=necko-reviewers,sekim,kershaw https://hg.mozilla.org/integration/autoland/rev/17ad7316a6df Write a test for DevTools offline mode not making cached requests fail r=jdescottes,devtools-reviewers
Backout by nerli@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ef10408825c6 Backed out 2 changesets for causing failures in browser_net_offline_mode.js CLOSED TREE
Flags: needinfo?(sekim)
Pushed by sekim@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6c9ae0f94b04 Check forceOffline BC flag _after_ opening the cache r=necko-reviewers,sekim,kershaw,jdescottes https://hg.mozilla.org/integration/autoland/rev/b2e4005c5cfa Write a test for DevTools offline mode not making cached requests fail r=jdescottes,devtools-reviewers
Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 132 Branch
Duplicate of this bug: 1916942
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: