Bug 479520: Implement IDNA2008 standard for International Domain Names, patch 2: changes to existing tests, r=jfkthame.

This commit is contained in:
Simon Montagu 2015-10-28 07:05:32 -07:00
parent b43cdcd175
commit b5b3f43e09
3 changed files with 33 additions and 14 deletions

View File

@ -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");
}

View File

@ -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);

View File

@ -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],