Backed out 3 changesets (bug 1585582) for bc failures browser/base/content/test/sanitize/browser.ini on a CLOSED TREE

Backed out changeset 98d7a4f4388f (bug 1585582)
Backed out changeset c13ec2bbc0a7 (bug 1585582)
Backed out changeset 8015660b170f (bug 1585582)
This commit is contained in:
Oana Pop Rus 2019-10-18 18:42:49 +03:00
Родитель 6bb6defd96
Коммит 617a761d10
10 изменённых файлов: 84 добавлений и 23 удалений

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

@ -11,9 +11,6 @@ support-files=
[browser_sanitize-sitepermissions.js]
[browser_sanitize-timespans.js]
[browser_sanitizeDialog.js]
prefs=
browser.cache.offline.enable=true
browser.cache.offline.storage.enable=true
[browser_cookiePermission.js]
[browser_cookiePermission_aboutURL.js]
[browser_cookiePermission_containers.js]

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

@ -490,6 +490,8 @@ add_task(async function test_form_entries() {
// Test for offline cache deletion
add_task(async function test_offline_cache() {
Services.prefs.setBoolPref("browser.cache.offline.enable", true);
Services.prefs.setBoolPref("browser.cache.offline.storage.enable", true);
// Prepare stuff, we will work with www.example.com
var URL = "http://www.example.com";
var URI = makeURI(URL);
@ -568,6 +570,8 @@ add_task(async function test_offline_cache() {
cacheListener
);
await wh.promiseClosed;
Services.prefs.clearUserPref("browser.cache.offline.enable");
Services.prefs.clearUserPref("browser.cache.offline.storage.enable");
});
// Test for offline apps permission deletion

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

@ -2982,6 +2982,12 @@ bool nsGlobalWindowInner::IsPrivilegedChromeWindow(JSContext* aCx,
nsContentUtils::GetSystemPrincipal();
}
/* static */
bool nsGlobalWindowInner::OfflineCacheAllowedForContext(JSContext* aCx,
JSObject* aObj) {
return IsSecureContextOrObjectIsFromSecureContext(aCx, aObj);
}
/* static */
bool nsGlobalWindowInner::IsRequestIdleCallbackEnabled(JSContext* aCx,
JSObject* aObj) {

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

@ -387,6 +387,9 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
static bool IsPrivilegedChromeWindow(JSContext* /* unused */, JSObject* aObj);
static bool OfflineCacheAllowedForContext(JSContext* /* unused */,
JSObject* aObj);
static bool IsRequestIdleCallbackEnabled(JSContext* aCx,
JSObject* /* unused */);

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

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
[SecureContext, Pref="browser.cache.offline.enable",
[Pref="browser.cache.offline.enable", Func="nsGlobalWindowInner::OfflineCacheAllowedForContext",
Exposed=Window]
interface OfflineResourceList : EventTarget {
/**

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

@ -72,7 +72,7 @@ typedef OfflineResourceList ApplicationCache;
#ifdef HAVE_SIDEBAR
[Replaceable, Throws] readonly attribute External external;
#endif
[Throws, SecureContext, Pref="browser.cache.offline.enable"] readonly attribute ApplicationCache applicationCache;
[Throws, Pref="browser.cache.offline.enable", Func="nsGlobalWindowInner::OfflineCacheAllowedForContext"] readonly attribute ApplicationCache applicationCache;
// user prompts
[Throws, NeedsSubjectPrincipal] void alert();

66
netwerk/cache/nsCacheService.cpp поставляемый
Просмотреть файл

@ -39,7 +39,6 @@
#include "mozilla/Services.h"
#include "nsITimer.h"
#include "mozIStorageService.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/net/NeckoCommon.h"
#include <algorithm>
@ -50,6 +49,8 @@ using namespace mozilla::net;
/******************************************************************************
* nsCacheProfilePrefObserver
*****************************************************************************/
#define OFFLINE_CACHE_ENABLE_PREF "browser.cache.offline.enable"
#define OFFLINE_CACHE_STORAGE_ENABLE_PREF "browser.cache.offline.storage.enable"
#define OFFLINE_CACHE_DIR_PREF "browser.cache.offline.parent_directory"
#define OFFLINE_CACHE_CAPACITY_PREF "browser.cache.offline.capacity"
#define OFFLINE_CACHE_CAPACITY 512000
@ -61,6 +62,14 @@ static const char* observerList[] = {
NS_XPCOM_SHUTDOWN_OBSERVER_ID, "last-pb-context-exited",
"suspend_process_notification", "resume_process_notification"};
static const char* prefList[] = {
OFFLINE_CACHE_ENABLE_PREF,
OFFLINE_CACHE_STORAGE_ENABLE_PREF,
OFFLINE_CACHE_CAPACITY_PREF,
OFFLINE_CACHE_DIR_PREF,
nullptr,
};
class nsCacheProfilePrefObserver : public nsIObserver {
virtual ~nsCacheProfilePrefObserver() = default;
@ -95,6 +104,8 @@ class nsCacheProfilePrefObserver : public nsIObserver {
return mSanitizeOnShutdown && mClearCacheOnShutdown;
}
void PrefChanged(const char* aPref);
private:
bool mHaveProfile;
@ -142,6 +153,10 @@ nsresult nsCacheProfilePrefObserver::Install() {
nsCOMPtr<nsIPrefBranch> branch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (!branch) return NS_ERROR_FAILURE;
Preferences::RegisterCallbacks(
PREF_CHANGE_METHOD(nsCacheProfilePrefObserver::PrefChanged), prefList,
this);
// Determine if we have a profile already
// Install() is called *after* the profile-after-change notification
// when there is only a single profile, or it is specified on the
@ -168,6 +183,13 @@ void nsCacheProfilePrefObserver::Remove() {
obs->RemoveObserver(this, observer);
}
}
// remove Pref Service observers
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (!prefs) return;
Preferences::UnregisterCallbacks(
PREF_CHANGE_METHOD(nsCacheProfilePrefObserver::PrefChanged), prefList,
this);
}
NS_IMETHODIMP
@ -214,6 +236,40 @@ nsCacheProfilePrefObserver::Observe(nsISupports* subject, const char* topic,
return NS_OK;
}
void nsCacheProfilePrefObserver::PrefChanged(const char* aPref) {
// ignore pref changes until we're done switch profiles
if (!mHaveProfile) return;
// which preference changed?
nsresult rv;
if (!strcmp(OFFLINE_CACHE_ENABLE_PREF, aPref) ||
!strcmp(OFFLINE_CACHE_STORAGE_ENABLE_PREF, aPref)) {
rv = Preferences::GetBool(OFFLINE_CACHE_ENABLE_PREF, &mOfflineCacheEnabled);
if (NS_FAILED(rv)) {
return;
}
rv = Preferences::GetBool(OFFLINE_CACHE_STORAGE_ENABLE_PREF,
&mOfflineStorageCacheEnabled);
if (NS_FAILED(rv)) {
return;
}
nsCacheService::SetOfflineCacheEnabled(OfflineCacheEnabled());
} else if (!strcmp(OFFLINE_CACHE_CAPACITY_PREF, aPref)) {
int32_t capacity = 0;
rv = Preferences::GetInt(OFFLINE_CACHE_CAPACITY_PREF, &capacity);
if (NS_FAILED(rv)) return;
mOfflineCacheCapacity = std::max(0, capacity);
nsCacheService::SetOfflineCacheCapacity(mOfflineCacheCapacity);
#if 0
} else if (!strcmp(OFFLINE_CACHE_DIR_PREF, aPref)) {
// XXX We probaby don't want to respond to this pref except after
// XXX profile changes. Ideally, there should be some kind of user
// XXX notification that the pref change won't take effect until
// XXX the next time the profile changes (browser launch)
#endif
}
}
nsresult nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch) {
nsresult rv = NS_OK;
@ -247,9 +303,13 @@ nsresult nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch) {
}
// read offline cache device prefs
mOfflineCacheEnabled = StaticPrefs::browser_cache_offline_enable();
mOfflineCacheEnabled = true; // presume offline cache is enabled
(void)branch->GetBoolPref(OFFLINE_CACHE_ENABLE_PREF, &mOfflineCacheEnabled);
mOfflineStorageCacheEnabled =
StaticPrefs::browser_cache_offline_storage_enable();
true; // presume offline storage cache is enabled
(void)branch->GetBoolPref(OFFLINE_CACHE_STORAGE_ENABLE_PREF,
&mOfflineStorageCacheEnabled);
mOfflineCacheCapacity = OFFLINE_CACHE_CAPACITY;
(void)branch->GetIntPref(OFFLINE_CACHE_CAPACITY_PREF, &mOfflineCacheCapacity);

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

@ -40,7 +40,3 @@ user_pref("dom.animations-api.implicit-keyframes.enabled", true);
// sometime wpt runs test even before the document becomes visible, which would
// delay video.play() and cause play() running in wrong order.
user_pref("media.block-autoplay-until-in-foreground", false);
user_pref("media.block-autoplay-until-in-foreground", false);
// Enable AppCache globally for now whilst it's being removed in Bug 1584984
user_pref("browser.cache.offline.storage.enable", true);
user_pref("browser.cache.offline.enable", true);

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

@ -406,6 +406,8 @@ async function test_push_cleared() {
const { PushService } = serviceExports;
const userAgentID = "bd744428-f125-436a-b6d0-dd0c9845837f";
const channelID = "0ef2ad4a-6c49-41ad-af6e-95d2425276bf";
Services.prefs.setBoolPref("browser.cache.offline.storage.enable", true);
Services.prefs.setBoolPref("browser.cache.offline.enable", true);
let db = PushServiceWebSocket.newPushDB();
@ -555,18 +557,10 @@ var tests = [
// Storage
test_storage_cleared,
];
// Cache
//
// Due to these prefs being static, setting them doesn't make a difference in time for the test
// As we are removing AppCache in Bug 1584984 this will just be removed soon.
if (
Services.prefs.getBoolPref("browser.cache.offline.enable") &&
Services.prefs.getBoolPref("browser.cache.offline.storage.enable")
) {
tests.push(test_cache_cleared);
}
test_cache_cleared,
];
function run_test() {
for (let i = 0; i < tests.length; i++) {

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

@ -1,4 +1,5 @@
[DEFAULT]
prefs = [browser.cache.offline.enable = true, browser.cache.offline.storage.enable=true]
head = head_forgetaboutsite.js ../../../../dom/push/test/xpcshell/head.js
skip-if = toolkit == 'android'
support-files =