dessant / clear-browsing-data

Browser extension for clearing browsing data, available for Chrome, Edge and Firefox
https://addons.mozilla.org/en-US/firefox/addon/clear-browsing-data/
GNU General Public License v3.0
185 stars 22 forks source link

Cache is not cleared on Firefox #13

Open boinker opened 5 years ago

dessant commented 5 years ago

Please share more details.

boinker commented 5 years ago

After clicking Clear Browsing Data menu button I go to Options/Privacy & Security/Cookies and Site Data. There it says that "Your stored cookies, site data and cache are currently using 3.5 MB of disk space". I then click Manage Data button and it says that www.united.com is using 3.5 MB of storage and google.com has 2 cookies. I have checked all boxes in the Clear Browsing Data options. Clear Browsing Data reports that "...successfully cleared."

So Clear Browsing Data does not clear everything causing me to have to go into Firefox Options/Privacy & Security/Cookies and Site Data and click on the "Clear Data..." button. Then after a refresh Firefox reports that "Your stored cookies, site data and cache are currently using 0 bytes of disk space."

Please update Clear Browsing Data so that after running it Firefox reports "Your stored cookies, site data and cache are currently using 0 bytes of disk space."

Thank you

dessant commented 5 years ago

What version of Firefox are you using and which operating system? The extension is using browser APIs to clear the data and it works as expected for others. It is possible that you are seeing a browser bug.

boinker commented 5 years ago

The www.united.com storage used by Firefox is created when I go to united.com and put in my confirmation number and last name to check on my flight. Some sort of persistent data. I don't know. You are the expert. I don't know about the google.com cookies remaining after clicking Clear Browsing Data. I am running Firefox Quantum 65.0 (64-bit) on Win 10 Pro. Firefox says it's up to date.

dessant commented 5 years ago

On my part all data is cleared with the same browser, have you refreshed the about:preferences#privacy page before checking Manage Data again?

dessant commented 5 years ago

It's also possible that sites make requests and store data right after you clear the data, so make sure to close other tabs before further tests.

boinker commented 5 years ago

I refresh the 'about:preferences#privacy' page to see if the clear worked. It does not. I tested it with only one Firefox tab open and that would be the 'about:preferences#privacy' page. Currently only the www.united.com site is using 3.5 MB last used 43 minutes ago.

dessant commented 5 years ago

I have reproduced the issue with a fresh Firefox profile using their service worker demo. Files cached by service workers are not cleared by the extension API.

According to the docs serviceWorkers clears the data cached by service workers, but it seems the code below unregisters workers without clearing the data.

// extension background page
browser.browsingData.remove({}, {serviceWorkers: true})

Run this in the web console (Ctrl+Shift+K) of the page that registered the service worker, it will list the keys of the cache:

window.caches.keys().then(function(keyList) {
  console.log(keyList)
});

This API works as expected in Chrome and the data is cleared.

The bug can be used to track users. The only workaround I have found so far is to disable service workers, visit about:config?filter=dom.serviceWorkers.enabled and set the value to false.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browsingData/remove

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browsingData/DataTypeSet

https://github.com/mozilla/gecko-dev/blob/ca776030e53ee395aa8c9014243caba9abacc184/browser/components/extensions/parent/ext-browsingData.js#L234

dessant commented 5 years ago

Disabling service workers only works if the caching is done from a service worker, but pages can access the Cache API too, so clearing the data using Firefox options or disabling the cache entirely are the only workarounds.

Save the user id:

window.caches.open('userid');

Get the user id on future visits:

window.caches.keys().then(keys => console.log(keys[0]));
dessant commented 5 years ago

https://bugzilla.mozilla.org/show_bug.cgi?id=1526246

boinker commented 5 years ago

Thank you for all of your good work. I wonder if Mozilla will do anything. We'll see.

dessant commented 5 years ago

Thanks! I enjoyed exploring the bug. :yum:

I think they'll fix it at some point, though keep in mind that the browsingData API in Firefox will still remain a minefield. Some of the bugs are listed in the description of the extension on AMO. All of that works as expected in Chrome.

dessant commented 5 years ago

I wrote a blog post about the issues discovered in the Firefox browsingData API.

https://armin.dev/blog/2019/03/firefox-extensions-browsing-data-security/

nadesco commented 5 years ago

visit about:config?filter=dom.serviceWorkers.enabled and set the value to false

Thanks for that. Clicking on Clear All Browsing Data previously set Cookies to '0' but Storage was still showing sites like youtube leaving KBs of data. I tried the United page and it showed 3.2MBs of data remaining in Storage when Cookies showed zero. In Preferences all boxes except browsing history, download history and saved p/words were checked. (Mac 10.14.5, Firefox 67.0)

With dom.serviceWorkers.enabled set to False the remaining data is now deleted. :)

boinker commented 5 years ago

I tried setting dom.serviceWorkers.enabled to false but data (e.g. youtube) remained after clicking the 'Clear Browsing Data' add-on button. Windows 10, Firefox 67.0 (64-bit).

dessant commented 5 years ago

I've looked further and there is a config option for disabling the Cache API, without disabling the internal cache entirely. Setting about:config?filter=dom.caches.enabled to false prevents storing data with the Cache API, though it may break sites that depend on it.

Taurean75 commented 5 years ago

It also doesn't delete download history from the Library. I'm using the latest versions on Windows 10.

dessant commented 5 years ago

@Taurean75, that upstream issue is already documented in the description of the extension: https://addons.mozilla.org/en-US/firefox/addon/clear-browsing-data/