summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/url/script-tests/standard-url.js
blob: 03808a83c90fcef97866c47915ef38bee56ef71c (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
description("Canonicalization of standard URLs");

cases = [ 
  ["http://www.google.com/foo?bar=baz#", "http://www.google.com/foo?bar=baz#"],
  ["http://[www.google.com]/", "http://[www.google.com]/"],
  // Disabled because whitespace gets treated different in this API.
  // ["ht\ttp:@www.google.com:80/;p?#", "ht%09tp://www.google.com:80/;p?#"],
  ["http:////////user:@google.com:99?foo", "http://user@google.com:99/?foo"],
  // Disabled because this gets treated as a relative URL.
  // ["www.google.com", ":www.google.com/"],
  ["http://192.0x00A80001", "http://192.168.0.1/"],
  ["http://www/foo%2Ehtml", "http://www/foo.html"],
  ["http://user:pass@/", "http://user:pass@/"],
  ["http://%25DOMAIN:foobar@foodomain.com/", "http://%25DOMAIN:foobar@foodomain.com/"],
  // Backslashes should get converted to forward slashes.
  ["http:\\\\\\\\www.google.com\\\\foo", "http://www.google.com/foo"],
  // Busted refs shouldn't make the whole thing fail.
  ["http://www.google.com/asdf#\\ud800", "http://www.google.com/asdf#\\uFFFD"],
  // Basic port tests.
  ["http://foo:80/", "http://foo/"],
  ["http://foo:81/", "http://foo:81/"],
  ["httpa://foo:80/", "httpa://foo:80/"],
  ["http://foo:-80/", "http://foo:-80/"],
  ["https://foo:443/", "https://foo/"],
  ["https://foo:80/", "https://foo:80/"],
  ["ftp://foo:21/", "ftp://foo/"],
  ["ftp://foo:80/", "ftp://foo:80/"],
  ["gopher://foo:70/", "gopher://foo/"],
  ["gopher://foo:443/", "gopher://foo:443/"],
  ["ws://foo:80/", "ws://foo/"],
  ["ws://foo:81/", "ws://foo:81/"],
  ["ws://foo:443/", "ws://foo:443/"],
  ["ws://foo:815/", "ws://foo:815/"],
  ["wss://foo:80/", "wss://foo:80/"],
  ["wss://foo:81/", "wss://foo:81/"],
  ["wss://foo:443/", "wss://foo/"],
  ["wss://foo:815/", "wss://foo:815/"],
];

for (var i = 0; i < cases.length; ++i) {
  test_vector = cases[i][0];
  expected_result = cases[i][1];
  shouldBe("canonicalize('" + test_vector + "')",
           "'" + expected_result + "'");
}

var successfullyParsed = true;