Bug 1299967 - Sort permission list in SitePermissions alphabetically. r?johannh
MozReview-Commit-ID: 3bf8dtunKuz
--- a/browser/modules/SitePermissions.jsm
+++ b/browser/modules/SitePermissions.jsm
@@ -89,17 +89,17 @@ this.SitePermissions = {
/* Checks whether a UI for managing permissions should be exposed for a given
* URI. This excludes file URIs, for instance, as they don't have a host,
* even though nsIPermissionManager can still handle them.
*/
isSupportedURI: function (aURI) {
return aURI.schemeIs("http") || aURI.schemeIs("https");
},
- /* Returns an array of all permission IDs.
+ /* Returns an array of all permission IDs sorted alphabetically by label for display in the UI.
*/
listPermissions: function () {
return kPermissionIDs;
},
/* Returns an array of permission states to be exposed to the user for a
* permission with the given ID.
*/
@@ -261,9 +261,14 @@ var gPermissionObject = {
"geo": {
exactHostMatch: true
},
"indexedDB": {}
};
-const kPermissionIDs = Object.keys(gPermissionObject);
+//Permission IDs sorted alphabetically by label for display in the UI.
+const kPermissionIDs = Object.keys(gPermissionObject).sort((a, b) => {
+ let firstLabel = SitePermissions.getPermissionLabel(a);
+ let secondLabel = SitePermissions.getPermissionLabel(b);
+ return firstLabel.localeCompare(secondLabel);
+});