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: Created Sept. 25, 2016, 1:38 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
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 {Filter, RegExpFilter} = require("filterClasses");
21
22 function testMatch(test, text, location, contentType, docDomain, thirdParty, sit ekey, expected)
23 {
24 function testMatch_internal(text, location, contentType, docDomain, thirdParty , sitekey, expected)
25 {
26 let filter = Filter.fromText(text);
27 let result = filter.matches(location, RegExpFilter.typeMap[contentType], doc Domain, thirdParty, sitekey);
28 test.equal(!!result, expected, '"' + text + '".matches(' + location + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-pa rty") + ", " + (sitekey || "no-sitekey") + ")");
29 }
30 testMatch_internal(text, location, contentType, docDomain, thirdParty, sitekey , expected);
31 if (!/^@@/.test(text))
32 testMatch_internal("@@" + text, location, contentType, docDomain, thirdParty , sitekey, expected);
33 }
34
35 exports.testBasicFilters = function(test)
36 {
37 testMatch(test, "abc", "http://abc/adf", "IMAGE", null, false, null, true);
38 testMatch(test, "abc", "http://ABC/adf", "IMAGE", null, false, null, true);
39 testMatch(test, "abc", "http://abd/adf", "IMAGE", null, false, null, false);
40 testMatch(test, "|abc", "http://abc/adf", "IMAGE", null, false, null, false);
41 testMatch(test, "|http://abc", "http://abc/adf", "IMAGE", null, false, null, t rue);
42 testMatch(test, "abc|", "http://abc/adf", "IMAGE", null, false, null, false);
43 testMatch(test, "abc/adf|", "http://abc/adf", "IMAGE", null, false, null, true );
44 testMatch(test, "||example.com/foo", "http://example.com/foo/bar", "IMAGE", nu ll, false, null, true);
45 testMatch(test, "||com/foo", "http://example.com/foo/bar", "IMAGE", null, fals e, null, true);
46 testMatch(test, "||mple.com/foo", "http://example.com/foo/bar", "IMAGE", null, false, null, false);
47 testMatch(test, "||/example.com/foo", "http://example.com/foo/bar", "IMAGE", n ull, false, null, false);
48 testMatch(test, "||example.com/foo/bar|", "http://example.com/foo/bar", "IMAGE ", null, false, null, true);
49 testMatch(test, "||example.com/foo", "http://foo.com/http://example.com/foo/ba r", "IMAGE", null, false, null, false);
50 testMatch(test, "||example.com/foo|", "http://example.com/foo/bar", "IMAGE", n ull, false, null, false);
51
52 test.done();
53 };
54
55 exports.testSeparatorPlaceholders = function(test)
56 {
57 testMatch(test, "abc^d", "http://abc/def", "IMAGE", null, false, null, true);
58 testMatch(test, "abc^e", "http://abc/def", "IMAGE", null, false, null, false);
59 testMatch(test, "def^", "http://abc/def", "IMAGE", null, false, null, true);
60 testMatch(test, "http://abc/d^f", "http://abc/def", "IMAGE", null, false, null , false);
61 testMatch(test, "http://abc/def^", "http://abc/def", "IMAGE", null, false, nul l, true);
62 testMatch(test, "^foo=bar^", "http://abc/?foo=bar", "IMAGE", null, false, null , true);
63 testMatch(test, "^foo=bar^", "http://abc/?a=b&foo=bar", "IMAGE", null, false, null, true);
64 testMatch(test, "^foo=bar^", "http://abc/?foo=bar&a=b", "IMAGE", null, false, null, true);
65 testMatch(test, "^foo=bar^", "http://abc/?notfoo=bar", "IMAGE", null, false, n ull, false);
66 testMatch(test, "^foo=bar^", "http://abc/?foo=barnot", "IMAGE", null, false, n ull, false);
67 testMatch(test, "^foo=bar^", "http://abc/?foo=bar%2Enot", "IMAGE", null, false , null, false);
68 testMatch(test, "||example.com^", "http://example.com/foo/bar", "IMAGE", null, false, null, true);
69 testMatch(test, "||example.com^", "http://example.company.com/foo/bar", "IMAGE ", null, false, null, false);
70 testMatch(test, "||example.com^", "http://example.com:1234/foo/bar", "IMAGE", null, false, null, true);
71 testMatch(test, "||example.com^", "http://example.com.com/foo/bar", "IMAGE", n ull, false, null, false);
72 testMatch(test, "||example.com^", "http://example.com-company.com/foo/bar", "I MAGE", null, false, null, false);
73 testMatch(test, "||example.com^foo", "http://example.com/foo/bar", "IMAGE", nu ll, false, null, true);
74 testMatch(test, "||пример.ру^", "http://пример.ру/foo/bar", "IMAGE", null, fal se, null, true);
75 testMatch(test, "||пример.ру^", "http://пример.руководитель.ру/foo/bar", "IMAG E", null, false, null, false);
76 testMatch(test, "||пример.ру^", "http://пример.ру:1234/foo/bar", "IMAGE", null , false, null, true);
77 testMatch(test, "||пример.ру^", "http://пример.ру.ру/foo/bar", "IMAGE", null, false, null, false);
78 testMatch(test, "||пример.ру^", "http://пример.ру-ководитель.ру/foo/bar", "IMA GE", null, false, null, false);
79 testMatch(test, "||пример.ру^foo", "http://пример.ру/foo/bar", "IMAGE", null, false, null, true);
80
81 test.done();
82 };
83
84 exports.testWildcardMatching = function(test)
85 {
86 testMatch(test, "abc*d", "http://abc/adf", "IMAGE", null, false, null, true);
87 testMatch(test, "abc*d", "http://abcd/af", "IMAGE", null, false, null, true);
88 testMatch(test, "abc*d", "http://abc/d/af", "IMAGE", null, false, null, true);
89 testMatch(test, "abc*d", "http://dabc/af", "IMAGE", null, false, null, false);
90 testMatch(test, "*abc", "http://abc/adf", "IMAGE", null, false, null, true);
91 testMatch(test, "abc*", "http://abc/adf", "IMAGE", null, false, null, true);
92 testMatch(test, "|*abc", "http://abc/adf", "IMAGE", null, false, null, true);
93 testMatch(test, "abc*|", "http://abc/adf", "IMAGE", null, false, null, true);
94 testMatch(test, "abc***d", "http://abc/adf", "IMAGE", null, false, null, true) ;
95
96 test.done();
97 };
98
99 exports.testTypeOptions = function(test)
100 {
101 testMatch(test, "abc$image", "http://abc/adf", "IMAGE", null, false, null, tru e);
102 testMatch(test, "abc$other", "http://abc/adf", "IMAGE", null, false, null, fal se);
103 testMatch(test, "abc$other", "http://abc/adf", "OTHER", null, false, null, tru e);
104 testMatch(test, "abc$~other", "http://abc/adf", "OTHER", null, false, null, fa lse);
105 testMatch(test, "abc$script", "http://abc/adf", "IMAGE", null, false, null, fa lse);
106 testMatch(test, "abc$script", "http://abc/adf", "SCRIPT", null, false, null, t rue);
107 testMatch(test, "abc$~script", "http://abc/adf", "SCRIPT", null, false, null, false);
108 testMatch(test, "abc$stylesheet", "http://abc/adf", "IMAGE", null, false, null , false);
109 testMatch(test, "abc$stylesheet", "http://abc/adf", "STYLESHEET", null, false, null, true);
110 testMatch(test, "abc$~stylesheet", "http://abc/adf", "STYLESHEET", null, false , null, false);
111 testMatch(test, "abc$object", "http://abc/adf", "IMAGE", null, false, null, fa lse);
112 testMatch(test, "abc$object", "http://abc/adf", "OBJECT", null, false, null, t rue);
113 testMatch(test, "abc$~object", "http://abc/adf", "OBJECT", null, false, null, false);
114 testMatch(test, "abc$document", "http://abc/adf", "IMAGE", null, false, null, false);
115 testMatch(test, "abc$document", "http://abc/adf", "DOCUMENT", null, false, nul l, true);
116 testMatch(test, "abc$~document", "http://abc/adf", "DOCUMENT", null, false, nu ll, false);
117 testMatch(test, "abc$subdocument", "http://abc/adf", "IMAGE", null, false, nul l, false);
118 testMatch(test, "abc$subdocument", "http://abc/adf", "SUBDOCUMENT", null, fals e, null, true);
119 testMatch(test, "abc$~subdocument", "http://abc/adf", "SUBDOCUMENT", null, fal se, null, false);
120 testMatch(test, "abc$background", "http://abc/adf", "OBJECT", null, false, nul l, false);
121 testMatch(test, "abc$background", "http://abc/adf", "IMAGE", null, false, null , true);
122 testMatch(test, "abc$~background", "http://abc/adf", "IMAGE", null, false, nul l, false);
123 testMatch(test, "abc$xbl", "http://abc/adf", "IMAGE", null, false, null, false );
124 testMatch(test, "abc$xbl", "http://abc/adf", "XBL", null, false, null, true);
125 testMatch(test, "abc$~xbl", "http://abc/adf", "XBL", null, false, null, false) ;
126 testMatch(test, "abc$ping", "http://abc/adf", "IMAGE", null, false, null, fals e);
127 testMatch(test, "abc$ping", "http://abc/adf", "PING", null, false, null, true) ;
128 testMatch(test, "abc$~ping", "http://abc/adf", "PING", null, false, null, fals e);
129 testMatch(test, "abc$xmlhttprequest", "http://abc/adf", "IMAGE", null, false, null, false);
130 testMatch(test, "abc$xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", null , false, null, true);
131 testMatch(test, "abc$~xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", nul l, false, null, false);
132 testMatch(test, "abc$object-subrequest", "http://abc/adf", "IMAGE", null, fals e, null, false);
133 testMatch(test, "abc$object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST" , null, false, null, true);
134 testMatch(test, "abc$~object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST ", null, false, null, false);
135 testMatch(test, "abc$dtd", "http://abc/adf", "IMAGE", null, false, null, false );
136 testMatch(test, "abc$dtd", "http://abc/adf", "DTD", null, false, null, true);
137 testMatch(test, "abc$~dtd", "http://abc/adf", "DTD", null, false, null, false) ;
138
139 testMatch(test, "abc$media", "http://abc/adf", "IMAGE", null, false, null, fal se);
140 testMatch(test, "abc$media", "http://abc/adf", "MEDIA", null, false, null, tru e);
141 testMatch(test, "abc$~media", "http://abc/adf", "MEDIA", null, false, null, fa lse);
142
143 testMatch(test, "abc$font", "http://abc/adf", "IMAGE", null, false, null, fals e);
144 testMatch(test, "abc$font", "http://abc/adf", "FONT", null, false, null, true) ;
145 testMatch(test, "abc$~font", "http://abc/adf", "FONT", null, false, null, fals e);
146
147 testMatch(test, "abc$ping", "http://abc/adf", "IMAGE", null, false, null, fals e);
148 testMatch(test, "abc$ping", "http://abc/adf", "PING", null, false, null, true) ;
149 testMatch(test, "abc$~ping", "http://abc/adf", "PING", null, false, null, fals e);
150
151 testMatch(test, "abc$image,script", "http://abc/adf", "IMAGE", null, false, nu ll, true);
152 testMatch(test, "abc$~image", "http://abc/adf", "IMAGE", null, false, null, fa lse);
153 testMatch(test, "abc$~script", "http://abc/adf", "IMAGE", null, false, null, t rue);
154 testMatch(test, "abc$~image,~script", "http://abc/adf", "IMAGE", null, false, null, false);
155 testMatch(test, "abc$~script,~image", "http://abc/adf", "IMAGE", null, false, null, false);
156 testMatch(test, "abc$~document,~script,~other", "http://abc/adf", "IMAGE", nul l, false, null, true);
157 testMatch(test, "abc$~image,image", "http://abc/adf", "IMAGE", null, false, nu ll, true);
158 testMatch(test, "abc$image,~image", "http://abc/adf", "IMAGE", null, false, nu ll, false);
159 testMatch(test, "abc$~image,image", "http://abc/adf", "SCRIPT", null, false, n ull, true);
160 testMatch(test, "abc$image,~image", "http://abc/adf", "SCRIPT", null, false, n ull, false);
161 testMatch(test, "abc$match-case", "http://abc/adf", "IMAGE", null, false, null , true);
162 testMatch(test, "abc$match-case", "http://ABC/adf", "IMAGE", null, false, null , false);
163 testMatch(test, "abc$~match-case", "http://abc/adf", "IMAGE", null, false, nul l, true);
164 testMatch(test, "abc$~match-case", "http://ABC/adf", "IMAGE", null, false, nul l, true);
165 testMatch(test, "abc$match-case,image", "http://abc/adf", "IMAGE", null, false , null, true);
166 testMatch(test, "abc$match-case,script", "http://abc/adf", "IMAGE", null, fals e, null, false);
167 testMatch(test, "abc$match-case,image", "http://ABC/adf", "IMAGE", null, false , null, false);
168 testMatch(test, "abc$match-case,script", "http://ABC/adf", "IMAGE", null, fals e, null, false);
169 testMatch(test, "abc$third-party", "http://abc/adf", "IMAGE", null, false, nul l, false);
170 testMatch(test, "abc$third-party", "http://abc/adf", "IMAGE", null, true, null , true);
171 testMatch(test, "abd$third-party", "http://abc/adf", "IMAGE", null, false, nul l, false);
172 testMatch(test, "abd$third-party", "http://abc/adf", "IMAGE", null, true, null , false);
173 testMatch(test, "abc$image,third-party", "http://abc/adf", "IMAGE", null, fals e, null, false);
174 testMatch(test, "abc$image,third-party", "http://abc/adf", "IMAGE", null, true , null, true);
175 testMatch(test, "abc$~image,third-party", "http://abc/adf", "IMAGE", null, fal se, null, false);
176 testMatch(test, "abc$~image,third-party", "http://abc/adf", "IMAGE", null, tru e, null, false);
177 testMatch(test, "abc$~third-party", "http://abc/adf", "IMAGE", null, false, nu ll, true);
178 testMatch(test, "abc$~third-party", "http://abc/adf", "IMAGE", null, true, nul l, false);
179 testMatch(test, "abd$~third-party", "http://abc/adf", "IMAGE", null, false, nu ll, false);
180 testMatch(test, "abd$~third-party", "http://abc/adf", "IMAGE", null, true, nul l, false);
181 testMatch(test, "abc$image,~third-party", "http://abc/adf", "IMAGE", null, fal se, null, true);
182 testMatch(test, "abc$image,~third-party", "http://abc/adf", "IMAGE", null, tru e, null, false);
183 testMatch(test, "abc$~image,~third-party", "http://abc/adf", "IMAGE", null, fa lse, null, false);
184
185 test.done();
186 };
187
188 exports.testRegularExpressions = function(test)
189 {
190 testMatch(test, "/abc/", "http://abc/adf", "IMAGE", null, false, null, true);
191 testMatch(test, "/abc/", "http://abcd/adf", "IMAGE", null, false, null, true);
192 testMatch(test, "*/abc/", "http://abc/adf", "IMAGE", null, false, null, true);
193 testMatch(test, "*/abc/", "http://abcd/adf", "IMAGE", null, false, null, false );
194 testMatch(test, "/a\\wc/", "http://abc/adf", "IMAGE", null, false, null, true) ;
195 testMatch(test, "/a\\wc/", "http://a1c/adf", "IMAGE", null, false, null, true) ;
196 testMatch(test, "/a\\wc/", "http://a_c/adf", "IMAGE", null, false, null, true) ;
197 testMatch(test, "/a\\wc/", "http://a%c/adf", "IMAGE", null, false, null, false );
198
199 test.done();
200 };
201
202 exports.testRegularExpressionsWithTypeOptions = function(test)
203 {
204 testMatch(test, "/abc/$image", "http://abc/adf", "IMAGE", null, false, null, t rue);
205 testMatch(test, "/abc/$image", "http://aBc/adf", "IMAGE", null, false, null, t rue);
206 testMatch(test, "/abc/$script", "http://abc/adf", "IMAGE", null, false, null, false);
207 testMatch(test, "/abc/$~image", "http://abcd/adf", "IMAGE", null, false, null, false);
208 testMatch(test, "/ab{2}c/$image", "http://abc/adf", "IMAGE", null, false, null , false);
209 testMatch(test, "/ab{2}c/$script", "http://abc/adf", "IMAGE", null, false, nul l, false);
210 testMatch(test, "/ab{2}c/$~image", "http://abcd/adf", "IMAGE", null, false, nu ll, false);
211 testMatch(test, "/abc/$third-party", "http://abc/adf", "IMAGE", null, false, n ull, false);
212 testMatch(test, "/abc/$third-party", "http://abc/adf", "IMAGE", null, true, nu ll, true);
213 testMatch(test, "/abc/$~third-party", "http://abc/adf", "IMAGE", null, false, null, true);
214 testMatch(test, "/abc/$~third-party", "http://abc/adf", "IMAGE", null, true, n ull, false);
215 testMatch(test, "/abc/$match-case", "http://abc/adf", "IMAGE", null, false, nu ll, true);
216 testMatch(test, "/abc/$match-case", "http://aBc/adf", "IMAGE", null, true, nul l, false);
217 testMatch(test, "/ab{2}c/$match-case", "http://abc/adf", "IMAGE", null, false, null, false);
218 testMatch(test, "/ab{2}c/$match-case", "http://aBc/adf", "IMAGE", null, true, null, false);
219 testMatch(test, "/abc/$~match-case", "http://abc/adf", "IMAGE", null, false, n ull, true);
220 testMatch(test, "/abc/$~match-case", "http://aBc/adf", "IMAGE", null, true, nu ll, true);
221 testMatch(test, "/ab{2}c/$~match-case", "http://abc/adf", "IMAGE", null, false , null, false);
222 testMatch(test, "/ab{2}c/$~match-case", "http://aBc/adf", "IMAGE", null, true, null, false);
223
224 test.done();
225 };
226
227 exports.testDomainRestrictions = function(test)
228 {
229 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com", tr ue, null, true);
230 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com.", t rue, null, true);
231 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com" , true, null, true);
232 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com. ", true, null, true);
233 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "Foo.com", tr ue, null, true);
234 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "abc.def.foo. com", true, null, true);
235 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.baz.com" , true, null, false);
236 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", null, true, n ull, false);
237 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo. com", true, null, true);
238 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo. com.", true, null, true);
239 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. foo.com", true, null, true);
240 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. foo.com.", true, null, true);
241 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "Foo. com", true, null, true);
242 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "abc. def.foo.com", true, null, true);
243 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. baz.com", true, null, false);
244 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", null, true, null, false);
245 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo. com", true, null, true);
246 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo. com.", true, null, true);
247 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. foo.com", true, null, true);
248 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. foo.com.", true, null, true);
249 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "Foo. com", true, null, true);
250 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "abc. def.foo.com", true, null, true);
251 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. baz.com", true, null, false);
252 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", null, true, null, false);
253 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com", t rue, null, false);
254 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com.", true, null, false);
255 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com ", true, null, false);
256 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com .", true, null, false);
257 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "Foo.com", t rue, null, false);
258 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "abc.def.foo .com", true, null, false);
259 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.baz.com ", true, null, true);
260 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", null, true, null, true);
261 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "fo o.com", true, null, false);
262 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "fo o.com.", true, null, false);
263 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.foo.com", true, null, false);
264 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.foo.com.", true, null, false);
265 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "Fo o.com", true, null, false);
266 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ab c.def.foo.com", true, null, false);
267 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.baz.com", true, null, true);
268 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", nul l, true, null, true);
269 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "fo o.com", true, null, false);
270 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "fo o.com.", true, null, false);
271 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.foo.com", true, null, false);
272 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.foo.com.", true, null, false);
273 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "Fo o.com", true, null, false);
274 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ab c.def.foo.com", true, null, false);
275 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.baz.com", true, null, true);
276 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", nul l, true, null, true);
277 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "foo .com", true, null, true);
278 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "bar .com", true, null, false);
279 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "baz .com", true, null, false);
280 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, true);
281 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.foo.com", true, null, true);
282 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "bar.foo.com", true, null, false);
283 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.bar.foo.com", true, null, false);
284 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "baz.com", true, null, false);
285 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.baz.com", true, null, false);
286 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.com ", true, null, true);
287 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.net ", true, null, false);
288 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.com ", true, null, false);
289 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.net ", true, null, false);
290 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "com", t rue, null, true);
291 testMatch(test, "abc$domain=foo.com", "http://ccc/def", "IMAGE", "foo.com", tr ue, null, false);
292 testMatch(test, "abc$domain=foo.com", "http://ccc/def", "IMAGE", "bar.com", tr ue, null, false);
293 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "IMAGE", "foo.co m", true, null, true);
294 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "IMAGE", "bar.co m", true, null, false);
295 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "OBJECT", "foo.c om", true, null, false);
296 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "OBJECT", "bar.c om", true, null, false);
297 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "foo.c om", true, null, false);
298 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "bar.c om", true, null, false);
299 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "foo. com", true, null, true);
300 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "bar. com", true, null, false);
301 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "IMAGE", "foo.co m", true, null, true);
302 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "IMAGE", "bar.co m", true, null, false);
303 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "OBJECT", "foo.c om", true, null, false);
304 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "OBJECT", "bar.c om", true, null, false);
305 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "foo.c om", true, null, false);
306 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "bar.c om", true, null, false);
307 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "foo. com", true, null, true);
308 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "bar. com", true, null, false);
309
310 test.done();
311 };
312
313 exports.testSitekeyRestrictions = function(test)
314 {
315 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, "foo-publickey", true);
316 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, null, false);
317 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, "bar-publickey", false);
318 testMatch(test, "abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", " IMAGE", "foo.com", true, "foo-publickey", true);
319 testMatch(test, "abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", " IMAGE", "foo.com", true, null, false);
320 testMatch(test, "abc$sitekey=bar-publickey|foo-publickey", "http://abc/def", " IMAGE", "foo.com", true, "foo-publickey", true);
321 testMatch(test, "abc$sitekey=foo-publickey", "http://ccc/def", "IMAGE", "foo.c om", true, "foo-publickey", false);
322 testMatch(test, "abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "foo-publickey", true);
323 testMatch(test, "abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "bar.com", true, "foo-publickey", false);
324 testMatch(test, "abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "foo-publickey", false);
325 testMatch(test, "abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "bar.com", true, "foo-publickey", true);
326
327 test.done();
328 };
329
330 exports.testExceptionRules = function(test)
331 {
332 testMatch(test, "@@test", "http://test/", "DOCUMENT", null, false, null, false );
333 testMatch(test, "@@http://test*", "http://test/", "DOCUMENT", null, false, nul l, false);
334 testMatch(test, "@@ftp://test*", "ftp://test/", "DOCUMENT", null, false, null, false);
335 testMatch(test, "@@test$document", "http://test/", "DOCUMENT", null, false, nu ll, true);
336 testMatch(test, "@@test$document,image", "http://test/", "DOCUMENT", null, fal se, null, true);
337 testMatch(test, "@@test$~image", "http://test/", "DOCUMENT", null, false, null , false);
338 testMatch(test, "@@test$~image,document", "http://test/", "DOCUMENT", null, fa lse, null, true);
339 testMatch(test, "@@test$document,~image", "http://test/", "DOCUMENT", null, fa lse, null, true);
340 testMatch(test, "@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "foo.com", false, null, true);
341 testMatch(test, "@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "bar.com", false, null, false);
342 testMatch(test, "@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "foo.com", false, null, false);
343 testMatch(test, "@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "bar.com", false, null, true);
344 testMatch(test, "@@test$document,sitekey=foo-publickey", "http://test/", "DOCU MENT", "foo.com", false, "foo-publickey", true);
345 testMatch(test, "@@test$document,sitekey=foo-publickey", "http://test/", "DOCU MENT", "foo.com", false, null, false);
346
347 test.done();
348 };
OLDNEW

Powered by Google App Engine
This is Rietveld