Bug 1299967 - Sort page permissions list alphabetically. r=Gijs, a=lizzard
authorPavan <pavankarthikboddeda@gmail.com>
Sun, 18 Dec 2016 08:11:00 -0500
changeset 353294 a6f6cf4180980a74083cc03f611cc510eb15b5cc
parent 353293 21d3da6e4f050cc63e475055e2b0157aba1eecc4
child 353295 caef6aa266783f353699996527d5019b1d3fe9db
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, lizzard
bugs1299967
milestone52.0a2
Bug 1299967 - Sort page permissions list alphabetically. r=Gijs, a=lizzard
browser/base/content/pageinfo/permissions.js
browser/modules/SitePermissions.jsm
--- a/browser/base/content/pageinfo/permissions.js
+++ b/browser/base/content/pageinfo/permissions.js
@@ -6,17 +6,22 @@ Components.utils.import("resource:///mod
 Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
 
 const nsIQuotaManagerService = Components.interfaces.nsIQuotaManagerService;
 
 var gPermURI;
 var gPermPrincipal;
 var gUsageRequest;
 
-var gPermissions = SitePermissions.listPermissions();
+// Array of permissionIDs sorted alphabetically by label.
+var gPermissions = SitePermissions.listPermissions().sort((a, b) => {
+  let firstLabel = SitePermissions.getPermissionLabel(a);
+  let secondLabel = SitePermissions.getPermissionLabel(b);
+  return firstLabel.localeCompare(secondLabel);
+});
 gPermissions.push("plugins");
 
 var permissionObserver = {
   observe: function (aSubject, aTopic, aData)
   {
     if (aTopic == "perm-changed") {
       var permission = aSubject.QueryInterface(Components.interfaces.nsIPermission);
       if (permission.matchesURI(gPermURI, true)) {
--- a/browser/modules/SitePermissions.jsm
+++ b/browser/modules/SitePermissions.jsm
@@ -92,17 +92,17 @@ this.SitePermissions = {
    */
   isSupportedURI: function (aURI) {
     return aURI.schemeIs("http") || aURI.schemeIs("https");
   },
 
   /* Returns an array of all permission IDs.
    */
   listPermissions: function () {
-    return kPermissionIDs;
+    return Object.keys(gPermissionObject);
   },
 
   /* Returns an array of permission states to be exposed to the user for a
    * permission with the given ID.
    */
   getAvailableStates: function (aPermissionID) {
     if (aPermissionID in gPermissionObject &&
         gPermissionObject[aPermissionID].states)