test_nsEffectiveTLDService_hasKnownPublicSuffix.js (1146B)
1 /* Any copyright is dedicated to the Public Domain. 2 https://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_task(async function () { 7 for (const [host, shouldKnowTld] of [ 8 ["example.com", true], // https://www.iana.org/domains/root/db/com.html 9 ["example.local", false], 10 ["example.vermögensberatung", true], // https://www.iana.org/domains/root/db/xn--vermgensberatung-pwb.html 11 ["example.xn--vermgensberatung-pwb", true], 12 ["example.löcal", false], 13 ["example.xn--lcal-5qa", false], 14 ["localhost", false], 15 ["com", true], 16 ["za", false], 17 ["co.za", true], 18 ["example.co.za", true], 19 ["example.com.", true], 20 ["example.local.", false], 21 ]) { 22 Assert.equal( 23 Services.eTLD.hasKnownPublicSuffixFromHost(host), 24 shouldKnowTld, 25 `"${host}" should ${ 26 shouldKnowTld ? " " : "not " 27 }have a known public suffix` 28 ); 29 Assert.equal( 30 Services.eTLD.hasKnownPublicSuffix(Services.io.newURI("http://" + host)), 31 shouldKnowTld, 32 `"http://${host}" should ${ 33 shouldKnowTld ? " " : "not " 34 }have a known public suffix` 35 ); 36 } 37 });