summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/url/script-tests/mailto.js
blob: 7786d7fc26a310863ae5360934c8ec41a4a2a4c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
description("Tests mailto: URL canonicalization");

cases = [ 
  ["addr1", "addr1"],
  ["addr1@foo.com", "addr1@foo.com"],

  // Trailing whitespace is stripped.
  ["addr1 \t ", "addr1"],
  ["addr1?to=jon", "addr1?to=jon"],
  ["addr1,addr2", "addr1,addr2"],
  ["addr1, addr2", "addr1, addr2"],
  ["addr1%2caddr2", "addr1%2caddr2"],

  // U+10300 input as UTF-16 surrogate pair, expected as escaped UTF-8
  ["\uD800\uDF00", "%F0%90%8C%80"],
  ["addr1?", "addr1?"],

  // Null character should be escaped to %00
  // Not sure how to test null characters in JavaScript.  They appear to get
  // stripped out.
  // ["addr1\\0addr2?foo", "addr1%00addr2?foo"],
];

for (var i = 0; i < cases.length; ++i) {
  shouldBe("canonicalize('mailto:" + cases[i][0] + "')",
           "'mailto:" + cases[i][1] + "'");
}
  // Invalid -- UTF-8 encoded surrogate value.
shouldBeFalse("canonicalize('mailto:\xed\xa0\x80') == 'mailto:%EF%BF%BD'");
                         
var successfullyParsed = true;