netwerk/test/unit/test_bug479413.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 /**
     2  * Test for unassigned code points in IDNs (RFC 3454 section 7)
     3  */
     5 var idnService;
     7 function expected_pass(inputIDN)
     8 {
     9   var isASCII = {};
    10   var displayIDN = idnService.convertToDisplayIDN(inputIDN, isASCII);
    11   do_check_eq(displayIDN, inputIDN);
    12 }
    14 function expected_fail(inputIDN)
    15 {
    16   var isASCII = {};
    17   var displayIDN = "";
    19   try {
    20     displayIDN = idnService.convertToDisplayIDN(inputIDN, isASCII);
    21   }
    22   catch(e) {}
    24   do_check_neq(displayIDN, inputIDN);
    25 }
    27 function run_test() {
    28    // add an IDN whitelist pref
    29   var pbi = Cc["@mozilla.org/preferences-service;1"]
    30     .getService(Ci.nsIPrefBranch);
    31   var whitelistPref = "network.IDN.whitelist.com";
    33   pbi.setBoolPref(whitelistPref, true);
    35   idnService = Cc["@mozilla.org/network/idn-service;1"]
    36     .getService(Ci.nsIIDNService);
    38   // assigned code point
    39   expected_pass("foo\u0101bar.com");
    41   // assigned code point in punycode. Should *fail* because the URL will be
    42   // converted to Unicode for display
    43   expected_fail("xn--foobar-5za.com");
    45   // unassigned code point
    46   expected_fail("foo\u3040bar.com");
    48   // unassigned code point in punycode. Should *pass* because the URL will not
    49   // be converted to Unicode
    50   expected_pass("xn--foobar-533e.com");
    52   // code point assigned since Unicode 3.0
    53   // XXX This test will unexpectedly pass when we update to IDNAbis
    54   expected_fail("foo\u0370bar.com");
    56   // reset the pref
    57   if (pbi.prefHasUserValue(whitelistPref))
    58     pbi.clearUserPref(whitelistPref);
    59 }

mercurial