Bug 1388107 - Support unknown capability values in the sitePermissions.xul dialog. r?johannh
MozReview-Commit-ID: 94mG93fe5OY
--- a/browser/components/preferences/sitePermissions.js
+++ b/browser/components/preferences/sitePermissions.js
@@ -9,16 +9,18 @@ Components.utils.import("resource:///mod
function Permission(principal, type, capability, capabilityString) {
this.principal = principal;
this.origin = principal.origin;
this.type = type;
this.capability = capability;
this.capabilityString = capabilityString;
}
+const PERMISSION_STATES = [SitePermissions.ALLOW, SitePermissions.BLOCK, SitePermissions.PROMPT];
+
var gSitePermissionsManager = {
_type: "",
_isObserving: false,
_permissions: new Map(),
_permissionsToChange: new Map(),
_permissionsToDelete: new Map(),
_list: null,
_bundle: null,
@@ -65,18 +67,18 @@ var gSitePermissionsManager = {
},
observe(subject, topic, data) {
if (topic !== "perm-changed")
return;
let permission = subject.QueryInterface(Components.interfaces.nsIPermission);
- // Ignore unrelated permission types.
- if (permission.type !== this._type)
+ // Ignore unrelated permission types and permissions with unknown states.
+ if (permission.type !== this._type || !PERMISSION_STATES.includes(permission.capability))
return;
if (data == "added") {
this._addPermissionToList(permission);
this.buildPermissionsList();
} else if (data == "changed") {
let p = this._permissions.get(permission.principal.origin);
p.capability = permission.capability;
@@ -107,17 +109,18 @@ var gSitePermissionsManager = {
case Services.perms.PROMPT_ACTION:
stringKey = "prompt"
break;
}
return this._bundle.getString(stringKey);
},
_addPermissionToList(perm) {
- if (perm.type !== this._type)
+ // Ignore unrelated permission types and permissions with unknown states.
+ if (perm.type !== this._type || !PERMISSION_STATES.includes(perm.capability))
return;
let capabilityString = this._getCapabilityString(perm.capability);
let p = new Permission(perm.principal, perm.type, perm.capability,
capabilityString);
this._permissions.set(p.origin, p);
},
_removePermissionFromList(origin) {