Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: qunit/tests/baseDomain.js

Issue 8401061: Added handling of $sitekey exceptions (Closed)
Patch Set: Created Sept. 25, 2012, 2:08 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « manifest.json ('k') | webrequest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 (function() 1 (function()
2 { 2 {
3 module("URL/host tools"); 3 module("URL/host tools");
4 4
5 test("Host name extraction", function() 5 test("Host name extraction", function()
6 { 6 {
7 var tests = [ 7 var tests = [
8 [null, ""],
9 ["/foo/bar", ""],
8 ["http://example.com/", "example.com"], 10 ["http://example.com/", "example.com"],
9 ["http://example.com:8000/", "example.com"], 11 ["http://example.com:8000/", "example.com"],
10 ["http://foo:bar@example.com:8000/", "example.com"], 12 ["http://foo:bar@example.com:8000/foo:bar/bas", "example.com"],
11 ["ftp://example.com/", "example.com"], 13 ["ftp://example.com/", "example.com"],
12 ["http://1.2.3.4:8000/", "1.2.3.4"], 14 ["http://1.2.3.4:8000/", "1.2.3.4"],
13 ["http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/", "2001:0db8:85a3:0000 :0000:8a2e:0370:7334"], 15 ["http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/", "2001:0db8:85a3:0000 :0000:8a2e:0370:7334"],
14 ["http://[2001::7334]:8000/test@foo.example.com/bar", "2001::7334"], 16 ["http://[2001::7334]:8000/test@foo.example.com/bar", "2001::7334"],
15 ]; 17 ];
16 18
17 for (var i = 0; i < tests.length; i++) 19 for (var i = 0; i < tests.length; i++)
18 equal(extractHostFromURL(tests[i][0]), tests[i][1], tests[i][0]); 20 equal(extractHostFromURL(tests[i][0]), tests[i][1], tests[i][0]);
19 }); 21 });
20 22
23 test("Invalid URI recognition", function()
24 {
25 var tests = [
26 null,
27 "",
28 "http:",
29 "http:foo.bar/",
30 "http://foo.bar"
31 ];
32 for (var i = 0; i < tests.length; i++)
33 {
34 raises(function()
35 {
36 return new URI(tests[i]);
37 }, tests[i]);
38 }
39 });
40
41 test("URI parsing", function()
42 {
43 var tests = [
44 ["http://example.com/", {
45 scheme: "http",
46 host: "example.com",
47 asciiHost: "example.com",
48 hostPort: "example.com",
49 port: -1,
50 path: "/",
51 prePath: "http://example.com"
52 }],
53 ["http://example.com:8000/", {
54 scheme: "http",
55 host: "example.com",
56 asciiHost: "example.com",
57 hostPort: "example.com:8000",
58 port: 8000,
59 path: "/",
60 prePath: "http://example.com:8000"
61 }],
62 ["http://foo:bar@\u0440\u043E\u0441\u0441\u0438\u044F.\u0440\u0444:8000/fo o:bar/bas", {
63 scheme: "http",
64 host: "\u0440\u043E\u0441\u0441\u0438\u044F.\u0440\u0444",
65 asciiHost: "xn--h1alffa9f.xn--p1ai",
66 hostPort: "\u0440\u043E\u0441\u0441\u0438\u044F.\u0440\u0444:8000",
67 port: 8000,
68 path: "/foo:bar/bas",
69 prePath: "http://foo:bar@\u0440\u043E\u0441\u0441\u0438\u044F.\u0440\u04 44:8000"
70 }],
71 ["ftp://m\xFCller.de/", {
72 scheme: "ftp",
73 host: "m\xFCller.de",
74 asciiHost: "xn--mller-kva.de",
75 hostPort: "m\xFCller.de",
76 port: -1,
77 path: "/",
78 prePath: "ftp://m\xFCller.de"
79 }],
80 ["http://1.2.3.4:8000/", {
81 scheme: "http",
82 host: "1.2.3.4",
83 asciiHost: "1.2.3.4",
84 hostPort: "1.2.3.4:8000",
85 port: 8000,
86 path: "/",
87 prePath: "http://1.2.3.4:8000"
88 }],
89 ["http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/", {
90 scheme: "http",
91 host: "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
92 asciiHost: "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
93 hostPort: "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]",
94 port: -1,
95 path: "/",
96 prePath: "http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]"
97 }],
98 ["http://[2001::7334]:8000/test@foo.example.com/bar", {
99 scheme: "http",
100 host: "2001::7334",
101 asciiHost: "2001::7334",
102 hostPort: "[2001::7334]:8000",
103 port: 8000,
104 path: "/test@foo.example.com/bar",
105 prePath: "http://[2001::7334]:8000"
106 }],
107 ];
108
109 for (var i = 0; i < tests.length; i++)
110 {
111 var url = tests[i][0];
112 var uri = new URI(url);
113 equal(uri.spec, url, "URI(" + url + ").spec");
114 for (var k in tests[i][1])
115 equal(uri[k], tests[i][1][k], "URI(" + url + ")." + k);
116 }
117 });
118
21 test("Determining base domain", function() 119 test("Determining base domain", function()
22 { 120 {
23 var tests = [ 121 var tests = [
24 ["com", "com"], 122 ["com", "com"],
25 ["example.com", "example.com"], 123 ["example.com", "example.com"],
26 ["www.example.com", "example.com"], 124 ["www.example.com", "example.com"],
27 ["www.example.com.", "example.com"], 125 ["www.example.com.", "example.com"],
28 ["www.example.co.uk", "example.co.uk"], 126 ["www.example.co.uk", "example.co.uk"],
29 ["www.example.co.uk.", "example.co.uk"], 127 ["www.example.co.uk.", "example.co.uk"],
30 ["www.example.bl.uk", "bl.uk"], 128 ["www.example.bl.uk", "bl.uk"],
(...skipping 27 matching lines...) Expand all
58 ["foo.uk", "bar.uk", true], 156 ["foo.uk", "bar.uk", true],
59 ["foo.co.uk", "bar.co.uk", true], 157 ["foo.co.uk", "bar.co.uk", true],
60 ["foo.example.co.uk", "bar.example.co.uk", false], 158 ["foo.example.co.uk", "bar.example.co.uk", false],
61 ["1.2.3.4", "2.2.3.4", true], 159 ["1.2.3.4", "2.2.3.4", true],
62 ]; 160 ];
63 161
64 for (var i = 0; i < tests.length; i++) 162 for (var i = 0; i < tests.length; i++)
65 equal(isThirdParty(tests[i][0], tests[i][1]), tests[i][2], tests[i][0] + " and " + tests[i][1]); 163 equal(isThirdParty(tests[i][0], tests[i][1]), tests[i][2], tests[i][0] + " and " + tests[i][1]);
66 }); 164 });
67 })(); 165 })();
OLDNEW
« no previous file with comments | « manifest.json ('k') | webrequest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld