Backed out 10 changesets (bug 1890427) for causing failures at LateWriteChecks.cpp. CLOSED TREE

Backed out changeset b3ea334a7968 (bug 1890427)
Backed out changeset 8534805fac67 (bug 1890427)
Backed out changeset 2b31d978a116 (bug 1890427)
Backed out changeset f1db7acebebe (bug 1890427)
Backed out changeset 57b90c2b57be (bug 1890427)
Backed out changeset c72168ca8f99 (bug 1890427)
Backed out changeset 6ccf8483a0c1 (bug 1890427)
Backed out changeset 76ac3e81db91 (bug 1890427)
Backed out changeset 6599f4c9d1cb (bug 1890427)
Backed out changeset 054da7263696 (bug 1890427)
This commit is contained in:
Butkovits Atila 2024-09-05 01:05:36 +03:00
Родитель 585cb9affe
Коммит 1245ebf404
3 изменённых файлов: 3 добавлений и 759 удалений

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

@ -50,14 +50,12 @@ ChromeUtils.defineLazyGetter(lazy, "fxAccounts", () => {
});
ChromeUtils.defineESModuleGetters(lazy, {
AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
ArchiveDecryptor: "resource:///modules/backup/ArchiveEncryption.sys.mjs",
ArchiveEncryptionState:
"resource:///modules/backup/ArchiveEncryptionState.sys.mjs",
ArchiveUtils: "resource:///modules/backup/ArchiveUtils.sys.mjs",
BasePromiseWorker: "resource://gre/modules/PromiseWorker.sys.mjs",
ClientID: "resource://gre/modules/ClientID.sys.mjs",
DeferredTask: "resource://gre/modules/DeferredTask.sys.mjs",
DownloadPaths: "resource://gre/modules/DownloadPaths.sys.mjs",
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
JsonSchema: "resource://gre/modules/JsonSchema.sys.mjs",
@ -650,15 +648,6 @@ export class BackupService extends EventTarget {
*/
#encState = undefined;
/**
* The PlacesObserver instance used to monitor the Places database for
* history and bookmark removals to determine if backups should be
* regenerated.
*
* @type {PlacesObserver|null}
*/
#placesObserver = null;
/**
* The AbortController used to abort any queued requests to create or delete
* backups that might be waiting on the WRITE_BACKUP_LOCK_NAME lock.
@ -667,16 +656,6 @@ export class BackupService extends EventTarget {
*/
#backupWriteAbortController = null;
/**
* A DeferredTask that will cause the last known backup to be deleted, and
* a new backup to be created.
*
* See BackupService.#debounceRegeneration()
*
* @type {DeferredTask}
*/
#regenerationDebouncer = null;
/**
* The path of the default parent directory for saving backups.
* The current default is the Documents directory.
@ -879,16 +858,6 @@ export class BackupService extends EventTarget {
return "write-backup";
}
/**
* The amount of time (in milliseconds) to wait for our backup regeneration
* debouncer to kick off a regeneration.
*
* @type {number}
*/
static get REGENERATION_DEBOUNCE_RATE_MS() {
return 10000;
}
/**
* Returns a reference to a BackupService singleton. If this is the first time
* that this getter is accessed, this causes the BackupService singleton to be
@ -947,12 +916,6 @@ export class BackupService extends EventTarget {
this.#postRecoveryPromise = promise;
this.#postRecoveryResolver = resolve;
this.#backupWriteAbortController = new AbortController();
this.#regenerationDebouncer = new lazy.DeferredTask(async () => {
if (!this.#backupWriteAbortController.signal.aborted) {
await this.deleteLastBackup();
await this.createBackupOnIdleDispatch();
}
}, BackupService.REGENERATION_DEBOUNCE_RATE_MS);
}
/**
@ -3152,25 +3115,6 @@ export class BackupService extends EventTarget {
);
lazy.logConsole.debug("Idle observer registered.");
lazy.logConsole.debug(`Registering Places observer`);
this.#placesObserver = new PlacesWeakCallbackWrapper(
this.onPlacesEvents.bind(this)
);
PlacesObservers.addListener(
["history-cleared", "page-removed", "bookmark-removed"],
this.#placesObserver
);
lazy.AddonManager.addAddonListener(this);
Services.obs.addObserver(this.#observer, "passwordmgr-storage-changed");
Services.obs.addObserver(this.#observer, "formautofill-storage-changed");
Services.obs.addObserver(this.#observer, "sanitizer-sanitization-complete");
Services.obs.addObserver(this.#observer, "perm-changed");
Services.obs.addObserver(this.#observer, "cookie-changed");
Services.obs.addObserver(this.#observer, "session-cookie-changed");
Services.obs.addObserver(this.#observer, "newtab-linkBlocked");
Services.obs.addObserver(this.#observer, "quit-application-granted");
}
@ -3191,25 +3135,8 @@ export class BackupService extends EventTarget {
this.#observer,
this.#idleThresholdSeconds
);
PlacesObservers.removeListener(
["history-cleared", "page-removed", "bookmark-removed"],
this.#placesObserver
);
lazy.AddonManager.removeAddonListener(this);
Services.obs.removeObserver(this.#observer, "passwordmgr-storage-changed");
Services.obs.removeObserver(this.#observer, "formautofill-storage-changed");
Services.obs.removeObserver(this.#observer, "perm-changed");
Services.obs.removeObserver(this.#observer, "cookie-changed");
Services.obs.removeObserver(this.#observer, "session-cookie-changed");
Services.obs.removeObserver(this.#observer, "newtab-linkBlocked");
Services.obs.removeObserver(this.#observer, "quit-application-granted");
this.#observer = null;
this.#regenerationDebouncer.disarm();
this.#backupWriteAbortController.abort();
}
/**
@ -3217,15 +3144,13 @@ export class BackupService extends EventTarget {
* quit-application-granted from the nsIObserverService. Exposed as a public
* method mainly for ease in testing.
*
* @param {nsISupports|null} subject
* @param {nsISupports|null} _subject
* The nsIUserIdleService for the idle notification, and null for the
* quit-application-granted topic.
* @param {string} topic
* The topic that the notification belongs to.
* @param {string} data
* Optional data that was included with the notification.
*/
onObserve(subject, topic, data) {
onObserve(_subject, topic) {
switch (topic) {
case "idle": {
this.onIdle();
@ -3233,63 +3158,12 @@ export class BackupService extends EventTarget {
}
case "quit-application-granted": {
this.uninitBackupScheduler();
break;
}
case "passwordmgr-storage-changed": {
if (data == "removeLogin" || data == "removeAllLogins") {
this.#debounceRegeneration();
}
break;
}
case "formautofill-storage-changed": {
if (
data == "remove" &&
(subject.wrappedJSObject.collectionName == "creditCards" ||
subject.wrappedJSObject.collectionName == "addresses")
) {
this.#debounceRegeneration();
}
break;
}
case "newtab-linkBlocked":
// Intentional fall-through
case "sanitizer-sanitization-complete": {
this.#debounceRegeneration();
break;
}
case "perm-changed": {
if (data == "deleted") {
this.#debounceRegeneration();
}
break;
}
case "cookie-changed":
// Intentional fall-through
case "session-cookie-changed": {
let notification = subject.QueryInterface(Ci.nsICookieNotification);
if (
notification.action ==
Ci.nsICookieNotification.COOKIES_BATCH_DELETED ||
notification.action == Ci.nsICookieNotification.COOKIE_DELETED ||
notification.action == Ci.nsICookieNotification.ALL_COOKIES_CLEARED
) {
this.#debounceRegeneration();
}
this.#backupWriteAbortController.abort();
break;
}
}
}
/**
* Called when the last known backup should be deleted and a new one
* created. This uses the #regenerationDebouncer to debounce clusters of
* events that might cause such a regeneration to occur.
*/
#debounceRegeneration() {
this.#regenerationDebouncer.disarm();
this.#regenerationDebouncer.arm();
}
/**
* Called when the nsIUserIdleService reports that user input events have
* not been sent to the application for at least
@ -3356,51 +3230,6 @@ export class BackupService extends EventTarget {
});
}
/**
* Handler for events coming in through our PlacesObserver.
*
* @param {PlacesEvent[]} placesEvents
* One or more batched events that are of a type that we subscribed to.
*/
onPlacesEvents(placesEvents) {
// Note that if any of the events that we iterate result in a regeneration
// being queued, we simply return without the processing the rest, as there
// is not really a point.
for (let event of placesEvents) {
switch (event.type) {
case "page-removed": {
// We will get a page-removed event if a page has been deleted both
// manually by a user, but also automatically if the page has "aged
// out" of the Places database. We only want to regenerate backups
// in the manual case (REASON_DELETED).
if (event.reason == PlacesVisitRemoved.REASON_DELETED) {
this.#debounceRegeneration();
return;
}
break;
}
case "bookmark-removed":
// Intentional fall-through
case "history-cleared": {
this.#debounceRegeneration();
return;
}
}
}
}
/**
* This method is the only method of the AddonListener interface that
* BackupService implements and is called by AddonManager when an addon
* is uninstalled.
*
* @param {AddonInternal} _addon
* The addon being uninstalled.
*/
onUninstalled(_addon) {
this.#debounceRegeneration();
}
/**
* Gets a sample from a given backup file and sets a subset of that as
* the backupFileInfo in the backup service state.

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

@ -1,583 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
const { PlacesTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/PlacesTestUtils.sys.mjs"
);
const { PlacesUtils } = ChromeUtils.importESModule(
"resource://gre/modules/PlacesUtils.sys.mjs"
);
const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
const { DownloadHistory } = ChromeUtils.importESModule(
"resource://gre/modules/DownloadHistory.sys.mjs"
);
const { AddonTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/AddonTestUtils.sys.mjs"
);
const { ExtensionTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/ExtensionXPCShellUtils.sys.mjs"
);
const { formAutofillStorage } = ChromeUtils.importESModule(
"resource://autofill/FormAutofillStorage.sys.mjs"
);
const { Sanitizer } = ChromeUtils.importESModule(
"resource:///modules/Sanitizer.sys.mjs"
);
const { NewTabUtils } = ChromeUtils.importESModule(
"resource://gre/modules/NewTabUtils.sys.mjs"
);
ExtensionTestUtils.init(this);
AddonTestUtils.init(this);
AddonTestUtils.createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1");
const nsLoginInfo = new Components.Constructor(
"@mozilla.org/login-manager/loginInfo;1",
Ci.nsILoginInfo,
"init"
);
/**
* This suite of tests ensures that the current backup will be deleted, and
* a new one generated when certain user actions occur.
*/
/**
* Adds a history visit to the Places database.
*
* @param {string} uriString
* A string representation of the URI to add a visit for.
* @param {number} [timestamp=Date.now()]
* The timestamp for the visit to be used. By default, this is the current
* date and time.
* @returns {Promise<undefined>}
*/
async function addTestHistory(uriString, timestamp = Date.now()) {
let uri = NetUtil.newURI(uriString);
await PlacesTestUtils.addVisits({
uri,
transition: Ci.nsINavHistoryService.TRANSITION_TYPED,
visitDate: timestamp * 1000,
});
}
let gCookieCounter = 0;
const COOKIE_HOST = "example.com";
const COOKIE_PATH = "/";
const COOKIE_ORIGIN_ATTRIBUTES = Object.freeze({});
/**
* Adds a new non-session cookie to the cookie database with the host set
* as COOKIE_HOST, the path as COOKIE_PATH, with the origin attributes of
* COOKIE_ORIGIN_ATTRIBUTES and a generated name and value.
*
* @param {boolean} isSessionCookie
* True if the cookie should be a session cookie.
* @returns {string}
* The name of the cookie that was generated.
*/
function addTestCookie(isSessionCookie) {
gCookieCounter++;
let name = `Cookie name: ${gCookieCounter}`;
Services.cookies.add(
COOKIE_HOST,
COOKIE_PATH,
name,
`Cookie value: ${gCookieCounter}`,
false,
false,
isSessionCookie,
Date.now() / 1000 + 1,
COOKIE_ORIGIN_ATTRIBUTES,
Ci.nsICookie.SAMESITE_NONE,
Ci.nsICookie.SCHEME_HTTP
);
return name;
}
/**
* A helper function that sets up a BackupService to be instrumented to detect
* a backup regeneration, and then runs an async taskFn to ensure that the
* regeneration occurs.
*
* @param {Function} taskFn
* The async function to run after the BackupService has been set up. It is
* not passed any arguments.
* @param {string} msg
* The message to write in the assertion when the regeneration occurs.
*/
async function expectRegeneration(taskFn, msg) {
let sandbox = sinon.createSandbox();
// Override the default REGENERATION_DEBOUNCE_RATE_MS to 0 so that we don't
// have to wait long for the debouncer to fire. We need to do this before
// we construct the BackupService that we'll use for the test.
sandbox.stub(BackupService, "REGENERATION_DEBOUNCE_RATE_MS").get(() => 0);
let bs = new BackupService();
// Now we set up some stubs on the BackupService to detect calls to
// deleteLastBackup and createbackupOnIdleDispatch, which are both called
// on regeneration.
let deleteDeferred = Promise.withResolvers();
sandbox.stub(bs, "deleteLastBackup").callsFake(() => {
Assert.ok(true, "Saw deleteLastBackup call");
deleteDeferred.resolve();
return Promise.resolve();
});
let createBackupDeferred = Promise.withResolvers();
sandbox.stub(bs, "createBackupOnIdleDispatch").callsFake(() => {
Assert.ok(true, "Saw createBackupOnIdleDispatch call");
createBackupDeferred.resolve();
return Promise.resolve();
});
bs.initBackupScheduler();
await taskFn();
let regenerationPromises = [
deleteDeferred.promise,
createBackupDeferred.promise,
];
// We'll wait for 1 second before considering the regeneration a bust.
let timeoutPromise = new Promise((resolve, reject) =>
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
setTimeout(() => {
reject();
}, 1000)
);
try {
await Promise.race([Promise.all(regenerationPromises), timeoutPromise]);
Assert.ok(true, msg);
} catch (e) {
Assert.ok(false, "Timed out waiting for regeneration.");
}
bs.uninitBackupScheduler();
sandbox.restore();
}
/**
* A helper function that sets up a BackupService to be instrumented to detect
* a backup regeneration, and then runs an async taskFn to ensure that the
* regeneration DOES NOT occur.
*
* @param {Function} taskFn
* The async function to run after the BackupService has been set up. It is
* not passed any arguments.
* @param {string} msg
* The message to write in the assertion when the regeneration does not occur
* within the timeout.
*/
async function expectNoRegeneration(taskFn, msg) {
let sandbox = sinon.createSandbox();
// Override the default REGENERATION_DEBOUNCE_RATE_MS to 0 so that we don't
// have to wait long for the debouncer to fire. We need to do this before
// we construct the BackupService that we'll use for the test.
sandbox.stub(BackupService, "REGENERATION_DEBOUNCE_RATE_MS").get(() => 0);
let bs = new BackupService();
// Now we set up some stubs on the BackupService to detect calls to
// deleteLastBackup and createbackupOnIdleDispatch, which are both called
// on regeneration. We share the same Promise here because in either of these
// being called, this test is a failure.
let regenerationPromise = Promise.withResolvers();
sandbox.stub(bs, "deleteLastBackup").callsFake(() => {
Assert.ok(false, "Unexpectedly saw deleteLastBackup call");
regenerationPromise.reject();
return Promise.resolve();
});
sandbox.stub(bs, "createBackupOnIdleDispatch").callsFake(() => {
Assert.ok(false, "Unexpectedly saw createBackupOnIdleDispatch call");
regenerationPromise.reject();
return Promise.resolve();
});
bs.initBackupScheduler();
await taskFn();
// We'll wait for 1 second, and if we don't see the regeneration attempt,
// we'll assume it's not coming.
let timeoutPromise = new Promise(resolve =>
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
setTimeout(() => {
Assert.ok(true, "Saw no regeneration within 1 second.");
resolve();
}, 1000)
);
try {
await Promise.race([regenerationPromise.promise, timeoutPromise]);
Assert.ok(true, msg);
} catch (e) {
Assert.ok(false, "Saw an unexpected regeneration.");
}
bs.uninitBackupScheduler();
sandbox.restore();
}
/**
* Tests that backup regeneration occurs on the page-removed PlacesObserver
* event that indicates manual user deletion of a page from history.
*/
add_task(async function test_page_removed_reason_deleted() {
const PAGE_URI = "https://test.com";
await addTestHistory(PAGE_URI);
await expectRegeneration(async () => {
await PlacesUtils.history.remove(PAGE_URI);
}, "Saw regeneration on page-removed via user deletion.");
});
/**
* Tests that backup regeneration does not occur on the page-removed
* PlacesObserver event that indicates automatic deletion of a page from
* history.
*/
add_task(async function test_page_removed_reason_expired() {
const PAGE_URI = "https://test.com";
await addTestHistory(
PAGE_URI,
0 /* Timestamp at 0 is wayyyyy in the past, in the 1960's - it's the UNIX epoch start date */
);
await expectNoRegeneration(async () => {
// This is how the Places tests force expiration, so we'll do it the same
// way.
let promise = TestUtils.topicObserved(
PlacesUtils.TOPIC_EXPIRATION_FINISHED
);
let expire = Cc["@mozilla.org/places/expiration;1"].getService(
Ci.nsIObserver
);
expire.observe(null, "places-debug-start-expiration", -1);
await promise;
}, "Saw no regeneration on page-removed via expiration.");
});
/**
* Tests that backup regeneration occurs on the history-cleared PlacesObserver
* event that indicates clearing of all user history.
*/
add_task(async function test_history_cleared() {
const PAGE_URI = "https://test.com";
await addTestHistory(PAGE_URI);
await expectRegeneration(async () => {
await PlacesUtils.history.clear();
}, "Saw regeneration on history-cleared.");
});
/**
* Tests that backup regeneration occurs when removing a download from history.
*/
add_task(async function test_download_removed() {
const FAKE_FILE_PATH = PathUtils.join(PathUtils.tempDir, "somefile.zip");
let download = {
source: {
url: "https://test.com/somefile",
isPrivate: false,
},
target: { path: FAKE_FILE_PATH },
};
await DownloadHistory.addDownloadToHistory(download);
await expectRegeneration(async () => {
await PlacesUtils.history.remove(download.source.url);
}, "Saw regeneration on download removal.");
});
/**
* Tests that backup regeneration occurs when clearing all downloads.
*/
add_task(async function test_all_downloads_removed() {
const FAKE_FILE_PATH = PathUtils.join(PathUtils.tempDir, "somefile.zip");
let download1 = {
source: {
url: "https://test.com/somefile",
isPrivate: false,
},
target: { path: FAKE_FILE_PATH },
};
let download2 = {
source: {
url: "https://test.com/somefile2",
isPrivate: false,
},
target: { path: FAKE_FILE_PATH },
};
await DownloadHistory.addDownloadToHistory(download1);
await DownloadHistory.addDownloadToHistory(download2);
await expectRegeneration(async () => {
await PlacesUtils.history.removeVisitsByFilter({
transition: PlacesUtils.history.TRANSITIONS.DOWNLOAD,
});
}, "Saw regeneration on all downloads removed.");
});
/**
* Tests that backup regeneration occurs when removing a password.
*/
add_task(async function test_password_removed() {
let login = new nsLoginInfo(
"https://example.com",
"https://example.com",
null,
"notifyu1",
"notifyp1",
"user",
"pass"
);
await Services.logins.addLoginAsync(login);
await expectRegeneration(async () => {
Services.logins.removeLogin(login);
}, "Saw regeneration on password removed.");
});
/**
* Tests that backup regeneration occurs when all passwords are removed.
*/
add_task(async function test_all_passwords_removed() {
let login1 = new nsLoginInfo(
"https://example.com",
"https://example.com",
null,
"notifyu1",
"notifyp1",
"user",
"pass"
);
let login2 = new nsLoginInfo(
"https://example.com",
"https://example.com",
null,
"",
"notifyp1",
"",
"pass"
);
await Services.logins.addLoginAsync(login1);
await Services.logins.addLoginAsync(login2);
await expectRegeneration(async () => {
Services.logins.removeAllLogins();
}, "Saw regeneration on all passwords removed.");
});
/**
* Tests that backup regeneration occurs when removing a bookmark.
*/
add_task(async function test_bookmark_removed() {
let bookmark = await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "data:text/plain,Content",
title: "Regeneration Test Bookmark",
});
await expectRegeneration(async () => {
await PlacesUtils.bookmarks.remove(bookmark);
}, "Saw regeneration on bookmark removed.");
});
/**
* Tests that backup regeneration occurs when all bookmarks are removed.
*/
add_task(async function test_all_bookmarks_removed() {
await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "data:text/plain,Content",
title: "Regeneration Test Bookmark 1",
});
await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "data:text/plain,Content2",
title: "Regeneration Test Bookmark 2",
});
await expectRegeneration(async () => {
await PlacesUtils.bookmarks.eraseEverything();
}, "Saw regeneration on all bookmarks removed.");
});
/**
* Tests that backup regeneration occurs when an addon is uninstalled.
*/
add_task(async function test_addon_uninstalled() {
await AddonTestUtils.promiseStartupManager();
let testExtension = ExtensionTestUtils.loadExtension({
manifest: {
name: "Some test extension",
browser_specific_settings: {
gecko: { id: "test-backup-regeneration@ext-0" },
},
},
useAddonManager: "temporary",
});
await testExtension.startup();
await expectRegeneration(async () => {
await testExtension.unload();
}, "Saw regeneration on test extension uninstall.");
});
/**
* Tests that backup regeneration occurs when removing a payment method.
*/
add_task(async function test_payment_method_removed() {
await formAutofillStorage.initialize();
let guid = await formAutofillStorage.creditCards.add({
"cc-name": "Foxy the Firefox",
"cc-number": "5555555555554444",
"cc-exp-month": 5,
"cc-exp-year": 2099,
});
await expectRegeneration(async () => {
await formAutofillStorage.creditCards.remove(guid);
}, "Saw regeneration on payment method removal.");
});
/**
* Tests that backup regeneration occurs when removing an address.
*/
add_task(async function test_address_removed() {
await formAutofillStorage.initialize();
let guid = await formAutofillStorage.addresses.add({
"given-name": "John",
"additional-name": "R.",
"family-name": "Smith",
organization: "World Wide Web Consortium",
"street-address": "32 Vassar Street\\\nMIT Room 32-G524",
"address-level2": "Cambridge",
"address-level1": "MA",
"postal-code": "02139",
country: "US",
tel: "+15195555555",
email: "user@example.com",
});
await expectRegeneration(async () => {
await formAutofillStorage.addresses.remove(guid);
}, "Saw regeneration on address removal.");
});
/**
* Tests that backup regeneration occurs after any kind of data sanitization.
*/
add_task(async function test_sanitization() {
await expectRegeneration(async () => {
await Sanitizer.sanitize(["cookiesAndStorage"]);
}, "Saw regeneration on sanitization of cookies and storage.");
await expectRegeneration(async () => {
await Sanitizer.sanitize(["siteSettings"]);
}, "Saw regeneration on sanitization of site settings.");
});
/**
* Tests that backup regeneration occurs after a permission is removed.
*/
add_task(async function test_permission_removed() {
let principal =
Services.scriptSecurityManager.createContentPrincipalFromOrigin(
"https://test-permission-site.com"
);
const PERMISSION_TYPE = "desktop-notification";
Services.perms.addFromPrincipal(
principal,
PERMISSION_TYPE,
Services.perms.ALLOW_ACTION
);
await expectRegeneration(async () => {
Services.perms.removeFromPrincipal(principal, PERMISSION_TYPE);
}, "Saw regeneration on permission removal.");
});
/**
* Tests that backup regeneration occurs when persistent and session cookies are
* removed.
*/
add_task(async function test_cookies_removed() {
for (let isSessionCookie of [false, true]) {
Services.cookies.removeAll();
// First, let's remove a single cookie by host, path, name and origin
// attrbutes.
let name = addTestCookie(isSessionCookie);
if (isSessionCookie) {
Assert.equal(
Services.cookies.sessionCookies.length,
1,
"Make sure we actually added a session cookie."
);
} else {
Assert.equal(
Services.cookies.sessionCookies.length,
0,
"Make sure we actually added a persistent cookie."
);
}
await expectRegeneration(async () => {
Services.cookies.remove(
COOKIE_HOST,
name,
COOKIE_PATH,
COOKIE_ORIGIN_ATTRIBUTES
);
}, "Saw regeneration on single cookie removal.");
// Now remove all cookies for a particular host.
addTestCookie(isSessionCookie);
addTestCookie(isSessionCookie);
await expectRegeneration(async () => {
Services.cookies.removeCookiesFromExactHost(COOKIE_HOST, "{}");
}, "Saw regeneration on cookie removal by host.");
// Now remove all cookies.
const COOKIES_TO_ADD = 10;
for (let i = 0; i < COOKIES_TO_ADD; ++i) {
addTestCookie(isSessionCookie);
}
await expectRegeneration(async () => {
Services.cookies.removeAll();
}, "Saw regeneration on all cookie removal.");
}
});
/**
* Tests that backup regeneration occurs when newtab links are blocked.
*/
add_task(async function test_newtab_link_blocked() {
NewTabUtils.init();
await expectRegeneration(async () => {
NewTabUtils.activityStreamLinks.blockURL("https://example.com");
}, "Saw regeneration on the blocking of a newtab link");
});

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

@ -36,8 +36,6 @@ support-files = [
["test_BackupService_recoverFromSnapshotFolder.js"]
["test_BackupService_regeneration.js"]
["test_BackupService_renderTemplate.js"]
["test_BackupService_resolveArchiveDestFolderPath.js"]