Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / netwerk / test / unit / test_idna2008.js
blob0e0290ce795291a692205f92cb38137fd8391f8a
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 const kTransitionalProcessing = false;
9 // Four characters map differently under non-transitional processing:
10 const labels = [
11 // U+00DF LATIN SMALL LETTER SHARP S to "ss"
12 "stra\u00dfe",
13 // U+03C2 GREEK SMALL LETTER FINAL SIGMA to U+03C3 GREEK SMALL LETTER SIGMA
14 "\u03b5\u03bb\u03bb\u03ac\u03c2",
15 // U+200C ZERO WIDTH NON-JOINER in Indic script
16 "\u0646\u0627\u0645\u0647\u200c\u0627\u06cc",
17 // U+200D ZERO WIDTH JOINER in Arabic script
18 "\u0dc1\u0dca\u200d\u0dbb\u0dd3",
20 // But CONTEXTJ rules prohibit ZWJ and ZWNJ in non-Arabic or Indic scripts
21 // U+200C ZERO WIDTH NON-JOINER in Latin script
22 "m\u200cn",
23 // U+200D ZERO WIDTH JOINER in Latin script
24 "p\u200dq",
27 const transitionalExpected = [
28 "strasse",
29 "xn--hxarsa5b",
30 "xn--mgba3gch31f",
31 "xn--10cl1a0b",
32 "",
33 "",
36 const nonTransitionalExpected = [
37 "xn--strae-oqa",
38 "xn--hxarsa0b",
39 "xn--mgba3gch31f060k",
40 "xn--10cl1a0b660p",
41 "",
42 "",
45 // Test options for converting IDN URLs under IDNA2008
46 function run_test() {
47 var idnService = Cc["@mozilla.org/network/idn-service;1"].getService(
48 Ci.nsIIDNService
51 for (var i = 0; i < labels.length; ++i) {
52 var result;
53 try {
54 result = idnService.convertUTF8toACE(labels[i]);
55 } catch (e) {
56 result = "";
59 if (kTransitionalProcessing) {
60 equal(result, transitionalExpected[i]);
61 } else {
62 equal(result, nonTransitionalExpected[i]);