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

Side by Side Diff: test/regexpFilters_matching.js

Issue 29354864: Issue 4223 - Migrate some more of adblockplustests (Closed)
Patch Set: Fixed typo in test_runner.js Created Oct. 4, 2016, 9:42 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 "use strict";
19
20 let {createSandbox} = require("./common");
21
22 let Filter = null;
23 let RegExpFilter = null;
24
25 exports.setUp = function(callback)
26 {
27 let sandboxedRequire = createSandbox();
28 (
29 {Filter, RegExpFilter} = sandboxedRequire("filterClasses")
30 );
31
32 callback();
33 };
34
35
36
37 function testMatch(test, text, location, contentType, docDomain, thirdParty, sit ekey, expected)
38 {
39 function testMatch_internal(text, location, contentType, docDomain, thirdParty , sitekey, expected)
40 {
41 let filter = Filter.fromText(text);
42 let result = filter.matches(location, RegExpFilter.typeMap[contentType], doc Domain, thirdParty, sitekey);
43 test.equal(!!result, expected, '"' + text + '".matches(' + location + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-pa rty") + ", " + (sitekey || "no-sitekey") + ")");
44 }
45 testMatch_internal(text, location, contentType, docDomain, thirdParty, sitekey , expected);
46 if (!/^@@/.test(text))
47 testMatch_internal("@@" + text, location, contentType, docDomain, thirdParty , sitekey, expected);
48 }
49
50 exports.testBasicFilters = function(test)
51 {
52 testMatch(test, "abc", "http://abc/adf", "IMAGE", null, false, null, true);
53 testMatch(test, "abc", "http://ABC/adf", "IMAGE", null, false, null, true);
54 testMatch(test, "abc", "http://abd/adf", "IMAGE", null, false, null, false);
55 testMatch(test, "|abc", "http://abc/adf", "IMAGE", null, false, null, false);
56 testMatch(test, "|http://abc", "http://abc/adf", "IMAGE", null, false, null, t rue);
57 testMatch(test, "abc|", "http://abc/adf", "IMAGE", null, false, null, false);
58 testMatch(test, "abc/adf|", "http://abc/adf", "IMAGE", null, false, null, true );
59 testMatch(test, "||example.com/foo", "http://example.com/foo/bar", "IMAGE", nu ll, false, null, true);
60 testMatch(test, "||com/foo", "http://example.com/foo/bar", "IMAGE", null, fals e, null, true);
61 testMatch(test, "||mple.com/foo", "http://example.com/foo/bar", "IMAGE", null, false, null, false);
62 testMatch(test, "||/example.com/foo", "http://example.com/foo/bar", "IMAGE", n ull, false, null, false);
63 testMatch(test, "||example.com/foo/bar|", "http://example.com/foo/bar", "IMAGE ", null, false, null, true);
64 testMatch(test, "||example.com/foo", "http://foo.com/http://example.com/foo/ba r", "IMAGE", null, false, null, false);
65 testMatch(test, "||example.com/foo|", "http://example.com/foo/bar", "IMAGE", n ull, false, null, false);
66
67 test.done();
68 };
69
70 exports.testSeparatorPlaceholders = function(test)
71 {
72 testMatch(test, "abc^d", "http://abc/def", "IMAGE", null, false, null, true);
73 testMatch(test, "abc^e", "http://abc/def", "IMAGE", null, false, null, false);
74 testMatch(test, "def^", "http://abc/def", "IMAGE", null, false, null, true);
75 testMatch(test, "http://abc/d^f", "http://abc/def", "IMAGE", null, false, null , false);
76 testMatch(test, "http://abc/def^", "http://abc/def", "IMAGE", null, false, nul l, true);
77 testMatch(test, "^foo=bar^", "http://abc/?foo=bar", "IMAGE", null, false, null , true);
78 testMatch(test, "^foo=bar^", "http://abc/?a=b&foo=bar", "IMAGE", null, false, null, true);
79 testMatch(test, "^foo=bar^", "http://abc/?foo=bar&a=b", "IMAGE", null, false, null, true);
80 testMatch(test, "^foo=bar^", "http://abc/?notfoo=bar", "IMAGE", null, false, n ull, false);
81 testMatch(test, "^foo=bar^", "http://abc/?foo=barnot", "IMAGE", null, false, n ull, false);
82 testMatch(test, "^foo=bar^", "http://abc/?foo=bar%2Enot", "IMAGE", null, false , null, false);
83 testMatch(test, "||example.com^", "http://example.com/foo/bar", "IMAGE", null, false, null, true);
84 testMatch(test, "||example.com^", "http://example.company.com/foo/bar", "IMAGE ", null, false, null, false);
85 testMatch(test, "||example.com^", "http://example.com:1234/foo/bar", "IMAGE", null, false, null, true);
86 testMatch(test, "||example.com^", "http://example.com.com/foo/bar", "IMAGE", n ull, false, null, false);
87 testMatch(test, "||example.com^", "http://example.com-company.com/foo/bar", "I MAGE", null, false, null, false);
88 testMatch(test, "||example.com^foo", "http://example.com/foo/bar", "IMAGE", nu ll, false, null, true);
89 testMatch(test, "||пример.ру^", "http://пример.ру/foo/bar", "IMAGE", null, fal se, null, true);
90 testMatch(test, "||пример.ру^", "http://пример.руководитель.ру/foo/bar", "IMAG E", null, false, null, false);
91 testMatch(test, "||пример.ру^", "http://пример.ру:1234/foo/bar", "IMAGE", null , false, null, true);
92 testMatch(test, "||пример.ру^", "http://пример.ру.ру/foo/bar", "IMAGE", null, false, null, false);
93 testMatch(test, "||пример.ру^", "http://пример.ру-ководитель.ру/foo/bar", "IMA GE", null, false, null, false);
94 testMatch(test, "||пример.ру^foo", "http://пример.ру/foo/bar", "IMAGE", null, false, null, true);
95
96 test.done();
97 };
98
99 exports.testWildcardMatching = function(test)
100 {
101 testMatch(test, "abc*d", "http://abc/adf", "IMAGE", null, false, null, true);
102 testMatch(test, "abc*d", "http://abcd/af", "IMAGE", null, false, null, true);
103 testMatch(test, "abc*d", "http://abc/d/af", "IMAGE", null, false, null, true);
104 testMatch(test, "abc*d", "http://dabc/af", "IMAGE", null, false, null, false);
105 testMatch(test, "*abc", "http://abc/adf", "IMAGE", null, false, null, true);
106 testMatch(test, "abc*", "http://abc/adf", "IMAGE", null, false, null, true);
107 testMatch(test, "|*abc", "http://abc/adf", "IMAGE", null, false, null, true);
108 testMatch(test, "abc*|", "http://abc/adf", "IMAGE", null, false, null, true);
109 testMatch(test, "abc***d", "http://abc/adf", "IMAGE", null, false, null, true) ;
110
111 test.done();
112 };
113
114 exports.testTypeOptions = function(test)
115 {
116 testMatch(test, "abc$image", "http://abc/adf", "IMAGE", null, false, null, tru e);
117 testMatch(test, "abc$other", "http://abc/adf", "IMAGE", null, false, null, fal se);
118 testMatch(test, "abc$other", "http://abc/adf", "OTHER", null, false, null, tru e);
119 testMatch(test, "abc$~other", "http://abc/adf", "OTHER", null, false, null, fa lse);
120 testMatch(test, "abc$script", "http://abc/adf", "IMAGE", null, false, null, fa lse);
121 testMatch(test, "abc$script", "http://abc/adf", "SCRIPT", null, false, null, t rue);
122 testMatch(test, "abc$~script", "http://abc/adf", "SCRIPT", null, false, null, false);
123 testMatch(test, "abc$stylesheet", "http://abc/adf", "IMAGE", null, false, null , false);
124 testMatch(test, "abc$stylesheet", "http://abc/adf", "STYLESHEET", null, false, null, true);
125 testMatch(test, "abc$~stylesheet", "http://abc/adf", "STYLESHEET", null, false , null, false);
126 testMatch(test, "abc$object", "http://abc/adf", "IMAGE", null, false, null, fa lse);
127 testMatch(test, "abc$object", "http://abc/adf", "OBJECT", null, false, null, t rue);
128 testMatch(test, "abc$~object", "http://abc/adf", "OBJECT", null, false, null, false);
129 testMatch(test, "abc$document", "http://abc/adf", "IMAGE", null, false, null, false);
130 testMatch(test, "abc$document", "http://abc/adf", "DOCUMENT", null, false, nul l, true);
131 testMatch(test, "abc$~document", "http://abc/adf", "DOCUMENT", null, false, nu ll, false);
132 testMatch(test, "abc$subdocument", "http://abc/adf", "IMAGE", null, false, nul l, false);
133 testMatch(test, "abc$subdocument", "http://abc/adf", "SUBDOCUMENT", null, fals e, null, true);
134 testMatch(test, "abc$~subdocument", "http://abc/adf", "SUBDOCUMENT", null, fal se, null, false);
135 testMatch(test, "abc$background", "http://abc/adf", "OBJECT", null, false, nul l, false);
136 testMatch(test, "abc$background", "http://abc/adf", "IMAGE", null, false, null , true);
137 testMatch(test, "abc$~background", "http://abc/adf", "IMAGE", null, false, nul l, false);
138 testMatch(test, "abc$xbl", "http://abc/adf", "IMAGE", null, false, null, false );
139 testMatch(test, "abc$xbl", "http://abc/adf", "XBL", null, false, null, true);
140 testMatch(test, "abc$~xbl", "http://abc/adf", "XBL", null, false, null, false) ;
141 testMatch(test, "abc$ping", "http://abc/adf", "IMAGE", null, false, null, fals e);
142 testMatch(test, "abc$ping", "http://abc/adf", "PING", null, false, null, true) ;
143 testMatch(test, "abc$~ping", "http://abc/adf", "PING", null, false, null, fals e);
144 testMatch(test, "abc$xmlhttprequest", "http://abc/adf", "IMAGE", null, false, null, false);
145 testMatch(test, "abc$xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", null , false, null, true);
146 testMatch(test, "abc$~xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", nul l, false, null, false);
147 testMatch(test, "abc$object-subrequest", "http://abc/adf", "IMAGE", null, fals e, null, false);
148 testMatch(test, "abc$object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST" , null, false, null, true);
149 testMatch(test, "abc$~object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST ", null, false, null, false);
150 testMatch(test, "abc$dtd", "http://abc/adf", "IMAGE", null, false, null, false );
151 testMatch(test, "abc$dtd", "http://abc/adf", "DTD", null, false, null, true);
152 testMatch(test, "abc$~dtd", "http://abc/adf", "DTD", null, false, null, false) ;
153
154 testMatch(test, "abc$media", "http://abc/adf", "IMAGE", null, false, null, fal se);
155 testMatch(test, "abc$media", "http://abc/adf", "MEDIA", null, false, null, tru e);
156 testMatch(test, "abc$~media", "http://abc/adf", "MEDIA", null, false, null, fa lse);
157
158 testMatch(test, "abc$font", "http://abc/adf", "IMAGE", null, false, null, fals e);
159 testMatch(test, "abc$font", "http://abc/adf", "FONT", null, false, null, true) ;
160 testMatch(test, "abc$~font", "http://abc/adf", "FONT", null, false, null, fals e);
161
162 testMatch(test, "abc$ping", "http://abc/adf", "IMAGE", null, false, null, fals e);
163 testMatch(test, "abc$ping", "http://abc/adf", "PING", null, false, null, true) ;
164 testMatch(test, "abc$~ping", "http://abc/adf", "PING", null, false, null, fals e);
165
166 testMatch(test, "abc$image,script", "http://abc/adf", "IMAGE", null, false, nu ll, true);
167 testMatch(test, "abc$~image", "http://abc/adf", "IMAGE", null, false, null, fa lse);
168 testMatch(test, "abc$~script", "http://abc/adf", "IMAGE", null, false, null, t rue);
169 testMatch(test, "abc$~image,~script", "http://abc/adf", "IMAGE", null, false, null, false);
170 testMatch(test, "abc$~script,~image", "http://abc/adf", "IMAGE", null, false, null, false);
171 testMatch(test, "abc$~document,~script,~other", "http://abc/adf", "IMAGE", nul l, false, null, true);
172 testMatch(test, "abc$~image,image", "http://abc/adf", "IMAGE", null, false, nu ll, true);
173 testMatch(test, "abc$image,~image", "http://abc/adf", "IMAGE", null, false, nu ll, false);
174 testMatch(test, "abc$~image,image", "http://abc/adf", "SCRIPT", null, false, n ull, true);
175 testMatch(test, "abc$image,~image", "http://abc/adf", "SCRIPT", null, false, n ull, false);
176 testMatch(test, "abc$match-case", "http://abc/adf", "IMAGE", null, false, null , true);
177 testMatch(test, "abc$match-case", "http://ABC/adf", "IMAGE", null, false, null , false);
178 testMatch(test, "abc$~match-case", "http://abc/adf", "IMAGE", null, false, nul l, true);
179 testMatch(test, "abc$~match-case", "http://ABC/adf", "IMAGE", null, false, nul l, true);
180 testMatch(test, "abc$match-case,image", "http://abc/adf", "IMAGE", null, false , null, true);
181 testMatch(test, "abc$match-case,script", "http://abc/adf", "IMAGE", null, fals e, null, false);
182 testMatch(test, "abc$match-case,image", "http://ABC/adf", "IMAGE", null, false , null, false);
183 testMatch(test, "abc$match-case,script", "http://ABC/adf", "IMAGE", null, fals e, null, false);
184 testMatch(test, "abc$third-party", "http://abc/adf", "IMAGE", null, false, nul l, false);
185 testMatch(test, "abc$third-party", "http://abc/adf", "IMAGE", null, true, null , true);
186 testMatch(test, "abd$third-party", "http://abc/adf", "IMAGE", null, false, nul l, false);
187 testMatch(test, "abd$third-party", "http://abc/adf", "IMAGE", null, true, null , false);
188 testMatch(test, "abc$image,third-party", "http://abc/adf", "IMAGE", null, fals e, null, false);
189 testMatch(test, "abc$image,third-party", "http://abc/adf", "IMAGE", null, true , null, true);
190 testMatch(test, "abc$~image,third-party", "http://abc/adf", "IMAGE", null, fal se, null, false);
191 testMatch(test, "abc$~image,third-party", "http://abc/adf", "IMAGE", null, tru e, null, false);
192 testMatch(test, "abc$~third-party", "http://abc/adf", "IMAGE", null, false, nu ll, true);
193 testMatch(test, "abc$~third-party", "http://abc/adf", "IMAGE", null, true, nul l, false);
194 testMatch(test, "abd$~third-party", "http://abc/adf", "IMAGE", null, false, nu ll, false);
195 testMatch(test, "abd$~third-party", "http://abc/adf", "IMAGE", null, true, nul l, false);
196 testMatch(test, "abc$image,~third-party", "http://abc/adf", "IMAGE", null, fal se, null, true);
197 testMatch(test, "abc$image,~third-party", "http://abc/adf", "IMAGE", null, tru e, null, false);
198 testMatch(test, "abc$~image,~third-party", "http://abc/adf", "IMAGE", null, fa lse, null, false);
199
200 test.done();
201 };
202
203 exports.testRegularExpressions = function(test)
204 {
205 testMatch(test, "/abc/", "http://abc/adf", "IMAGE", null, false, null, true);
206 testMatch(test, "/abc/", "http://abcd/adf", "IMAGE", null, false, null, true);
207 testMatch(test, "*/abc/", "http://abc/adf", "IMAGE", null, false, null, true);
208 testMatch(test, "*/abc/", "http://abcd/adf", "IMAGE", null, false, null, false );
209 testMatch(test, "/a\\wc/", "http://abc/adf", "IMAGE", null, false, null, true) ;
210 testMatch(test, "/a\\wc/", "http://a1c/adf", "IMAGE", null, false, null, true) ;
211 testMatch(test, "/a\\wc/", "http://a_c/adf", "IMAGE", null, false, null, true) ;
212 testMatch(test, "/a\\wc/", "http://a%c/adf", "IMAGE", null, false, null, false );
213
214 test.done();
215 };
216
217 exports.testRegularExpressionsWithTypeOptions = function(test)
218 {
219 testMatch(test, "/abc/$image", "http://abc/adf", "IMAGE", null, false, null, t rue);
220 testMatch(test, "/abc/$image", "http://aBc/adf", "IMAGE", null, false, null, t rue);
221 testMatch(test, "/abc/$script", "http://abc/adf", "IMAGE", null, false, null, false);
222 testMatch(test, "/abc/$~image", "http://abcd/adf", "IMAGE", null, false, null, false);
223 testMatch(test, "/ab{2}c/$image", "http://abc/adf", "IMAGE", null, false, null , false);
224 testMatch(test, "/ab{2}c/$script", "http://abc/adf", "IMAGE", null, false, nul l, false);
225 testMatch(test, "/ab{2}c/$~image", "http://abcd/adf", "IMAGE", null, false, nu ll, false);
226 testMatch(test, "/abc/$third-party", "http://abc/adf", "IMAGE", null, false, n ull, false);
227 testMatch(test, "/abc/$third-party", "http://abc/adf", "IMAGE", null, true, nu ll, true);
228 testMatch(test, "/abc/$~third-party", "http://abc/adf", "IMAGE", null, false, null, true);
229 testMatch(test, "/abc/$~third-party", "http://abc/adf", "IMAGE", null, true, n ull, false);
230 testMatch(test, "/abc/$match-case", "http://abc/adf", "IMAGE", null, false, nu ll, true);
231 testMatch(test, "/abc/$match-case", "http://aBc/adf", "IMAGE", null, true, nul l, false);
232 testMatch(test, "/ab{2}c/$match-case", "http://abc/adf", "IMAGE", null, false, null, false);
233 testMatch(test, "/ab{2}c/$match-case", "http://aBc/adf", "IMAGE", null, true, null, false);
234 testMatch(test, "/abc/$~match-case", "http://abc/adf", "IMAGE", null, false, n ull, true);
235 testMatch(test, "/abc/$~match-case", "http://aBc/adf", "IMAGE", null, true, nu ll, true);
236 testMatch(test, "/ab{2}c/$~match-case", "http://abc/adf", "IMAGE", null, false , null, false);
237 testMatch(test, "/ab{2}c/$~match-case", "http://aBc/adf", "IMAGE", null, true, null, false);
238
239 test.done();
240 };
241
242 exports.testDomainRestrictions = function(test)
243 {
244 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com", tr ue, null, true);
245 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com.", t rue, null, true);
246 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com" , true, null, true);
247 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com. ", true, null, true);
248 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "Foo.com", tr ue, null, true);
249 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "abc.def.foo. com", true, null, true);
250 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.baz.com" , true, null, false);
251 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", null, true, n ull, false);
252 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo. com", true, null, true);
253 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo. com.", true, null, true);
254 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. foo.com", true, null, true);
255 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. foo.com.", true, null, true);
256 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "Foo. com", true, null, true);
257 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "abc. def.foo.com", true, null, true);
258 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. baz.com", true, null, false);
259 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", null, true, null, false);
260 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo. com", true, null, true);
261 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo. com.", true, null, true);
262 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. foo.com", true, null, true);
263 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. foo.com.", true, null, true);
264 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "Foo. com", true, null, true);
265 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "abc. def.foo.com", true, null, true);
266 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. baz.com", true, null, false);
267 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", null, true, null, false);
268 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com", t rue, null, false);
269 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com.", true, null, false);
270 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com ", true, null, false);
271 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com .", true, null, false);
272 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "Foo.com", t rue, null, false);
273 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "abc.def.foo .com", true, null, false);
274 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.baz.com ", true, null, true);
275 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", null, true, null, true);
276 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "fo o.com", true, null, false);
277 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "fo o.com.", true, null, false);
278 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.foo.com", true, null, false);
279 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.foo.com.", true, null, false);
280 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "Fo o.com", true, null, false);
281 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ab c.def.foo.com", true, null, false);
282 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.baz.com", true, null, true);
283 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", nul l, true, null, true);
284 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "fo o.com", true, null, false);
285 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "fo o.com.", true, null, false);
286 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.foo.com", true, null, false);
287 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.foo.com.", true, null, false);
288 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "Fo o.com", true, null, false);
289 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ab c.def.foo.com", true, null, false);
290 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.baz.com", true, null, true);
291 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", nul l, true, null, true);
292 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "foo .com", true, null, true);
293 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "bar .com", true, null, false);
294 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "baz .com", true, null, false);
295 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, true);
296 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.foo.com", true, null, true);
297 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "bar.foo.com", true, null, false);
298 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.bar.foo.com", true, null, false);
299 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "baz.com", true, null, false);
300 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.baz.com", true, null, false);
301 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.com ", true, null, true);
302 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.net ", true, null, false);
303 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.com ", true, null, false);
304 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.net ", true, null, false);
305 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "com", t rue, null, true);
306 testMatch(test, "abc$domain=foo.com", "http://ccc/def", "IMAGE", "foo.com", tr ue, null, false);
307 testMatch(test, "abc$domain=foo.com", "http://ccc/def", "IMAGE", "bar.com", tr ue, null, false);
308 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "IMAGE", "foo.co m", true, null, true);
309 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "IMAGE", "bar.co m", true, null, false);
310 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "OBJECT", "foo.c om", true, null, false);
311 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "OBJECT", "bar.c om", true, null, false);
312 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "foo.c om", true, null, false);
313 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "bar.c om", true, null, false);
314 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "foo. com", true, null, true);
315 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "bar. com", true, null, false);
316 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "IMAGE", "foo.co m", true, null, true);
317 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "IMAGE", "bar.co m", true, null, false);
318 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "OBJECT", "foo.c om", true, null, false);
319 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "OBJECT", "bar.c om", true, null, false);
320 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "foo.c om", true, null, false);
321 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "bar.c om", true, null, false);
322 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "foo. com", true, null, true);
323 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "bar. com", true, null, false);
324
325 test.done();
326 };
327
328 exports.testSitekeyRestrictions = function(test)
329 {
330 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, "foo-publickey", true);
331 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, null, false);
332 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, "bar-publickey", false);
333 testMatch(test, "abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", " IMAGE", "foo.com", true, "foo-publickey", true);
334 testMatch(test, "abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", " IMAGE", "foo.com", true, null, false);
335 testMatch(test, "abc$sitekey=bar-publickey|foo-publickey", "http://abc/def", " IMAGE", "foo.com", true, "foo-publickey", true);
336 testMatch(test, "abc$sitekey=foo-publickey", "http://ccc/def", "IMAGE", "foo.c om", true, "foo-publickey", false);
337 testMatch(test, "abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "foo-publickey", true);
338 testMatch(test, "abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "bar.com", true, "foo-publickey", false);
339 testMatch(test, "abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "foo-publickey", false);
340 testMatch(test, "abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "bar.com", true, "foo-publickey", true);
341
342 test.done();
343 };
344
345 exports.testExceptionRules = function(test)
346 {
347 testMatch(test, "@@test", "http://test/", "DOCUMENT", null, false, null, false );
348 testMatch(test, "@@http://test*", "http://test/", "DOCUMENT", null, false, nul l, false);
349 testMatch(test, "@@ftp://test*", "ftp://test/", "DOCUMENT", null, false, null, false);
350 testMatch(test, "@@test$document", "http://test/", "DOCUMENT", null, false, nu ll, true);
351 testMatch(test, "@@test$document,image", "http://test/", "DOCUMENT", null, fal se, null, true);
352 testMatch(test, "@@test$~image", "http://test/", "DOCUMENT", null, false, null , false);
353 testMatch(test, "@@test$~image,document", "http://test/", "DOCUMENT", null, fa lse, null, true);
354 testMatch(test, "@@test$document,~image", "http://test/", "DOCUMENT", null, fa lse, null, true);
355 testMatch(test, "@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "foo.com", false, null, true);
356 testMatch(test, "@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "bar.com", false, null, false);
357 testMatch(test, "@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "foo.com", false, null, false);
358 testMatch(test, "@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "bar.com", false, null, true);
359 testMatch(test, "@@test$document,sitekey=foo-publickey", "http://test/", "DOCU MENT", "foo.com", false, "foo-publickey", true);
360 testMatch(test, "@@test$document,sitekey=foo-publickey", "http://test/", "DOCU MENT", "foo.com", false, null, false);
361
362 test.done();
363 };
OLDNEW

Powered by Google App Engine
This is Rietveld