Bug 1665355 - Don't throw on appcache.update() if the storage is disabled r=baku

To avoid applications breaking, this method shouldn't throw when called if the
pref is set to off.

To reproduce go to: https://webdbg.com/test/appcache/
Open devtools console
Type: appCache.update()
Make sure it doesn't throw

Differential Revision: https://phabricator.services.mozilla.com/D90390
This commit is contained in:
Valentin Gosu 2020-09-18 13:57:11 +00:00
Родитель e45fb60afb
Коммит 486de00f22
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -26,6 +26,7 @@
#include "mozilla/EventDispatcher.h"
#include "mozilla/Preferences.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/StaticPrefs_browser.h"
#include "nsXULAppAPI.h"
#define IS_CHILD_PROCESS() (GeckoProcessType_Default != XRE_GetProcessType())
@ -486,6 +487,11 @@ void nsDOMOfflineResourceList::Update(ErrorResult& aRv) {
return;
}
// If the storage is disabled this operation should be ignored.
if (!StaticPrefs::browser_cache_offline_storage_enable()) {
return;
}
if (!nsContentUtils::OfflineAppAllowed(mDocumentURI)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;