Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / netwerk / test / unit / test_psl.js
blobd9c0c2965d6479f2a2e75050f86a741c9dfad190
1 "use strict";
3 var idna = Cc["@mozilla.org/network/idn-service;1"].getService(
4 Ci.nsIIDNService
5 );
7 function run_test() {
8 var file = do_get_file("data/test_psl.txt");
9 var uri = Services.io.newFileURI(file);
10 var srvScope = {};
11 Services.scriptloader.loadSubScript(uri.spec, srvScope);
14 // Exported to the loaded script
15 /* exported checkPublicSuffix */
16 function checkPublicSuffix(host, expectedSuffix) {
17 var actualSuffix = null;
18 try {
19 actualSuffix = Services.eTLD.getBaseDomainFromHost(host);
20 } catch (e) {
21 if (
22 e.result != Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS &&
23 e.result != Cr.NS_ERROR_ILLEGAL_VALUE
24 ) {
25 throw e;
28 // The EffectiveTLDService always gives back punycoded labels.
29 // The test suite wants to get back what it put in.
30 if (
31 actualSuffix !== null &&
32 expectedSuffix !== null &&
33 /(^|\.)xn--/.test(actualSuffix) &&
34 !/(^|\.)xn--/.test(expectedSuffix)
35 ) {
36 actualSuffix = idna.convertACEtoUTF8(actualSuffix);
38 Assert.equal(actualSuffix, expectedSuffix);