From bb3147ef68c22fcd4490eab4b3a2ca29c1031282 Mon Sep 17 00:00:00 2001 From: Honza Bambas Date: Fri, 5 Feb 2016 08:36:00 -0500 Subject: [PATCH] Bug 1237783 - Make sure we correctly turn off appcache. r=ehsan --- dom/webidl/Window.webidl | 2 +- uriloader/prefetch/nsOfflineCacheUpdateService.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dom/webidl/Window.webidl b/dom/webidl/Window.webidl index e61d8e5a6d8..12b18a151f5 100644 --- a/dom/webidl/Window.webidl +++ b/dom/webidl/Window.webidl @@ -69,7 +69,7 @@ typedef any Transferable; #ifdef HAVE_SIDEBAR [Replaceable, Throws] readonly attribute External external; #endif - [Throws] readonly attribute ApplicationCache applicationCache; + [Throws, Pref="browser.cache.offline.enable"] readonly attribute ApplicationCache applicationCache; // user prompts [Throws, UnsafeInPrerendering] void alert(); diff --git a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp index e9b2e53bb0d..f26fb136aa0 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp @@ -52,6 +52,7 @@ using namespace mozilla; using namespace mozilla::dom; static nsOfflineCacheUpdateService *gOfflineCacheUpdateService = nullptr; +static bool sAllowOfflineCache = true; nsTHashtable* nsOfflineCacheUpdateService::mAllowedDomains = nullptr; @@ -247,6 +248,10 @@ nsOfflineCacheUpdateService::nsOfflineCacheUpdateService() , mUpdateRunning(false) , mLowFreeSpace(false) { + MOZ_ASSERT(NS_IsMainThread()); + Preferences::AddBoolVarCache(&sAllowOfflineCache, + "browser.cache.offline.enable", + true); } nsOfflineCacheUpdateService::~nsOfflineCacheUpdateService() @@ -605,6 +610,10 @@ OfflineAppPermForPrincipal(nsIPrincipal *aPrincipal, { *aAllowed = false; + if (!sAllowOfflineCache) { + return NS_OK; + } + if (!aPrincipal) return NS_ERROR_INVALID_ARG; @@ -696,6 +705,10 @@ nsOfflineCacheUpdateService::AllowOfflineApp(nsIPrincipal *aPrincipal) { nsresult rv; + if (!sAllowOfflineCache) { + return NS_ERROR_NOT_AVAILABLE; + } + if (GeckoProcessType_Default != XRE_GetProcessType()) { ContentChild* child = ContentChild::GetSingleton();