Bug 1869884 - Remerging downloads into history. r=pbz,fluent-reviewers,bolsson

Differential Revision: https://phabricator.services.mozilla.com/D198393
This commit is contained in:
Harshit Sohaney
2024-01-19 06:30:02 +00:00
parent ab3661f8cc
commit 4e984702b9
10 changed files with 59 additions and 174 deletions

View File

@@ -6,7 +6,7 @@ const url =
// We will be removing the ["history"] option once we remove the
// old clear history dialog in Bug 1856418 - Remove all old clear data dialog boxes
let prefs = [["history"], ["historyAndFormData"]];
let prefs = [["history"], ["historyFormDataAndDownloads"]];
for (let itemsToClear of prefs) {
add_task(async function purgeHistoryTest() {

View File

@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
add_task(async function test() {
let prefs = ["history", "historyAndFormData"];
let prefs = ["history", "historyFormDataAndDownloads"];
for (let pref of prefs) {
// This test relies on the form history being empty to start with delete

View File

@@ -4,7 +4,7 @@
// Tests that sanitizing history will clear storage access permissions
// for sites without cookies or site data.
add_task(async function sanitizeStorageAccessPermissions() {
let categories = ["history", "historyAndFormData"];
let categories = ["history", "historyFormDataAndDownloads"];
for (let pref of categories) {
await new Promise(resolve => {

View File

@@ -529,9 +529,6 @@ async function validateDataSizes(dialogHelper) {
// get current data sizes from siteDataManager
let cacheUsage = await SiteDataManager.getCacheSize();
let quotaUsage = await SiteDataManager.getQuotaUsageForTimeRanges(timespans);
let downloadUsage = await SiteDataManager.getDownloadCountForTimeRanges(
timespans
);
for (let i = 0; i < timespans.length; i++) {
// select timespan to check
@@ -541,8 +538,6 @@ async function validateDataSizes(dialogHelper) {
let clearCookiesAndSiteDataCheckbox =
dialogHelper.win.document.getElementById("cookiesAndStorage");
let clearCacheCheckbox = dialogHelper.win.document.getElementById("cache");
let clearDownloadsCheckbox =
dialogHelper.win.document.getElementById("downloads");
let [convertedQuotaUsage] = DownloadUtils.convertByteUnits(
quotaUsage[timespans[i]]
@@ -553,7 +548,6 @@ async function validateDataSizes(dialogHelper) {
await dialogHelper.win.document.l10n.translateElements([
clearCookiesAndSiteDataCheckbox,
clearCacheCheckbox,
clearDownloadsCheckbox,
]);
ok(
clearCacheCheckbox.label.includes(convertedCacheUnit),
@@ -563,10 +557,6 @@ async function validateDataSizes(dialogHelper) {
clearCookiesAndSiteDataCheckbox.label.includes(convertedQuotaUsage),
`Should show the quota usage as ${convertedQuotaUsage}`
);
ok(
clearDownloadsCheckbox.label.includes(downloadUsage[timespans[i]]),
`Should show the downloads usage as ${downloadUsage[timespans[i]]}`
);
}
}
@@ -602,7 +592,7 @@ add_task(async function test_cancel() {
let dh = new DialogHelper();
dh.onload = function () {
this.selectDuration(Sanitizer.TIMESPAN_HOUR);
this.checkPrefCheckbox("historyAndFormData", false);
this.checkPrefCheckbox("historyFormDataAndDownloads", false);
this.cancelDialog();
};
dh.onunload = async function () {
@@ -642,7 +632,7 @@ add_task(async function test_everything() {
"with a predefined timespan"
);
this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING);
this.checkPrefCheckbox("historyAndFormData", true);
this.checkPrefCheckbox("historyFormDataAndDownloads", true);
this.acceptDialog();
};
dh.onunload = async function () {
@@ -689,7 +679,7 @@ add_task(async function test_everything_warning() {
"with clearing everything"
);
this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING);
this.checkPrefCheckbox("historyAndFormData", true);
this.checkPrefCheckbox("historyFormDataAndDownloads", true);
this.acceptDialog();
};
dh.onunload = async function () {
@@ -747,8 +737,7 @@ add_task(async function test_history_downloads_checked() {
let dh = new DialogHelper();
dh.onload = function () {
this.selectDuration(Sanitizer.TIMESPAN_HOUR);
this.checkPrefCheckbox("downloads", true);
this.checkPrefCheckbox("historyAndFormData", true);
this.checkPrefCheckbox("historyFormDataAndDownloads", true);
this.acceptDialog();
};
dh.onunload = async function () {
@@ -800,7 +789,7 @@ add_task(async function test_cannot_clear_history() {
let dh = new DialogHelper();
dh.onload = function () {
var cb = this.win.document.querySelectorAll(
"checkbox[id='historyAndFormData']"
"checkbox[id='historyFormDataAndDownloads']"
);
ok(
cb.length == 1 && !cb[0].disabled,
@@ -827,7 +816,7 @@ add_task(async function test_no_formdata_history_to_clear() {
let dh = new DialogHelper();
dh.onload = function () {
var cb = this.win.document.querySelectorAll(
"checkbox[id='historyAndFormData']"
"checkbox[id='historyFormDataAndDownloads']"
);
ok(
cb.length == 1 && !cb[0].disabled && cb[0].checked,
@@ -850,7 +839,7 @@ add_task(async function test_form_entries() {
let dh = new DialogHelper();
dh.onload = function () {
var cb = this.win.document.querySelectorAll(
"checkbox[id='historyAndFormData']"
"checkbox[id='historyFormDataAndDownloads']"
);
is(cb.length, 1, "There is only one checkbox for history and form data");
ok(!cb[0].disabled, "The checkbox is enabled");
@@ -951,33 +940,6 @@ add_task(async function test_all_data_sizes() {
});
});
add_task(async function test_single_download() {
// add download
let downloadIDs = [];
await addDownloadWithMinutesAgo(downloadIDs, 100000000000);
let dh = new DialogHelper();
dh.onload = async function () {
this.uncheckAllCheckboxes();
this.checkPrefCheckbox("downloads", true);
this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING);
let clearDownloadsCheckbox = dh.win.document.getElementById("downloads");
// Wait for the UI to update
await dh.win.document.l10n.translateElements([clearDownloadsCheckbox]);
ok(
clearDownloadsCheckbox.label.includes("1 file)"),
"Should show singular file"
);
this.acceptDialog();
};
dh.onunload = async function () {
await ensureDownloadsClearedState(downloadIDs, true);
};
dh.open();
await dh.promiseClosed;
blankSlate();
});
// test the case when we open the dialog through the clear on shutdown settings
add_task(async function test_clear_on_shutdown() {
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
@@ -990,7 +952,7 @@ add_task(async function test_clear_on_shutdown() {
dh.setMode("clearOnShutdown");
dh.onload = async function () {
this.uncheckAllCheckboxes();
this.checkPrefCheckbox("historyAndFormData", true);
this.checkPrefCheckbox("historyFormDataAndDownloads", false);
this.checkPrefCheckbox("cookiesAndStorage", true);
this.acceptDialog();
};
@@ -1009,9 +971,9 @@ add_task(async function test_clear_on_shutdown() {
}
boolPrefIs(
"clearOnShutdown_v2.historyAndFormData",
true,
"clearOnShutdown_v2 history should be true "
"clearOnShutdown_v2.historyFormDataAndDownloads",
false,
"clearOnShutdown_v2 history should be false"
);
boolPrefIs(
@@ -1020,12 +982,6 @@ add_task(async function test_clear_on_shutdown() {
"clearOnShutdown_v2 cookies should be true"
);
boolPrefIs(
"clearOnShutdown_v2.downloads",
false,
"clearOnShutdown_v2 downloads should be false"
);
boolPrefIs(
"clearOnShutdown_v2.cache",
false,
@@ -1066,15 +1022,14 @@ add_task(async function test_clear_on_shutdown() {
dh.setMode("clearOnShutdown");
dh.onload = async function () {
this.uncheckAllCheckboxes();
this.checkPrefCheckbox("historyAndFormData", true);
this.checkPrefCheckbox("downloads", true);
this.checkPrefCheckbox("historyFormDataAndDownloads", true);
this.acceptDialog();
};
dh.open();
await dh.promiseClosed;
boolPrefIs(
"clearOnShutdown_v2.historyAndFormData",
"clearOnShutdown_v2.historyFormDataAndDownloads",
true,
"clearOnShutdown_v2 history should be true"
);
@@ -1085,12 +1040,6 @@ add_task(async function test_clear_on_shutdown() {
"clearOnShutdown_v2 cookies should be false"
);
boolPrefIs(
"clearOnShutdown_v2.downloads",
true,
"clearOnShutdown_v2 downloads should be true"
);
boolPrefIs(
"clearOnShutdown_v2.cache",
false,
@@ -1135,11 +1084,10 @@ add_task(async function test_defaults_prefs() {
dh.setMode("clearSiteData");
dh.onload = function () {
this.validateCheckbox("historyAndFormData", false);
this.validateCheckbox("historyFormDataAndDownloads", false);
this.validateCheckbox("cache", true);
this.validateCheckbox("cookiesAndStorage", true);
this.validateCheckbox("siteSettings", false);
this.validateCheckbox("downloads", false);
this.cancelDialog();
};
@@ -1152,11 +1100,10 @@ add_task(async function test_defaults_prefs() {
dh = new DialogHelper();
dh.onload = function () {
// Default checked for browser and clear history mode
this.validateCheckbox("historyAndFormData", true);
this.validateCheckbox("historyFormDataAndDownloads", true);
this.validateCheckbox("cache", true);
this.validateCheckbox("cookiesAndStorage", true);
this.validateCheckbox("siteSettings", false);
this.validateCheckbox("downloads", true);
this.cancelDialog();
};
@@ -1193,7 +1140,7 @@ async function clearAndValidateDataSizes({
await validateDataSizes(this);
this.checkPrefCheckbox("cache", clearCache);
this.checkPrefCheckbox("cookiesAndStorage", clearCookies);
this.checkPrefCheckbox("downloads", clearDownloads);
this.checkPrefCheckbox("historyFormDataAndDownloads", clearDownloads);
this.selectDuration(timespan);
this.acceptDialog();
};