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

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

Issue 4544964214128640: Issue 1841 - Replaced URI class with built-in URL objects (Closed)
Patch Set: Addressed comments Created Jan. 21, 2015, 5:47 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 | « metadata.common ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 23 matching lines...) Expand all
34 ["ftp://example.com/", "example.com"], 34 ["ftp://example.com/", "example.com"],
35 ["http://1.2.3.4:8000/", "1.2.3.4"], 35 ["http://1.2.3.4:8000/", "1.2.3.4"],
36 ["http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/", "2001:0db8:85a3:0000 :0000:8a2e:0370:7334"], 36 ["http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/", "2001:0db8:85a3:0000 :0000:8a2e:0370:7334"],
37 ["http://[2001::7334]:8000/test@foo.example.com/bar", "2001::7334"], 37 ["http://[2001::7334]:8000/test@foo.example.com/bar", "2001::7334"],
38 ]; 38 ];
39 39
40 for (var i = 0; i < tests.length; i++) 40 for (var i = 0; i < tests.length; i++)
41 equal(extractHostFromURL(tests[i][0]), tests[i][1], tests[i][0]); 41 equal(extractHostFromURL(tests[i][0]), tests[i][1], tests[i][0]);
42 }); 42 });
43 43
44 test("Invalid URI recognition", function()
45 {
46 var tests = [
47 null,
48 "",
49 "http:",
50 "http://",
51 "http:foo.bar/"
52 ];
53 for (var i = 0; i < tests.length; i++)
54 {
55 raises(function()
56 {
57 return new URI(tests[i]);
58 }, tests[i]);
59 }
60 });
61
62 test("URI parsing", function()
63 {
64 var tests = [
65 ["http://example.com", {
66 scheme: "http",
67 host: "example.com",
68 asciiHost: "example.com",
69 hostPort: "example.com",
70 port: -1,
71 path: "",
72 prePath: "http://example.com"
73 }],
74 ["http://example.com?foo#bar", {
75 scheme: "http",
76 host: "example.com",
77 asciiHost: "example.com",
78 hostPort: "example.com",
79 port: -1,
80 path: "?foo#bar",
81 prePath: "http://example.com"
82 }],
83 ["http://example.com#foo?bar", {
84 scheme: "http",
85 host: "example.com",
86 asciiHost: "example.com",
87 hostPort: "example.com",
88 port: -1,
89 path: "#foo?bar",
90 prePath: "http://example.com"
91 }],
92 ["http://example.com/", {
93 scheme: "http",
94 host: "example.com",
95 asciiHost: "example.com",
96 hostPort: "example.com",
97 port: -1,
98 path: "/",
99 prePath: "http://example.com"
100 }],
101 ["http://example.com:8000/", {
102 scheme: "http",
103 host: "example.com",
104 asciiHost: "example.com",
105 hostPort: "example.com:8000",
106 port: 8000,
107 path: "/",
108 prePath: "http://example.com:8000"
109 }],
110 ["http://foo:bar@\u0440\u043E\u0441\u0441\u0438\u044F.\u0440\u0444:8000/fo o:bar/bas", {
111 scheme: "http",
112 host: "\u0440\u043E\u0441\u0441\u0438\u044F.\u0440\u0444",
113 asciiHost: "xn--h1alffa9f.xn--p1ai",
114 hostPort: "\u0440\u043E\u0441\u0441\u0438\u044F.\u0440\u0444:8000",
115 port: 8000,
116 path: "/foo:bar/bas",
117 prePath: "http://foo:bar@\u0440\u043E\u0441\u0441\u0438\u044F.\u0440\u04 44:8000"
118 }],
119 ["ftp://m\xFCller.de/", {
120 scheme: "ftp",
121 host: "m\xFCller.de",
122 asciiHost: "xn--mller-kva.de",
123 hostPort: "m\xFCller.de",
124 port: -1,
125 path: "/",
126 prePath: "ftp://m\xFCller.de"
127 }],
128 ["http://1.2.3.4:8000/", {
129 scheme: "http",
130 host: "1.2.3.4",
131 asciiHost: "1.2.3.4",
132 hostPort: "1.2.3.4:8000",
133 port: 8000,
134 path: "/",
135 prePath: "http://1.2.3.4:8000"
136 }],
137 ["http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/", {
138 scheme: "http",
139 host: "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
140 asciiHost: "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
141 hostPort: "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]",
142 port: -1,
143 path: "/",
144 prePath: "http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]"
145 }],
146 ["http://[2001::7334]:8000/test@foo.example.com/bar", {
147 scheme: "http",
148 host: "2001::7334",
149 asciiHost: "2001::7334",
150 hostPort: "[2001::7334]:8000",
151 port: 8000,
152 path: "/test@foo.example.com/bar",
153 prePath: "http://[2001::7334]:8000"
154 }],
155 ];
156
157 for (var i = 0; i < tests.length; i++)
158 {
159 var url = tests[i][0];
160 var uri = new URI(url);
161 equal(uri.spec, url, "URI(" + url + ").spec");
162 for (var k in tests[i][1])
163 equal(uri[k], tests[i][1][k], "URI(" + url + ")." + k);
164 }
165 });
166
167 test("Determining base domain", function() 44 test("Determining base domain", function()
168 { 45 {
169 var tests = [ 46 var tests = [
170 ["com", "com"], 47 ["com", "com"],
171 ["example.com", "example.com"], 48 ["example.com", "example.com"],
172 ["www.example.com", "example.com"], 49 ["www.example.com", "example.com"],
173 ["www.example.com.", "example.com"], 50 ["www.example.com.", "example.com"],
174 ["www.example.co.uk", "example.co.uk"], 51 ["www.example.co.uk", "example.co.uk"],
175 ["www.example.co.uk.", "example.co.uk"], 52 ["www.example.co.uk.", "example.co.uk"],
176 ["www.example.bl.uk", "bl.uk"], 53 ["www.example.bl.uk", "bl.uk"],
(...skipping 27 matching lines...) Expand all
204 ["foo.uk", "bar.uk", true], 81 ["foo.uk", "bar.uk", true],
205 ["foo.co.uk", "bar.co.uk", true], 82 ["foo.co.uk", "bar.co.uk", true],
206 ["foo.example.co.uk", "bar.example.co.uk", false], 83 ["foo.example.co.uk", "bar.example.co.uk", false],
207 ["1.2.3.4", "2.2.3.4", true], 84 ["1.2.3.4", "2.2.3.4", true],
208 ]; 85 ];
209 86
210 for (var i = 0; i < tests.length; i++) 87 for (var i = 0; i < tests.length; i++)
211 equal(isThirdParty(tests[i][0], tests[i][1]), tests[i][2], tests[i][0] + " and " + tests[i][1]); 88 equal(isThirdParty(tests[i][0], tests[i][1]), tests[i][2], tests[i][0] + " and " + tests[i][1]);
212 }); 89 });
213 })(); 90 })();
OLDNEW
« no previous file with comments | « metadata.common ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld