Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 var etld = Cc["@mozilla.org/network/effective-tld-service;1"]
2 .getService(Ci.nsIEffectiveTLDService);
4 var idna = Cc["@mozilla.org/network/idn-service;1"]
5 .getService(Ci.nsIIDNService);
7 var Cr = Components.results;
9 function run_test()
10 {
11 var file = do_get_file("data/test_psl.txt");
12 var ios = Cc["@mozilla.org/network/io-service;1"]
13 .getService(Ci.nsIIOService);
14 var uri = ios.newFileURI(file);
15 var scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
16 .getService(Ci.mozIJSSubScriptLoader);
17 var srvScope = {};
18 scriptLoader.loadSubScript(uri.spec, srvScope, "utf-8");
19 }
21 function checkPublicSuffix(host, expectedSuffix)
22 {
23 var actualSuffix = null;
24 try {
25 actualSuffix = etld.getBaseDomainFromHost(host);
26 } catch (e if e.result == Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS ||
27 e.result == Cr.NS_ERROR_ILLEGAL_VALUE) {
28 }
29 // The EffectiveTLDService always gives back punycoded labels.
30 // The test suite wants to get back what it put in.
31 if (actualSuffix !== null && expectedSuffix !== null &&
32 /(^|\.)xn--/.test(actualSuffix) && !/(^|\.)xn--/.test(expectedSuffix)) {
33 actualSuffix = idna.convertACEtoUTF8(actualSuffix);
34 }
35 do_check_eq(actualSuffix, expectedSuffix);
36 }