5 var idn = Cc["@mozilla.org/network/idn-service;1"].getService(Ci.nsIIDNService);
8 var fis = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(
12 do_get_file("effective_tld_names.dat"),
15 Ci.nsIFileInputStream.CLOSE_ON_EOF
18 var lis = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(
19 Ci.nsIConverterInputStream
21 lis.init(fis, "UTF-8", 1024, 0);
22 lis.QueryInterface(Ci.nsIUnicharLineInputStream);
24 var out = { value: "" };
26 var more = lis.readLine(out);
29 line = line.replace(/^\s+/, "");
30 var firstTwo = line.substring(0, 2); // a misnomer, but whatever
31 if (firstTwo == "" || firstTwo == "//") {
35 var space = line.search(/[ \t]/);
36 line = line.substring(0, space == -1 ? line.length : space);
38 if ("*." == firstTwo) {
39 let rest = line.substring(2);
41 "foo.SUPER-SPECIAL-AWESOME-PREFIX." + rest,
42 "SUPER-SPECIAL-AWESOME-PREFIX." + rest
44 } else if ("!" == line.charAt(0)) {
47 line.substring(line.indexOf(".") + 1)
50 checkPublicSuffix("SUPER-SPECIAL-AWESOME-PREFIX." + line, line);
55 function checkPublicSuffix(host, expectedSuffix) {
56 expectedSuffix = idn.convertUTF8toACE(expectedSuffix).toLowerCase();
57 var actualSuffix = Services.eTLD.getPublicSuffixFromHost(host);
58 Assert.equal(actualSuffix, expectedSuffix);