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

Powered by Google App Engine
This is Rietveld