tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_nsEffectiveTLDService_getKnownPublicSuffix.js (1114B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * https://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 /**
      5 * Tests getPublicSuffix with the validate argument.
      6 */
      7 
      8 "use strict";
      9 
     10 add_task(() => {
     11  for (let [suffix, isKnown] of [
     12    ["", false],
     13    [null, false],
     14    ["mozbacon", false],
     15    ["com", true],
     16    ["circle", true],
     17    ["bd", true],
     18    ["gov.bd", true],
     19    ["ck", true],
     20    ["www.ck", true],
     21    ["bs", true],
     22    ["com.bs", true],
     23    ["網絡.cn", true],
     24    ["valléedaoste.it", true],
     25    ["aurskog-høland.no", true],
     26    ["公司.香港", true],
     27    ["भारतम्", true],
     28    ["فلسطين", true],
     29    ["example.com.", true],
     30  ]) {
     31    let origin = "test." + suffix;
     32    Assert.equal(
     33      !!Services.eTLD.getKnownPublicSuffixFromHost(origin),
     34      isKnown,
     35      `"${suffix}" should ${isKnown ? " " : "not "}be a known public suffix`
     36    );
     37    Assert.equal(
     38      !!Services.eTLD.getKnownPublicSuffix(
     39        Services.io.newURI("http://" + origin)
     40      ),
     41      isKnown,
     42      `"${suffix}" should ${isKnown ? " " : "not "}be a known public suffix`
     43    );
     44  }
     45 });