[tor-commits] [tor-browser/esr24] Bug 1033340 - port forward PSL test changes also, to try and get rid of xpcshell PSL bustage. a=bustage.

mikeperry at torproject.org mikeperry at torproject.org
Fri Aug 29 05:26:43 UTC 2014


commit 994856d33e0338cb0378eeca454a6bca428acef7
Author: Gervase Markham <gerv at gerv.net>
Date:   Thu Jul 3 15:22:34 2014 +0100

    Bug 1033340 - port forward PSL test changes also, to try and get rid of xpcshell PSL bustage. a=bustage.
---
 netwerk/test/unit/data/test_psl.txt |   32 ++++++++++++++++++++++++++------
 netwerk/test/unit/test_psl.js       |   20 ++++++++++++++------
 2 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/netwerk/test/unit/data/test_psl.txt b/netwerk/test/unit/data/test_psl.txt
index 5a75831..35c8ccf 100644
--- a/netwerk/test/unit/data/test_psl.txt
+++ b/netwerk/test/unit/data/test_psl.txt
@@ -60,12 +60,12 @@ checkPublicSuffix('a.b.c.kobe.jp', 'b.c.kobe.jp');
 checkPublicSuffix('city.kobe.jp', 'city.kobe.jp');
 checkPublicSuffix('www.city.kobe.jp', 'city.kobe.jp');
 // TLD with a wildcard rule and exceptions.
-checkPublicSuffix('om', null);
-checkPublicSuffix('test.om', null);
-checkPublicSuffix('b.test.om', 'b.test.om');
-checkPublicSuffix('a.b.test.om', 'b.test.om');
-checkPublicSuffix('songfest.om', 'songfest.om');
-checkPublicSuffix('www.songfest.om', 'songfest.om');
+checkPublicSuffix('ck', null);
+checkPublicSuffix('test.ck', null);
+checkPublicSuffix('b.test.ck', 'b.test.ck');
+checkPublicSuffix('a.b.test.ck', 'b.test.ck');
+checkPublicSuffix('www.ck', 'www.ck');
+checkPublicSuffix('www.www.ck', 'www.ck');
 // US K12.
 checkPublicSuffix('us', null);
 checkPublicSuffix('test.us', 'test.us');
@@ -76,3 +76,23 @@ checkPublicSuffix('www.test.ak.us', 'test.ak.us');
 checkPublicSuffix('k12.ak.us', null);
 checkPublicSuffix('test.k12.ak.us', 'test.k12.ak.us');
 checkPublicSuffix('www.test.k12.ak.us', 'test.k12.ak.us');
+// IDN labels.
+checkPublicSuffix('食狮.com.cn', '食狮.com.cn');
+checkPublicSuffix('食狮.公司.cn', '食狮.公司.cn');
+checkPublicSuffix('www.食狮.公司.cn', '食狮.公司.cn');
+checkPublicSuffix('shishi.公司.cn', 'shishi.公司.cn');
+checkPublicSuffix('公司.cn', null);
+checkPublicSuffix('食狮.中国', '食狮.中国');
+checkPublicSuffix('www.食狮.中国', '食狮.中国');
+checkPublicSuffix('shishi.中国', 'shishi.中国');
+checkPublicSuffix('中国', null);
+// Same as above, but punycoded.
+checkPublicSuffix('xn--85x722f.com.cn', 'xn--85x722f.com.cn');
+checkPublicSuffix('xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn');
+checkPublicSuffix('www.xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn');
+checkPublicSuffix('shishi.xn--55qx5d.cn', 'shishi.xn--55qx5d.cn');
+checkPublicSuffix('xn--55qx5d.cn', null);
+checkPublicSuffix('xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s');
+checkPublicSuffix('www.xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s');
+checkPublicSuffix('shishi.xn--fiqs8s', 'shishi.xn--fiqs8s');
+checkPublicSuffix('xn--fiqs8s', null);
diff --git a/netwerk/test/unit/test_psl.js b/netwerk/test/unit/test_psl.js
index 446fe4c..251ffa6 100644
--- a/netwerk/test/unit/test_psl.js
+++ b/netwerk/test/unit/test_psl.js
@@ -1,9 +1,11 @@
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
 var etld = Cc["@mozilla.org/network/effective-tld-service;1"]
              .getService(Ci.nsIEffectiveTLDService);
 
+var idna = Cc["@mozilla.org/network/idn-service;1"]
+           .getService(Ci.nsIIDNService);
+
+var Cr = Components.results;
+
 function run_test()
 {
   var file = do_get_file("data/test_psl.txt");
@@ -13,7 +15,7 @@ function run_test()
   var scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
                        .getService(Ci.mozIJSSubScriptLoader);
   var srvScope = {};
-  scriptLoader.loadSubScript(uri.spec, srvScope);
+  scriptLoader.loadSubScript(uri.spec, srvScope, "utf-8");
 }
 
 function checkPublicSuffix(host, expectedSuffix)
@@ -21,8 +23,14 @@ function checkPublicSuffix(host, expectedSuffix)
   var actualSuffix = null;
   try {
     actualSuffix = etld.getBaseDomainFromHost(host);
-  } catch (e if e.name == "NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS" ||
-                e.name == "NS_ERROR_ILLEGAL_VALUE") {
+  } catch (e if e.result == Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS ||
+                e.result == Cr.NS_ERROR_ILLEGAL_VALUE) {
+  }
+  // The EffectiveTLDService always gives back punycoded labels.
+  // The test suite wants to get back what it put in.
+  if (actualSuffix !== null && expectedSuffix !== null &&
+      /(^|\.)xn--/.test(actualSuffix) && !/(^|\.)xn--/.test(expectedSuffix)) {
+    actualSuffix = idna.convertACEtoUTF8(actualSuffix);
   }
   do_check_eq(actualSuffix, expectedSuffix);
 }





More information about the tor-commits mailing list