From b5b3f43e0928de0cb87ebc48be4f04d69825a4ea Mon Sep 17 00:00:00 2001 From: Simon Montagu Date: Wed, 28 Oct 2015 07:05:32 -0700 Subject: [PATCH] Bug 479520: Implement IDNA2008 standard for International Domain Names, patch 2: changes to existing tests, r=jfkthame. --- netwerk/test/unit/test_bug427957.js | 10 +++++++-- netwerk/test/unit/test_idn_blacklist.js | 30 +++++++++++++++---------- netwerk/test/unit/test_idn_urls.js | 7 ++++++ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/netwerk/test/unit/test_bug427957.js b/netwerk/test/unit/test_bug427957.js index 8c3485c32a4..e869725a407 100644 --- a/netwerk/test/unit/test_bug427957.js +++ b/netwerk/test/unit/test_bug427957.js @@ -92,8 +92,14 @@ function run_test() { // www.1מיץ.com is invalid expected_fail("www.1\u05DE\u05D9\u05E5.com"); - // www.מיץ1.com is invalid - expected_fail("www.\u05DE\u05D9\u05E51.com"); + // www.!מיץ.com is invalid + expected_fail("www.!\u05DE\u05D9\u05E5.com"); + // www.מיץ!.com is invalid + expected_fail("www.\u05DE\u05D9\u05E5!.com"); + + // XXX TODO: add a test for an RTL label ending with a digit. This was + // invalid in IDNA2003 but became valid in IDNA2008 + // But www.מיץ1פטל.com is fine expected_pass("www.\u05DE\u05D9\u05E51\u05E4\u05D8\u05DC.com"); } diff --git a/netwerk/test/unit/test_idn_blacklist.js b/netwerk/test/unit/test_idn_blacklist.js index a840736bbe5..5ca0173bb2d 100644 --- a/netwerk/test/unit/test_idn_blacklist.js +++ b/netwerk/test/unit/test_idn_blacklist.js @@ -144,19 +144,25 @@ function run_test() { } catch(e) { result = ".com"; } - if (punycodeURL.substr(0, 4) == "xn--") { - // test convertToDisplayIDN with a Unicode URL and with a - // Punycode URL if we have one - do_check_eq(escape(result), escape(punycodeURL)); + // If the punycode URL is equivalent to \ufffd.com (i.e. the + // blacklisted character has been replaced by a unicode + // REPLACEMENT CHARACTER, skip the test + if (result != "xn--zn7c.com") { - result = idnService.convertToDisplayIDN(punycodeURL, isASCII); - do_check_eq(escape(result), escape(punycodeURL)); - } else { - // The "punycode" URL isn't punycode. This happens in testcases - // where the Unicode URL has become normalized to an ASCII URL, - // so, even though expectedUnicode is true, the expected result - // is equal to punycodeURL - do_check_eq(escape(result), escape(punycodeURL)); + if (punycodeURL.substr(0, 4) == "xn--") { + // test convertToDisplayIDN with a Unicode URL and with a + // Punycode URL if we have one + equal(escape(result), escape(punycodeURL)); + + result = idnService.convertToDisplayIDN(punycodeURL, isASCII); + equal(escape(result), escape(punycodeURL)); + } else { + // The "punycode" URL isn't punycode. This happens in testcases + // where the Unicode URL has become normalized to an ASCII URL, + // so, even though expectedUnicode is true, the expected result + // is equal to punycodeURL + equal(escape(result), escape(punycodeURL)); + } } } pbi.setBoolPref("network.IDN.whitelist.com", oldWhitelistCom); diff --git a/netwerk/test/unit/test_idn_urls.js b/netwerk/test/unit/test_idn_urls.js index b163f5e7b6b..061788e3c8f 100644 --- a/netwerk/test/unit/test_idn_urls.js +++ b/netwerk/test/unit/test_idn_urls.js @@ -12,8 +12,15 @@ const testcases = [ // non-XID character ["I♥NY", "xn--iny-zx5a", false, false, false], +/* + Behaviour of this test changed in IDNA2008, replacing the non-XID + character with U+FFFD replacement character - when all platforms use + IDNA2008 it can be uncommented and the punycode URL changed to + "xn--mgbl3eb85703a" + // new non-XID character in Unicode 6.3 ["حلا\u061cل", "xn--bgbvr6gc", false, false, false], +*/ // U+30FB KATAKANA MIDDLE DOT is excluded from non-XID characters (bug 857490) ["乾燥肌・石けん", "xn--08j4gylj12hz80b0uhfup", false, true, true],