Bug 1180871 - Fix some fallout from bug 1170200 (non dataman code) r=Ratty a=ewong in a CLOSED TREE RELEASE_42_END
authorEdmund Wong <ewong@pw-wspx.org>
Tue, 03 Nov 2015 17:43:56 +0800
changeset 31224 34ba48147772e7ff350b79f65fb54244e55062de
parent 31223 9dca1f23289624fac065dd5eb8cdf1291ce4c9d7
child 31225 6b3bfa159c52a19f030ccabe9404d56e4aa583c3
child 31228 2fa5dd6f56f3aaf22513ec617cd530c1b280e7d4
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersRatty, ewong
bugs1180871, 1170200
Bug 1180871 - Fix some fallout from bug 1170200 (non dataman code) r=Ratty a=ewong in a CLOSED TREE
suite/browser/pageinfo/pageInfo.js
suite/browser/pageinfo/permissions.js
suite/common/bindings/notification.xml
suite/common/nsContextMenu.js
suite/common/pref/pref-offlineapps.js
suite/common/pref/pref-popups.js
--- a/suite/browser/pageinfo/pageInfo.js
+++ b/suite/browser/pageinfo/pageInfo.js
@@ -936,17 +936,17 @@ function saveMedia()
 }
 
 function onBlockImage(aChecked)
 {
   var uri = makeURI(document.getElementById("imageurltext").value);
   if (aChecked)
     Services.perms.add(uri, "image", Services.perms.DENY_ACTION);
   else
-    Services.perms.remove(uri.host, "image");
+    Services.perms.remove(uri, "image");
 }
 
 function onImageSelect()
 {
   var previewBox      = document.getElementById("mediaPreviewBox");
   var mediaSaveBox    = document.getElementById("mediaSaveBox");
   var mediaSaveButton = document.getElementById("imagesaveasbutton");
   var splitter        = document.getElementById("mediaSplitter");
@@ -1207,17 +1207,17 @@ var imagePermissionObserver = {
 
     if (aTopic == "perm-changed") {
       var permission = aSubject.QueryInterface(Components.interfaces.nsIPermission);
       if (permission.type == "image") {
         var imageTree = document.getElementById("imagetree");
         var row = imageTree.currentIndex;
         var item = gImageView.data[row][COL_IMAGE_NODE];
         var url = gImageView.data[row][COL_IMAGE_ADDRESS];
-        if (makeURI(url).host == permission.host)
+        if (permission.matchesURI(makeURI(url), true))
           makeBlockImage(url);
       }
     }
   }
 }
 
 function getContentTypeFromHeaders(cacheEntryDescriptor)
 {
--- a/suite/browser/pageinfo/permissions.js
+++ b/suite/browser/pageinfo/permissions.js
@@ -53,18 +53,18 @@ var gPermObj = {
   }
 };
 
 var permissionObserver = {
   observe: function (aSubject, aTopic, aData)
   {
     if (aTopic == "perm-changed") {
       var permission = aSubject.QueryInterface(Components.interfaces.nsIPermission);
-      if (/^https?/.test(gPermURI.scheme) &&
-          permission.host == gPermURI.host && permission.type in gPermObj)
+      if (/^https?/.test(gPermURI.scheme) && permission.type in gPermObj &&
+          permission.matchesURI(gPermURI, true))
         initRow(permission.type);
     }
   }
 };
 
 function initPermission()
 {
   onUnloadRegistry.push(onUnloadPermission);
@@ -118,17 +118,17 @@ function initRow(aPartId)
   setRadioState(aPartId, perm);
 }
 
 function onCheckboxClick(aPartId)
 {
   var command  = document.getElementById("cmd_" + aPartId + "Toggle");
   var checkbox = document.getElementById(aPartId + "Def");
   if (checkbox.checked) {
-    Services.perms.remove(gPermURI.host, aPartId);
+    Services.perms.remove(gPermURI, aPartId);
     command.setAttribute("disabled", "true");
     var perm = gPermObj[aPartId]();
     setRadioState(aPartId, perm);
   }
   else {
     onRadioClick(aPartId);
     command.removeAttribute("disabled");
   }
--- a/suite/common/bindings/notification.xml
+++ b/suite/common/bindings/notification.xml
@@ -513,26 +513,17 @@
                 }
                 break;
 
               case "perm-changed":
                 var permission = aSubject.QueryInterface(Components.interfaces.nsIPermission);
                 if (permission.type != "popup" || aData != "added" || !this.popupCount)
                   return;
 
-                try {
-                  var hostport = this.activeBrowser.currentURI.hostPort;
-                } catch (ex) {
-                  // we can't do much without a hostport here
-                  return;
-                }
-                var host = '.' + permission.host;
-                hostport = '.' + hostport;
-
-                if (host == hostport.slice(-host.length)) {
+                if (permission.matchesURI(this.activeBrowser.currentURI, false)) {
                   var popupNotification = this.getNotificationWithValue("popup-blocked");
                   if (popupNotification)
                     this.removeNotification(popupNotification);
                   this.popupCount = 0;
                   this.notifyPopupCountChanged();
                 }
                 break;
             }
--- a/suite/common/nsContextMenu.js
+++ b/suite/common/nsContextMenu.js
@@ -793,17 +793,17 @@ nsContextMenu.prototype = {
   },
 
   // Block/Unblock image from loading in the future.
   toggleImageBlocking: function(aBlock) {
   const uri = Services.io.newURI(this.mediaURL, null, null);
   if (aBlock)
     Services.perms.add(uri, "image", Services.perms.DENY_ACTION);
   else
-    Services.perms.remove(uri.host, "image");
+    Services.perms.remove(uri, "image");
   },
 
   // Open linked-to URL in a new tab.
   openLinkInTab: function(aEvent) {
     // Determine linked-to URL.
     return openNewTabWith(this.linkURL, this.link, null, aEvent);
   },
 
--- a/suite/common/pref/pref-offlineapps.js
+++ b/suite/common/pref/pref-offlineapps.js
@@ -87,26 +87,26 @@ function ClearOfflineAppCache()
 function UpdateNotifyBox(aValue)
 {
   EnableElementById("offlineNotifyAsk", !aValue);
 
   // remove this once bug 934457 and bug 1024832 are fixed
   document.getElementById("offlineNotifyPermissions").disabled = aValue;
 }
 
-function _getOfflineAppUsage(aHost)
+function _getOfflineAppUsage(aPermission)
 {
   var appCache = Components.classes["@mozilla.org/network/application-cache-service;1"]
                            .getService(Components.interfaces.nsIApplicationCacheService);
   var groups = appCache.getGroups();
 
   var usage = 0;
   for (let i = 0; i < groups.length; i++) {
     let uri = Services.io.newURI(groups[i], null, null);
-    if (uri.asciiHost == aHost)
+    if (aPermission.matchesURI(uri, true))
       usage += appCache.getActiveCache(groups[i]).usage;
   }
   return usage;
 }
 
 /**
  * Updates the list of offline applications.
  */
@@ -122,19 +122,19 @@ function UpdateOfflineApps()
 
   while (enumerator.hasMoreElements()) {
     let perm = enumerator.getNext()
                          .QueryInterface(Components.interfaces.nsIPermission);
     if (perm.type != "offline-app" ||
         perm.capability != pm.ALLOW_ACTION)
       continue;
 
-    let usage = _getOfflineAppUsage(perm.host);
+    let usage = _getOfflineAppUsage(perm);
     let row = document.createElement("listitem");
-    row.setAttribute("host", perm.host);
+    row.setAttribute("host", perm.principal.URI.host);
     let converted = DownloadUtils.convertByteUnits(usage);
     row.setAttribute("usage", bundle.getFormattedString("offlineAppUsage",
                                                         converted));
     list.appendChild(row);
   }
 }
 
 function OfflineAppSelected(aList)
--- a/suite/common/pref/pref-popups.js
+++ b/suite/common/pref/pref-popups.js
@@ -22,31 +22,31 @@ function SetLists()
 
   var permissionManager = Components.classes["@mozilla.org/permissionmanager;1"]
                                     .getService(nsIPermissionManager);
 
   var pref = document.getElementById("privacy.popups.remove_blacklist");
   if (pref.value)
   {
     var enumerator = permissionManager.enumerator;
-    var hosts = [];
+    var uris = [];
 
     while (enumerator.hasMoreElements())
     {                
       var permission = enumerator.getNext();
       if (permission instanceof nsIPermission)
       {
         if ((permission.type == kPopupType) &&
             (permission.capability == nsIPermissionManager.DENY_ACTION))
-          hosts.push(permission.host);
+          uris.push(permission.principal.URI);
       }
     }
 
-    for (var i in hosts)
-      permissionManager.remove(hosts[i], kPopupType);
+    for (var i in uris)
+      permissionManager.remove(uris[i], kPopupType);
 
     pref.value = false;
   }
 
   pref = document.getElementById("privacy.popups.prefill_whitelist");
   if (pref.value)
   {
     try