Bug 1299967 - Sort page permissions list alphabetically. r=Gijs
authorPavan <pavankarthikboddeda@gmail.com>
Sun, 18 Dec 2016 08:11:00 -0500
changeset 326428 0103a22afe984cdf4ddffc2c55b44487261caa39
parent 326427 781d1e9b85863cedadc307ef2734c7bb9f93f115
child 326429 3e76f6a459f92ee7cf4ea6343e3c139c6cd0f7c6
push id35243
push userryanvm@gmail.com
push dateMon, 19 Dec 2016 21:18:41 +0000
treeherderautoland@0103a22afe98 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1299967
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1299967 - Sort page permissions list alphabetically. r=Gijs
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)