Bug 1299967 - Sort permission list in SitePermissions alphabetically. r?johannh draft
authorjulia <julia.friesel@gmail.com>
Sat, 29 Oct 2016 14:36:49 +0200
changeset 431508 ecc26647820edd104ba4e100b52351c4fb564380
parent 431012 1561c917ee27c3ea04bd69467e5b8c7c08102f2a
child 535410 64270ede2058730ba163b18281af69f1e33a7316
push id34049
push userbmo:julia.friesel@gmail.com
push dateSat, 29 Oct 2016 14:13:22 +0000
reviewersjohannh
bugs1299967
milestone52.0a1
Bug 1299967 - Sort permission list in SitePermissions alphabetically. r?johannh MozReview-Commit-ID: 3bf8dtunKuz
browser/modules/SitePermissions.jsm
--- 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);
+});