Bug 1890427 - Part 8: Use an observer to regenerate backups on permission removal. r=backup-reviewers,kpatenio
Differential Revision: https://phabricator.services.mozilla.com/D218878
This commit is contained in:
@@ -3167,6 +3167,7 @@ export class BackupService extends EventTarget {
|
||||
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, "quit-application-granted");
|
||||
}
|
||||
|
||||
@@ -3197,7 +3198,11 @@ export class BackupService extends EventTarget {
|
||||
|
||||
Services.obs.removeObserver(this.#observer, "passwordmgr-storage-changed");
|
||||
Services.obs.removeObserver(this.#observer, "formautofill-storage-changed");
|
||||
Services.obs.removeObserver(this.#observer, "sanitizer-sanitization-complete");
|
||||
Services.obs.removeObserver(
|
||||
this.#observer,
|
||||
"sanitizer-sanitization-complete"
|
||||
);
|
||||
Services.obs.removeObserver(this.#observer, "perm-changed");
|
||||
Services.obs.removeObserver(this.#observer, "quit-application-granted");
|
||||
this.#observer = null;
|
||||
|
||||
@@ -3248,6 +3253,12 @@ export class BackupService extends EventTarget {
|
||||
this.#debounceRegeneration();
|
||||
break;
|
||||
}
|
||||
case "perm-changed": {
|
||||
if (data == "deleted") {
|
||||
this.#debounceRegeneration();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -455,3 +455,23 @@ add_task(async function test_sanitization() {
|
||||
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.");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user