Bug 1876097 - Migrate old prefs to the new prefs for clear on shutdown in the new clear history dialog. r=pbz
Differential Revision: https://phabricator.services.mozilla.com/D199445
This commit is contained in:
@@ -1065,6 +1065,8 @@ pref("privacy.sanitize.timeSpan", 1);
|
|||||||
|
|
||||||
pref("privacy.sanitize.useOldClearHistoryDialog", true);
|
pref("privacy.sanitize.useOldClearHistoryDialog", true);
|
||||||
|
|
||||||
|
pref("privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs", false);
|
||||||
|
|
||||||
pref("privacy.panicButton.enabled", true);
|
pref("privacy.panicButton.enabled", true);
|
||||||
|
|
||||||
// Time until temporary permissions expire, in ms
|
// Time until temporary permissions expire, in ms
|
||||||
|
|||||||
@@ -153,6 +153,10 @@ var gSanitizePromptDialog = {
|
|||||||
this._dialog.setAttribute("inClearOnShutdown", "true");
|
this._dialog.setAttribute("inClearOnShutdown", "true");
|
||||||
// remove the clear private data groupbox element
|
// remove the clear private data groupbox element
|
||||||
clearPrivateDataGroupbox.remove();
|
clearPrivateDataGroupbox.remove();
|
||||||
|
|
||||||
|
// If this is the first time the user is opening the new clear on shutdown
|
||||||
|
// dialog, migrate their prefs
|
||||||
|
Sanitizer.maybeMigrateSanitizeOnShutdownPrefs();
|
||||||
} else if (!lazy.USE_OLD_DIALOG) {
|
} else if (!lazy.USE_OLD_DIALOG) {
|
||||||
okButtonl10nID = "sanitize-button-ok2";
|
okButtonl10nID = "sanitize-button-ok2";
|
||||||
// remove the clear on shutdown groupbox element
|
// remove the clear on shutdown groupbox element
|
||||||
|
|||||||
@@ -35,3 +35,5 @@ support-files = [
|
|||||||
["browser_sanitizeDialog.js"]
|
["browser_sanitizeDialog.js"]
|
||||||
|
|
||||||
["browser_sanitizeDialog_v2.js"]
|
["browser_sanitizeDialog_v2.js"]
|
||||||
|
|
||||||
|
["browser_sanitizeOnShutdown_migration.js"]
|
||||||
|
|||||||
@@ -1313,3 +1313,31 @@ add_task(async function testClearingOptionsTelemetry() {
|
|||||||
`Expected ${telemetryObject} to be the same as ${expectedObject}`
|
`Expected ${telemetryObject} to be the same as ${expectedObject}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
add_task(async function testCheckboxStatesAfterMigration() {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["privacy.clearOnShutdown.history", false],
|
||||||
|
["privacy.clearOnShutdown.formdata", true],
|
||||||
|
["privacy.clearOnShutdown.cookies", true],
|
||||||
|
["privacy.clearOnShutdown.offlineApps", false],
|
||||||
|
["privacy.clearOnShutdown.sessions", false],
|
||||||
|
["privacy.clearOnShutdown.siteSettings", false],
|
||||||
|
["privacy.clearOnShutdown.cache", true],
|
||||||
|
["privacy.clearOnShutdown_v2.cookiesAndStorage", false],
|
||||||
|
["privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs", false],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
let dh = new DialogHelper();
|
||||||
|
dh.setMode("clearOnShutdown");
|
||||||
|
dh.onload = function () {
|
||||||
|
this.validateCheckbox("cookiesAndStorage", true);
|
||||||
|
this.validateCheckbox("historyFormDataAndDownloads", false);
|
||||||
|
this.validateCheckbox("cache", true);
|
||||||
|
this.validateCheckbox("siteSettings", false);
|
||||||
|
this.cancelDialog();
|
||||||
|
};
|
||||||
|
dh.open();
|
||||||
|
await dh.promiseClosed;
|
||||||
|
});
|
||||||
|
|||||||
@@ -0,0 +1,312 @@
|
|||||||
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||||
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* 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/. */
|
||||||
|
|
||||||
|
add_setup(async function () {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [["privacy.sanitize.useOldClearHistoryDialog", false]],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function testMigrationOfCacheAndSiteSettings() {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["privacy.clearOnShutdown.cache", true],
|
||||||
|
["privacy.clearOnShutdown.siteSettings", true],
|
||||||
|
["privacy.clearOnShutdown_v2.cache", false],
|
||||||
|
["privacy.clearOnShutdown_v2.siteSettings", false],
|
||||||
|
["privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs", false],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Sanitizer.runSanitizeOnShutdown();
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cache"),
|
||||||
|
true,
|
||||||
|
"Cache should be set to true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.siteSettings"),
|
||||||
|
true,
|
||||||
|
"siteSettings should be set to true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.cache"),
|
||||||
|
true,
|
||||||
|
"old cache should remain true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.siteSettings"),
|
||||||
|
true,
|
||||||
|
"old siteSettings should remain true"
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref(
|
||||||
|
"privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs"
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
"migration pref has been flipped"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function testHistoryAndFormData_historyTrue() {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["privacy.clearOnShutdown.history", true],
|
||||||
|
["privacy.clearOnShutdown.formdata", false],
|
||||||
|
["privacy.clearOnShutdown_v2.historyFormDataAndDownloads", false],
|
||||||
|
["privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs", false],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Sanitizer.runSanitizeOnShutdown();
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref(
|
||||||
|
"privacy.clearOnShutdown_v2.historyFormDataAndDownloads"
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
"historyFormDataAndDownloads should be set to true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.history"),
|
||||||
|
true,
|
||||||
|
"old history pref should remain true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.formdata"),
|
||||||
|
false,
|
||||||
|
"old formdata pref should remain false"
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref(
|
||||||
|
"privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs"
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
"migration pref has been flipped"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function testHistoryAndFormData_historyFalse() {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["privacy.clearOnShutdown.history", false],
|
||||||
|
["privacy.clearOnShutdown.formdata", true],
|
||||||
|
["privacy.clearOnShutdown_v2.historyFormDataAndDownloads", true],
|
||||||
|
["privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs", false],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Sanitizer.runSanitizeOnShutdown();
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref(
|
||||||
|
"privacy.clearOnShutdown_v2.historyFormDataAndDownloads"
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
"historyFormDataAndDownloads should be set to true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.history"),
|
||||||
|
false,
|
||||||
|
"old history pref should remain false"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.formdata"),
|
||||||
|
true,
|
||||||
|
"old formdata pref should remain true"
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref(
|
||||||
|
"privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs"
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
"migration pref has been flipped"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function testCookiesAndStorage_cookiesFalse() {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["privacy.clearOnShutdown.cookies", false],
|
||||||
|
["privacy.clearOnShutdown.offlineApps", true],
|
||||||
|
["privacy.clearOnShutdown.sessions", true],
|
||||||
|
["privacy.clearOnShutdown_v2.cookiesAndStorage", true],
|
||||||
|
["privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs", false],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Simulate clearing on shutdown.
|
||||||
|
Sanitizer.runSanitizeOnShutdown();
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cookiesAndStorage"),
|
||||||
|
false,
|
||||||
|
"cookiesAndStorage should be set to false"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.cookies"),
|
||||||
|
false,
|
||||||
|
"old cookies pref should remain false"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.offlineApps"),
|
||||||
|
true,
|
||||||
|
"old offlineApps pref should remain true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.sessions"),
|
||||||
|
true,
|
||||||
|
"old sessions pref should remain true"
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref(
|
||||||
|
"privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs"
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
"migration pref has been flipped"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function testCookiesAndStorage_cookiesTrue() {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["privacy.clearOnShutdown.cookies", true],
|
||||||
|
["privacy.clearOnShutdown.offlineApps", false],
|
||||||
|
["privacy.clearOnShutdown.sessions", false],
|
||||||
|
["privacy.clearOnShutdown_v2.cookiesAndStorage", false],
|
||||||
|
["privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs", false],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Sanitizer.runSanitizeOnShutdown();
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cookiesAndStorage"),
|
||||||
|
true,
|
||||||
|
"cookiesAndStorage should be set to true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.cookies"),
|
||||||
|
true,
|
||||||
|
"old cookies pref should remain true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.offlineApps"),
|
||||||
|
false,
|
||||||
|
"old offlineApps pref should remain false"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.sessions"),
|
||||||
|
false,
|
||||||
|
"old sessions pref should remain false"
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref(
|
||||||
|
"privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs"
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
"migration pref has been flipped"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function testMigrationDoesNotRepeat() {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["privacy.clearOnShutdown.cookies", true],
|
||||||
|
["privacy.clearOnShutdown.offlineApps", false],
|
||||||
|
["privacy.clearOnShutdown.sessions", false],
|
||||||
|
["privacy.clearOnShutdown_v2.cookiesAndStorage", false],
|
||||||
|
["privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs", true],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Simulate clearing on shutdown.
|
||||||
|
Sanitizer.runSanitizeOnShutdown();
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cookiesAndStorage"),
|
||||||
|
false,
|
||||||
|
"cookiesAndStorage should remain false"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.cookies"),
|
||||||
|
true,
|
||||||
|
"old cookies pref should remain true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.offlineApps"),
|
||||||
|
false,
|
||||||
|
"old offlineApps pref should remain false"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.sessions"),
|
||||||
|
false,
|
||||||
|
"old sessions pref should remain false"
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref(
|
||||||
|
"privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs"
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
"migration pref has been flipped"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function ensureNoOldPrefsAreEffectedByMigration() {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["privacy.clearOnShutdown.history", true],
|
||||||
|
["privacy.clearOnShutdown.formdata", true],
|
||||||
|
["privacy.clearOnShutdown.cookies", true],
|
||||||
|
["privacy.clearOnShutdown.offlineApps", false],
|
||||||
|
["privacy.clearOnShutdown.sessions", false],
|
||||||
|
["privacy.clearOnShutdown.siteSettings", true],
|
||||||
|
["privacy.clearOnShutdown.cache", true],
|
||||||
|
["privacy.clearOnShutdown_v2.cookiesAndStorage", false],
|
||||||
|
["privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs", false],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Sanitizer.runSanitizeOnShutdown();
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cookiesAndStorage"),
|
||||||
|
true,
|
||||||
|
"cookiesAndStorage should become true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.cookies"),
|
||||||
|
true,
|
||||||
|
"old cookies pref should remain true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.offlineApps"),
|
||||||
|
false,
|
||||||
|
"old offlineApps pref should remain false"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.sessions"),
|
||||||
|
false,
|
||||||
|
"old sessions pref should remain false"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.history"),
|
||||||
|
true,
|
||||||
|
"old history pref should remain true"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getBoolPref("privacy.clearOnShutdown.formdata"),
|
||||||
|
true,
|
||||||
|
"old formdata pref should remain true"
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -396,6 +396,58 @@ export var Sanitizer = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrate old sanitize on shutdown prefs to the new prefs for the new
|
||||||
|
* clear on shutdown dialog. Does nothing if the migration was completed before
|
||||||
|
* based on the pref privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
maybeMigrateSanitizeOnShutdownPrefs() {
|
||||||
|
if (
|
||||||
|
Services.prefs.getBoolPref(
|
||||||
|
"privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cookies = Services.prefs.getBoolPref("privacy.clearOnShutdown.cookies");
|
||||||
|
let history = Services.prefs.getBoolPref("privacy.clearOnShutdown.history");
|
||||||
|
let cache = Services.prefs.getBoolPref("privacy.clearOnShutdown.cache");
|
||||||
|
let siteSettings = Services.prefs.getBoolPref(
|
||||||
|
"privacy.clearOnShutdown.siteSettings"
|
||||||
|
);
|
||||||
|
|
||||||
|
// We set cookiesAndStorage to true if cookies are enabled for clearing on shutdown
|
||||||
|
// regardless of what sessions and offlineApps are set to
|
||||||
|
// This is because cookie clearing behaviour takes precedence over sessions and offlineApps clearing.
|
||||||
|
Services.prefs.setBoolPref(
|
||||||
|
"privacy.clearOnShutdown_v2.cookiesAndStorage",
|
||||||
|
cookies
|
||||||
|
);
|
||||||
|
|
||||||
|
// we set historyFormDataAndDownloads to true if history is enabled for clearing on
|
||||||
|
// shutdown, regardless of what form data is set to.
|
||||||
|
// This is because history clearing behavious takes precedence over formdata clearing.
|
||||||
|
Services.prefs.setBoolPref(
|
||||||
|
"privacy.clearOnShutdown_v2.historyFormDataAndDownloads",
|
||||||
|
history
|
||||||
|
);
|
||||||
|
|
||||||
|
// cache and siteSettings follow the old dialog prefs
|
||||||
|
Services.prefs.setBoolPref("privacy.clearOnShutdown_v2.cache", cache);
|
||||||
|
|
||||||
|
Services.prefs.setBoolPref(
|
||||||
|
"privacy.clearOnShutdown_v2.siteSettings",
|
||||||
|
siteSettings
|
||||||
|
);
|
||||||
|
|
||||||
|
Services.prefs.setBoolPref(
|
||||||
|
"privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
// When making any changes to the sanitize implementations here,
|
// When making any changes to the sanitize implementations here,
|
||||||
// please check whether the changes are applicable to Android
|
// please check whether the changes are applicable to Android
|
||||||
// (mobile/android/modules/geckoview/GeckoViewStorageController.jsm) as well.
|
// (mobile/android/modules/geckoview/GeckoViewStorageController.jsm) as well.
|
||||||
@@ -1031,6 +1083,10 @@ async function sanitizeOnShutdown(progress) {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
// Perform a migration if this is the first time sanitizeOnShutdown is
|
||||||
|
// running for the user with the new dialog
|
||||||
|
Sanitizer.maybeMigrateSanitizeOnShutdownPrefs();
|
||||||
|
|
||||||
progress.sanitizationPrefs = {
|
progress.sanitizationPrefs = {
|
||||||
privacy_sanitize_sanitizeOnShutdown: Services.prefs.getBoolPref(
|
privacy_sanitize_sanitizeOnShutdown: Services.prefs.getBoolPref(
|
||||||
"privacy.sanitize.sanitizeOnShutdown"
|
"privacy.sanitize.sanitizeOnShutdown"
|
||||||
|
|||||||
Reference in New Issue
Block a user