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.
michael@0 | 1 | var etld = Cc["@mozilla.org/network/effective-tld-service;1"] |
michael@0 | 2 | .getService(Ci.nsIEffectiveTLDService); |
michael@0 | 3 | |
michael@0 | 4 | var idna = Cc["@mozilla.org/network/idn-service;1"] |
michael@0 | 5 | .getService(Ci.nsIIDNService); |
michael@0 | 6 | |
michael@0 | 7 | var Cr = Components.results; |
michael@0 | 8 | |
michael@0 | 9 | function run_test() |
michael@0 | 10 | { |
michael@0 | 11 | var file = do_get_file("data/test_psl.txt"); |
michael@0 | 12 | var ios = Cc["@mozilla.org/network/io-service;1"] |
michael@0 | 13 | .getService(Ci.nsIIOService); |
michael@0 | 14 | var uri = ios.newFileURI(file); |
michael@0 | 15 | var scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"] |
michael@0 | 16 | .getService(Ci.mozIJSSubScriptLoader); |
michael@0 | 17 | var srvScope = {}; |
michael@0 | 18 | scriptLoader.loadSubScript(uri.spec, srvScope, "utf-8"); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | function checkPublicSuffix(host, expectedSuffix) |
michael@0 | 22 | { |
michael@0 | 23 | var actualSuffix = null; |
michael@0 | 24 | try { |
michael@0 | 25 | actualSuffix = etld.getBaseDomainFromHost(host); |
michael@0 | 26 | } catch (e if e.result == Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS || |
michael@0 | 27 | e.result == Cr.NS_ERROR_ILLEGAL_VALUE) { |
michael@0 | 28 | } |
michael@0 | 29 | // The EffectiveTLDService always gives back punycoded labels. |
michael@0 | 30 | // The test suite wants to get back what it put in. |
michael@0 | 31 | if (actualSuffix !== null && expectedSuffix !== null && |
michael@0 | 32 | /(^|\.)xn--/.test(actualSuffix) && !/(^|\.)xn--/.test(expectedSuffix)) { |
michael@0 | 33 | actualSuffix = idna.convertACEtoUTF8(actualSuffix); |
michael@0 | 34 | } |
michael@0 | 35 | do_check_eq(actualSuffix, expectedSuffix); |
michael@0 | 36 | } |