Bug 724222 View page info -> Security: doesn't show cookies were set for sites with ip:8080 address (see Firefox Bug 409174) r=IanN.
authorPhilip Chee <philip.chee@gmail.com>
Tue, 07 Feb 2012 12:29:18 +0800
changeset 10788 9ff442d02f87c6fc0592de02fb146b23f5981ec1
parent 10787 5ab177f7e555264bd5123dbafdda792335a86ee1
child 10789 0095afd2cc5fdd4ea3f00549cf9930c0360073ba
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN
bugs724222, 409174, 435577
Bug 724222 View page info -> Security: doesn't show cookies were set for sites with ip:8080 address (see Firefox Bug 409174) r=IanN. Also contains regression fix caused by 409174: Bug 435577 Security tab broken for moz-icon or jar URIs.
suite/browser/pageinfo/security.js
--- a/suite/browser/pageinfo/security.js
+++ b/suite/browser/pageinfo/security.js
@@ -132,17 +132,24 @@ var security = {
     return name;
   },
   
   /**
    * Open the cookie manager window
    */
   viewCookies : function()
   {
-    toDataManager(this._getSecurityInfo().hostName + '|cookies');
+    var hostName = "";
+    try {
+      hostName = gDocument.documentURIObject.asciiHost;
+    }
+    catch (e) {
+    }
+
+    toDataManager(hostName + '|cookies');
   },
 
   /**
    * Open the login manager window
    */
   viewPasswords : function()
   {
     toDataManager(this._getSecurityInfo().hostName + '|passwords');
@@ -205,20 +212,21 @@ function securityOnLoad() {
   if (info.cert)
     security._cert = info.cert;
   document.getElementById("security-view-cert").collapsed = !info.cert;
 
   /* Set Privacy & History section text */
   var yesStr = pageInfoBundle.getString("yes");
   var noStr = pageInfoBundle.getString("no");
 
-  var hasCookies = hostHasCookies(info.hostName);
+  var uri = gDocument.documentURIObject;
+  var hasCookies = hostHasCookies(uri);
   setText("security-privacy-cookies-value", hasCookies ? yesStr : noStr);
   document.getElementById("security-view-cookies").disabled = !hasCookies;
-  var hasPasswords = realmHasPasswords(info.fullLocation);
+  var hasPasswords = realmHasPasswords(uri);
   setText("security-privacy-passwords-value", hasPasswords ? yesStr : noStr);
   document.getElementById("security-view-password").disabled = !hasPasswords;
 
   var visitCount = previousVisitCount(info.hostName);
   if(visitCount > 1) {
     setText("security-privacy-history-value",
             pageInfoBundle.getFormattedString("securityNVisits", [visitCount.toLocaleString()]));
   }
@@ -288,34 +296,37 @@ function viewCertHelper(parent, cert)
   if (!cert)
     return;
 
   var cd = Components.classes[CERTIFICATEDIALOGS_CONTRACTID].getService(nsICertificateDialogs);
   cd.viewCert(parent, cert);
 }
 
 /**
- * Return true iff we have cookies for hostName
+ * Return true iff we have cookies for uri.
  */
-function hostHasCookies(hostName) {
+function hostHasCookies(aUri) {
+  var hostName;
+  try {
+    hostName = aUri.asciiHost;
+  }
+  catch (e) {
+  }
   if (!hostName)
     return false;
 
   return Services.cookies.countCookiesFromHost(hostName) > 0;
 }
 
 /**
- * Return true iff realm (proto://host:port) (extracted from location) has
+ * Return true iff realm (proto://host:port) (extracted from uri) has
  * saved passwords
  */
-function realmHasPasswords(location) {
-  if (!location) 
-    return false;
-  
-  return Services.logins.countLogins(makeURI(location).prePath, "", "") > 0;
+function realmHasPasswords(aUri) {
+  return Services.logins.countLogins(aUri.prePath, "", "") > 0;
 }
 
 /**
  * Return the number of previous visits recorded for host before today.
  *
  * @param host - the domain name to look for in history
  */
 function previousVisitCount(host, endTimeReference) {