Bug 509202 - Addressbar displays ssl identy in punycode with browser.identity.ssl_domain_display=1. r=gavin, a=betaN+
authorDan Witte <dwitte@mozilla.com>
Fri, 27 Aug 2010 08:12:02 -0700
changeset 51575 a64bb4bf114d49f49f7d94f0e70a70e5db9de263
parent 51574 4aa15010c20525a58f0a8f28fd47c367a5f58374
child 51576 118b011d4d52c979578021733c10d124e4a4b871
push idunknown
push userunknown
push dateunknown
reviewersgavin, betaN
bugs509202
milestone2.0b5pre
Bug 509202 - Addressbar displays ssl identy in punycode with browser.identity.ssl_domain_display=1. r=gavin, a=betaN+
browser/base/content/browser.js
browser/base/content/test/browser_bug420160.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -7004,18 +7004,23 @@ var gIdentityHandler = {
   /**
    * Return the eTLD+1 version of the current hostname
    */
   getEffectiveHost : function() {
     // Cache the eTLDService if this is our first time through
     if (!this._eTLDService)
       this._eTLDService = Cc["@mozilla.org/network/effective-tld-service;1"]
                          .getService(Ci.nsIEffectiveTLDService);
+    if (!this._IDNService)
+      this._IDNService = Cc["@mozilla.org/network/idn-service;1"]
+                         .getService(Ci.nsIIDNService);
     try {
-      return this._eTLDService.getBaseDomainFromHost(this._lastLocation.hostname);
+      let baseDomain =
+        this._eTLDService.getBaseDomainFromHost(this._lastLocation.hostname);
+      return this._IDNService.convertToDisplayIDN(baseDomain, {});
     } catch (e) {
       // If something goes wrong (e.g. hostname is an IP address) just fail back
       // to the full domain.
       return this._lastLocation.hostname;
     }
   },
 
   /**
--- a/browser/base/content/test/browser_bug420160.js
+++ b/browser/base/content/test/browser_bug420160.js
@@ -13,20 +13,31 @@ function test() {
   ok(gIdentityHandler, "gIdentityHandler should exist");
 
   gBrowser.selectedTab = gBrowser.addTab();
   gBrowser.selectedBrowser.addEventListener("load", listener, true);
   listener.testFunction = testNormalDomain;  
   content.location = "http://test1.example.org/";
 }
 
+// Greek IDN for 'example.test'.
+var idnDomain = "\u03C0\u03B1\u03C1\u03AC\u03B4\u03B5\u03B9\u03B3\u03BC\u03B1.\u03B4\u03BF\u03BA\u03B9\u03BC\u03AE";
+
 function testNormalDomain() {
   is(gIdentityHandler._lastLocation.host, 'test1.example.org', "Identity handler is getting the full location");
   is(gIdentityHandler.getEffectiveHost(), 'example.org', "getEffectiveHost should return example.org for test1.example.org");
 
+  listener.testFunction = testIDNDomain;
+  content.location = "http://sub1." + idnDomain + "/";
+}
+
+function testIDNDomain() {
+  is(gIdentityHandler._lastLocation.host, "sub1." + idnDomain, "Identity handler is getting the full location");
+  is(gIdentityHandler.getEffectiveHost(), idnDomain, "getEffectiveHost should return the IDN base domain in UTF-8");
+
   listener.testFunction = testNormalDomainWithPort;
   content.location = "http://sub1.test1.example.org:8000/";
 }
 
 function testNormalDomainWithPort() {
   is(gIdentityHandler._lastLocation.host, 'sub1.test1.example.org:8000', "Identity handler is getting port information");
   is(gIdentityHandler.getEffectiveHost(), 'example.org', "getEffectiveHost should return example.org for sub1.test1.example.org:8000");