OLD | NEW |
| (Empty) |
1 (function() | |
2 { | |
3 module("Matching of blocking filters", {setup: prepareFilterComponents, teardo
wn: restoreFilterComponents}); | |
4 | |
5 function testMatch(text, location, contentType, docDomain, thirdParty, sitekey
, expected) | |
6 { | |
7 function testMatch_internal(text, location, contentType, docDomain, thirdPar
ty, sitekey, expected) | |
8 { | |
9 let filter = Filter.fromText(text); | |
10 let result = filter.matches(location, RegExpFilter.typeMap[contentType], d
ocDomain, thirdParty, sitekey); | |
11 equal(!!result, expected, '"' + text + '".matches(' + location + ", " + co
ntentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party
") + ", " + (sitekey || "no-sitekey") + ")"); | |
12 } | |
13 testMatch_internal(text, location, contentType, docDomain, thirdParty, sitek
ey, expected); | |
14 if (!/^@@/.test(text)) | |
15 testMatch_internal("@@" + text, location, contentType, docDomain, thirdPar
ty, sitekey, expected); | |
16 } | |
17 | |
18 test("Basic filters", function() | |
19 { | |
20 testMatch("abc", "http://abc/adf", "IMAGE", null, false, null, true); | |
21 testMatch("abc", "http://ABC/adf", "IMAGE", null, false, null, true); | |
22 testMatch("abc", "http://abd/adf", "IMAGE", null, false, null, false); | |
23 testMatch("|abc", "http://abc/adf", "IMAGE", null, false, null, false); | |
24 testMatch("|http://abc", "http://abc/adf", "IMAGE", null, false, null, true)
; | |
25 testMatch("abc|", "http://abc/adf", "IMAGE", null, false, null, false); | |
26 testMatch("abc/adf|", "http://abc/adf", "IMAGE", null, false, null, true); | |
27 testMatch("||example.com/foo", "http://example.com/foo/bar", "IMAGE", null,
false, null, true); | |
28 testMatch("||com/foo", "http://example.com/foo/bar", "IMAGE", null, false, n
ull, true); | |
29 testMatch("||mple.com/foo", "http://example.com/foo/bar", "IMAGE", null, fal
se, null, false); | |
30 testMatch("||/example.com/foo", "http://example.com/foo/bar", "IMAGE", null,
false, null, false); | |
31 testMatch("||example.com/foo/bar|", "http://example.com/foo/bar", "IMAGE", n
ull, false, null, true); | |
32 testMatch("||example.com/foo", "http://foo.com/http://example.com/foo/bar",
"IMAGE", null, false, null, false); | |
33 testMatch("||example.com/foo|", "http://example.com/foo/bar", "IMAGE", null,
false, null, false); | |
34 }); | |
35 | |
36 test("Separator placeholders", function() | |
37 { | |
38 testMatch("abc^d", "http://abc/def", "IMAGE", null, false, null, true); | |
39 testMatch("abc^e", "http://abc/def", "IMAGE", null, false, null, false); | |
40 testMatch("def^", "http://abc/def", "IMAGE", null, false, null, true); | |
41 testMatch("http://abc/d^f", "http://abc/def", "IMAGE", null, false, null, fa
lse); | |
42 testMatch("http://abc/def^", "http://abc/def", "IMAGE", null, false, null, t
rue); | |
43 testMatch("^foo=bar^", "http://abc/?foo=bar", "IMAGE", null, false, null, tr
ue); | |
44 testMatch("^foo=bar^", "http://abc/?a=b&foo=bar", "IMAGE", null, false, null
, true); | |
45 testMatch("^foo=bar^", "http://abc/?foo=bar&a=b", "IMAGE", null, false, null
, true); | |
46 testMatch("^foo=bar^", "http://abc/?notfoo=bar", "IMAGE", null, false, null,
false); | |
47 testMatch("^foo=bar^", "http://abc/?foo=barnot", "IMAGE", null, false, null,
false); | |
48 testMatch("^foo=bar^", "http://abc/?foo=bar%2Enot", "IMAGE", null, false, nu
ll, false); | |
49 testMatch("||example.com^", "http://example.com/foo/bar", "IMAGE", null, fal
se, null, true); | |
50 testMatch("||example.com^", "http://example.company.com/foo/bar", "IMAGE", n
ull, false, null, false); | |
51 testMatch("||example.com^", "http://example.com:1234/foo/bar", "IMAGE", null
, false, null, true); | |
52 testMatch("||example.com^", "http://example.com.com/foo/bar", "IMAGE", null,
false, null, false); | |
53 testMatch("||example.com^", "http://example.com-company.com/foo/bar", "IMAGE
", null, false, null, false); | |
54 testMatch("||example.com^foo", "http://example.com/foo/bar", "IMAGE", null,
false, null, true); | |
55 testMatch("||пример.ру^", "http://пример.ру/foo/bar", "IMAGE", null, false,
null, true); | |
56 testMatch("||пример.ру^", "http://пример.руководитель.ру/foo/bar", "IMAGE",
null, false, null, false); | |
57 testMatch("||пример.ру^", "http://пример.ру:1234/foo/bar", "IMAGE", null, fa
lse, null, true); | |
58 testMatch("||пример.ру^", "http://пример.ру.ру/foo/bar", "IMAGE", null, fals
e, null, false); | |
59 testMatch("||пример.ру^", "http://пример.ру-ководитель.ру/foo/bar", "IMAGE",
null, false, null, false); | |
60 testMatch("||пример.ру^foo", "http://пример.ру/foo/bar", "IMAGE", null, fals
e, null, true); | |
61 }); | |
62 | |
63 test("Wildcard matching", function() | |
64 { | |
65 testMatch("abc*d", "http://abc/adf", "IMAGE", null, false, null, true); | |
66 testMatch("abc*d", "http://abcd/af", "IMAGE", null, false, null, true); | |
67 testMatch("abc*d", "http://abc/d/af", "IMAGE", null, false, null, true); | |
68 testMatch("abc*d", "http://dabc/af", "IMAGE", null, false, null, false); | |
69 testMatch("*abc", "http://abc/adf", "IMAGE", null, false, null, true); | |
70 testMatch("abc*", "http://abc/adf", "IMAGE", null, false, null, true); | |
71 testMatch("|*abc", "http://abc/adf", "IMAGE", null, false, null, true); | |
72 testMatch("abc*|", "http://abc/adf", "IMAGE", null, false, null, true); | |
73 testMatch("abc***d", "http://abc/adf", "IMAGE", null, false, null, true); | |
74 }); | |
75 | |
76 test("Type options", function() | |
77 { | |
78 testMatch("abc$image", "http://abc/adf", "IMAGE", null, false, null, true); | |
79 testMatch("abc$other", "http://abc/adf", "IMAGE", null, false, null, false); | |
80 testMatch("abc$other", "http://abc/adf", "OTHER", null, false, null, true); | |
81 testMatch("abc$~other", "http://abc/adf", "OTHER", null, false, null, false)
; | |
82 testMatch("abc$script", "http://abc/adf", "IMAGE", null, false, null, false)
; | |
83 testMatch("abc$script", "http://abc/adf", "SCRIPT", null, false, null, true)
; | |
84 testMatch("abc$~script", "http://abc/adf", "SCRIPT", null, false, null, fals
e); | |
85 testMatch("abc$stylesheet", "http://abc/adf", "IMAGE", null, false, null, fa
lse); | |
86 testMatch("abc$stylesheet", "http://abc/adf", "STYLESHEET", null, false, nul
l, true); | |
87 testMatch("abc$~stylesheet", "http://abc/adf", "STYLESHEET", null, false, nu
ll, false); | |
88 testMatch("abc$object", "http://abc/adf", "IMAGE", null, false, null, false)
; | |
89 testMatch("abc$object", "http://abc/adf", "OBJECT", null, false, null, true)
; | |
90 testMatch("abc$~object", "http://abc/adf", "OBJECT", null, false, null, fals
e); | |
91 testMatch("abc$document", "http://abc/adf", "IMAGE", null, false, null, fals
e); | |
92 testMatch("abc$document", "http://abc/adf", "DOCUMENT", null, false, null, t
rue); | |
93 testMatch("abc$~document", "http://abc/adf", "DOCUMENT", null, false, null,
false); | |
94 testMatch("abc$subdocument", "http://abc/adf", "IMAGE", null, false, null, f
alse); | |
95 testMatch("abc$subdocument", "http://abc/adf", "SUBDOCUMENT", null, false, n
ull, true); | |
96 testMatch("abc$~subdocument", "http://abc/adf", "SUBDOCUMENT", null, false,
null, false); | |
97 testMatch("abc$background", "http://abc/adf", "OBJECT", null, false, null, f
alse); | |
98 testMatch("abc$background", "http://abc/adf", "IMAGE", null, false, null, tr
ue); | |
99 testMatch("abc$~background", "http://abc/adf", "IMAGE", null, false, null, f
alse); | |
100 testMatch("abc$xbl", "http://abc/adf", "IMAGE", null, false, null, false); | |
101 testMatch("abc$xbl", "http://abc/adf", "XBL", null, false, null, true); | |
102 testMatch("abc$~xbl", "http://abc/adf", "XBL", null, false, null, false); | |
103 testMatch("abc$ping", "http://abc/adf", "IMAGE", null, false, null, false); | |
104 testMatch("abc$ping", "http://abc/adf", "PING", null, false, null, true); | |
105 testMatch("abc$~ping", "http://abc/adf", "PING", null, false, null, false); | |
106 testMatch("abc$xmlhttprequest", "http://abc/adf", "IMAGE", null, false, null
, false); | |
107 testMatch("abc$xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", null, fa
lse, null, true); | |
108 testMatch("abc$~xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", null, f
alse, null, false); | |
109 testMatch("abc$object-subrequest", "http://abc/adf", "IMAGE", null, false, n
ull, false); | |
110 testMatch("abc$object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST", nu
ll, false, null, true); | |
111 testMatch("abc$~object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST", n
ull, false, null, false); | |
112 testMatch("abc$dtd", "http://abc/adf", "IMAGE", null, false, null, false); | |
113 testMatch("abc$dtd", "http://abc/adf", "DTD", null, false, null, true); | |
114 testMatch("abc$~dtd", "http://abc/adf", "DTD", null, false, null, false); | |
115 | |
116 testMatch("abc$media", "http://abc/adf", "IMAGE", null, false, null, false); | |
117 testMatch("abc$media", "http://abc/adf", "MEDIA", null, false, null, true); | |
118 testMatch("abc$~media", "http://abc/adf", "MEDIA", null, false, null, false)
; | |
119 | |
120 testMatch("abc$font", "http://abc/adf", "IMAGE", null, false, null, false); | |
121 testMatch("abc$font", "http://abc/adf", "FONT", null, false, null, true); | |
122 testMatch("abc$~font", "http://abc/adf", "FONT", null, false, null, false); | |
123 | |
124 testMatch("abc$ping", "http://abc/adf", "IMAGE", null, false, null, false); | |
125 testMatch("abc$ping", "http://abc/adf", "PING", null, false, null, true); | |
126 testMatch("abc$~ping", "http://abc/adf", "PING", null, false, null, false); | |
127 | |
128 testMatch("abc$image,script", "http://abc/adf", "IMAGE", null, false, null,
true); | |
129 testMatch("abc$~image", "http://abc/adf", "IMAGE", null, false, null, false)
; | |
130 testMatch("abc$~script", "http://abc/adf", "IMAGE", null, false, null, true)
; | |
131 testMatch("abc$~image,~script", "http://abc/adf", "IMAGE", null, false, null
, false); | |
132 testMatch("abc$~script,~image", "http://abc/adf", "IMAGE", null, false, null
, false); | |
133 testMatch("abc$~document,~script,~other", "http://abc/adf", "IMAGE", null, f
alse, null, true); | |
134 testMatch("abc$~image,image", "http://abc/adf", "IMAGE", null, false, null,
true); | |
135 testMatch("abc$image,~image", "http://abc/adf", "IMAGE", null, false, null,
false); | |
136 testMatch("abc$~image,image", "http://abc/adf", "SCRIPT", null, false, null,
true); | |
137 testMatch("abc$image,~image", "http://abc/adf", "SCRIPT", null, false, null,
false); | |
138 testMatch("abc$match-case", "http://abc/adf", "IMAGE", null, false, null, tr
ue); | |
139 testMatch("abc$match-case", "http://ABC/adf", "IMAGE", null, false, null, fa
lse); | |
140 testMatch("abc$~match-case", "http://abc/adf", "IMAGE", null, false, null, t
rue); | |
141 testMatch("abc$~match-case", "http://ABC/adf", "IMAGE", null, false, null, t
rue); | |
142 testMatch("abc$match-case,image", "http://abc/adf", "IMAGE", null, false, nu
ll, true); | |
143 testMatch("abc$match-case,script", "http://abc/adf", "IMAGE", null, false, n
ull, false); | |
144 testMatch("abc$match-case,image", "http://ABC/adf", "IMAGE", null, false, nu
ll, false); | |
145 testMatch("abc$match-case,script", "http://ABC/adf", "IMAGE", null, false, n
ull, false); | |
146 testMatch("abc$third-party", "http://abc/adf", "IMAGE", null, false, null, f
alse); | |
147 testMatch("abc$third-party", "http://abc/adf", "IMAGE", null, true, null, tr
ue); | |
148 testMatch("abd$third-party", "http://abc/adf", "IMAGE", null, false, null, f
alse); | |
149 testMatch("abd$third-party", "http://abc/adf", "IMAGE", null, true, null, fa
lse); | |
150 testMatch("abc$image,third-party", "http://abc/adf", "IMAGE", null, false, n
ull, false); | |
151 testMatch("abc$image,third-party", "http://abc/adf", "IMAGE", null, true, nu
ll, true); | |
152 testMatch("abc$~image,third-party", "http://abc/adf", "IMAGE", null, false,
null, false); | |
153 testMatch("abc$~image,third-party", "http://abc/adf", "IMAGE", null, true, n
ull, false); | |
154 testMatch("abc$~third-party", "http://abc/adf", "IMAGE", null, false, null,
true); | |
155 testMatch("abc$~third-party", "http://abc/adf", "IMAGE", null, true, null, f
alse); | |
156 testMatch("abd$~third-party", "http://abc/adf", "IMAGE", null, false, null,
false); | |
157 testMatch("abd$~third-party", "http://abc/adf", "IMAGE", null, true, null, f
alse); | |
158 testMatch("abc$image,~third-party", "http://abc/adf", "IMAGE", null, false,
null, true); | |
159 testMatch("abc$image,~third-party", "http://abc/adf", "IMAGE", null, true, n
ull, false); | |
160 testMatch("abc$~image,~third-party", "http://abc/adf", "IMAGE", null, false,
null, false); | |
161 }); | |
162 | |
163 test("Regular expressions", function() | |
164 { | |
165 testMatch("/abc/", "http://abc/adf", "IMAGE", null, false, null, true); | |
166 testMatch("/abc/", "http://abcd/adf", "IMAGE", null, false, null, true); | |
167 testMatch("*/abc/", "http://abc/adf", "IMAGE", null, false, null, true); | |
168 testMatch("*/abc/", "http://abcd/adf", "IMAGE", null, false, null, false); | |
169 testMatch("/a\\wc/", "http://abc/adf", "IMAGE", null, false, null, true); | |
170 testMatch("/a\\wc/", "http://a1c/adf", "IMAGE", null, false, null, true); | |
171 testMatch("/a\\wc/", "http://a_c/adf", "IMAGE", null, false, null, true); | |
172 testMatch("/a\\wc/", "http://a%c/adf", "IMAGE", null, false, null, false); | |
173 }); | |
174 | |
175 test("Regular expressions with type options", function() | |
176 { | |
177 testMatch("/abc/$image", "http://abc/adf", "IMAGE", null, false, null, true)
; | |
178 testMatch("/abc/$image", "http://aBc/adf", "IMAGE", null, false, null, true)
; | |
179 testMatch("/abc/$script", "http://abc/adf", "IMAGE", null, false, null, fals
e); | |
180 testMatch("/abc/$~image", "http://abcd/adf", "IMAGE", null, false, null, fal
se); | |
181 testMatch("/ab{2}c/$image", "http://abc/adf", "IMAGE", null, false, null, fa
lse); | |
182 testMatch("/ab{2}c/$script", "http://abc/adf", "IMAGE", null, false, null, f
alse); | |
183 testMatch("/ab{2}c/$~image", "http://abcd/adf", "IMAGE", null, false, null,
false); | |
184 testMatch("/abc/$third-party", "http://abc/adf", "IMAGE", null, false, null,
false); | |
185 testMatch("/abc/$third-party", "http://abc/adf", "IMAGE", null, true, null,
true); | |
186 testMatch("/abc/$~third-party", "http://abc/adf", "IMAGE", null, false, null
, true); | |
187 testMatch("/abc/$~third-party", "http://abc/adf", "IMAGE", null, true, null,
false); | |
188 testMatch("/abc/$match-case", "http://abc/adf", "IMAGE", null, false, null,
true); | |
189 testMatch("/abc/$match-case", "http://aBc/adf", "IMAGE", null, true, null, f
alse); | |
190 testMatch("/ab{2}c/$match-case", "http://abc/adf", "IMAGE", null, false, nul
l, false); | |
191 testMatch("/ab{2}c/$match-case", "http://aBc/adf", "IMAGE", null, true, null
, false); | |
192 testMatch("/abc/$~match-case", "http://abc/adf", "IMAGE", null, false, null,
true); | |
193 testMatch("/abc/$~match-case", "http://aBc/adf", "IMAGE", null, true, null,
true); | |
194 testMatch("/ab{2}c/$~match-case", "http://abc/adf", "IMAGE", null, false, nu
ll, false); | |
195 testMatch("/ab{2}c/$~match-case", "http://aBc/adf", "IMAGE", null, true, nul
l, false); | |
196 }); | |
197 | |
198 test("Domain restrictions", function() | |
199 { | |
200 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com", true,
null, true); | |
201 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com.", true,
null, true); | |
202 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com", tr
ue, null, true); | |
203 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com.", t
rue, null, true); | |
204 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "Foo.com", true,
null, true); | |
205 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "abc.def.foo.com"
, true, null, true); | |
206 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "www.baz.com", tr
ue, null, false); | |
207 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", null, true, null,
false); | |
208 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo.com"
, true, null, true); | |
209 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo.com.
", true, null, true); | |
210 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www.foo.
com", true, null, true); | |
211 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www.foo.
com.", true, null, true); | |
212 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "Foo.com"
, true, null, true); | |
213 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "abc.def.
foo.com", true, null, true); | |
214 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www.baz.
com", true, null, false); | |
215 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", null, tru
e, null, false); | |
216 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo.com"
, true, null, true); | |
217 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo.com.
", true, null, true); | |
218 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www.foo.
com", true, null, true); | |
219 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www.foo.
com.", true, null, true); | |
220 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "Foo.com"
, true, null, true); | |
221 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "abc.def.
foo.com", true, null, true); | |
222 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www.baz.
com", true, null, false); | |
223 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", null, tru
e, null, false); | |
224 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com", true,
null, false); | |
225 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com.", true
, null, false); | |
226 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com", t
rue, null, false); | |
227 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com.",
true, null, false); | |
228 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "Foo.com", true,
null, false); | |
229 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "abc.def.foo.com
", true, null, false); | |
230 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.baz.com", t
rue, null, true); | |
231 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", null, true, null
, true); | |
232 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "foo.co
m", true, null, false); | |
233 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "foo.co
m.", true, null, false); | |
234 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "www.fo
o.com", true, null, false); | |
235 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "www.fo
o.com.", true, null, false); | |
236 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "Foo.co
m", true, null, false); | |
237 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "abc.de
f.foo.com", true, null, false); | |
238 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "www.ba
z.com", true, null, true); | |
239 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", null, t
rue, null, true); | |
240 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "foo.co
m", true, null, false); | |
241 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "foo.co
m.", true, null, false); | |
242 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "www.fo
o.com", true, null, false); | |
243 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "www.fo
o.com.", true, null, false); | |
244 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "Foo.co
m", true, null, false); | |
245 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "abc.de
f.foo.com", true, null, false); | |
246 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "www.ba
z.com", true, null, true); | |
247 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", null, t
rue, null, true); | |
248 testMatch("abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "foo.com
", true, null, true); | |
249 testMatch("abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "bar.com
", true, null, false); | |
250 testMatch("abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "baz.com
", true, null, false); | |
251 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "foo
.com", true, null, true); | |
252 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www
.foo.com", true, null, true); | |
253 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "bar
.foo.com", true, null, false); | |
254 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www
.bar.foo.com", true, null, false); | |
255 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "baz
.com", true, null, false); | |
256 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www
.baz.com", true, null, false); | |
257 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.com", t
rue, null, true); | |
258 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.net", t
rue, null, false); | |
259 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.com", t
rue, null, false); | |
260 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.net", t
rue, null, false); | |
261 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "com", true,
null, true); | |
262 testMatch("abc$domain=foo.com", "http://ccc/def", "IMAGE", "foo.com", true,
null, false); | |
263 testMatch("abc$domain=foo.com", "http://ccc/def", "IMAGE", "bar.com", true,
null, false); | |
264 testMatch("abc$image,domain=foo.com", "http://abc/def", "IMAGE", "foo.com",
true, null, true); | |
265 testMatch("abc$image,domain=foo.com", "http://abc/def", "IMAGE", "bar.com",
true, null, false); | |
266 testMatch("abc$image,domain=foo.com", "http://abc/def", "OBJECT", "foo.com",
true, null, false); | |
267 testMatch("abc$image,domain=foo.com", "http://abc/def", "OBJECT", "bar.com",
true, null, false); | |
268 testMatch("abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "foo.com",
true, null, false); | |
269 testMatch("abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "bar.com",
true, null, false); | |
270 testMatch("abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "foo.com"
, true, null, true); | |
271 testMatch("abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "bar.com"
, true, null, false); | |
272 testMatch("abc$domain=foo.com,image", "http://abc/def", "IMAGE", "foo.com",
true, null, true); | |
273 testMatch("abc$domain=foo.com,image", "http://abc/def", "IMAGE", "bar.com",
true, null, false); | |
274 testMatch("abc$domain=foo.com,image", "http://abc/def", "OBJECT", "foo.com",
true, null, false); | |
275 testMatch("abc$domain=foo.com,image", "http://abc/def", "OBJECT", "bar.com",
true, null, false); | |
276 testMatch("abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "foo.com",
true, null, false); | |
277 testMatch("abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "bar.com",
true, null, false); | |
278 testMatch("abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "foo.com"
, true, null, true); | |
279 testMatch("abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "bar.com"
, true, null, false); | |
280 }); | |
281 | |
282 test("Sitekey restrictions", function() | |
283 { | |
284 testMatch("abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com",
true, "foo-publickey", true); | |
285 testMatch("abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com",
true, null, false); | |
286 testMatch("abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com",
true, "bar-publickey", false); | |
287 testMatch("abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", "IMAG
E", "foo.com", true, "foo-publickey", true); | |
288 testMatch("abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", "IMAG
E", "foo.com", true, null, false); | |
289 testMatch("abc$sitekey=bar-publickey|foo-publickey", "http://abc/def", "IMAG
E", "foo.com", true, "foo-publickey", true); | |
290 testMatch("abc$sitekey=foo-publickey", "http://ccc/def", "IMAGE", "foo.com",
true, "foo-publickey", false); | |
291 testMatch("abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMA
GE", "foo.com", true, "foo-publickey", true); | |
292 testMatch("abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMA
GE", "bar.com", true, "foo-publickey", false); | |
293 testMatch("abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IM
AGE", "foo.com", true, "foo-publickey", false); | |
294 testMatch("abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IM
AGE", "bar.com", true, "foo-publickey", true); | |
295 }); | |
296 | |
297 test("Exception rules", function() | |
298 { | |
299 testMatch("@@test", "http://test/", "DOCUMENT", null, false, null, false); | |
300 testMatch("@@http://test*", "http://test/", "DOCUMENT", null, false, null, f
alse); | |
301 testMatch("@@ftp://test*", "ftp://test/", "DOCUMENT", null, false, null, fal
se); | |
302 testMatch("@@test$document", "http://test/", "DOCUMENT", null, false, null,
true); | |
303 testMatch("@@test$document,image", "http://test/", "DOCUMENT", null, false,
null, true); | |
304 testMatch("@@test$~image", "http://test/", "DOCUMENT", null, false, null, fa
lse); | |
305 testMatch("@@test$~image,document", "http://test/", "DOCUMENT", null, false,
null, true); | |
306 testMatch("@@test$document,~image", "http://test/", "DOCUMENT", null, false,
null, true); | |
307 testMatch("@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "foo
.com", false, null, true); | |
308 testMatch("@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "bar
.com", false, null, false); | |
309 testMatch("@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "fo
o.com", false, null, false); | |
310 testMatch("@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "ba
r.com", false, null, true); | |
311 testMatch("@@test$document,sitekey=foo-publickey", "http://test/", "DOCUMENT
", "foo.com", false, "foo-publickey", true); | |
312 testMatch("@@test$document,sitekey=foo-publickey", "http://test/", "DOCUMENT
", "foo.com", false, null, false); | |
313 }); | |
314 })(); | |
OLD | NEW |