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

Side by Side Diff: test/regexpFilters_matching.js

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

Powered by Google App Engine
This is Rietveld