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

Side by Side Diff: test/abp2blocklist.js

Issue 29441592: Issue 4329 - Add $genericblock support (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Fix bug: Make a copy of the exceptionDomains array Created May 20, 2017, 1:59 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
« lib/abp2blocklist.js ('K') | « lib/abp2blocklist.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ]); 147 ]);
148 testRules(test, ["@@||example.com/path^$font,document"], [ 148 testRules(test, ["@@||example.com/path^$font,document"], [
149 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com/path", 149 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com/path",
150 "resource-type": ["font"]}, 150 "resource-type": ["font"]},
151 action: {type: "ignore-previous-rules"}} 151 action: {type: "ignore-previous-rules"}}
152 ]); 152 ]);
153 153
154 test.done(); 154 test.done();
155 }, 155 },
156 156
157 testGenericblockExceptions: function(test)
158 {
159 testRules(test, ["^ad.jpg|", "@@||example.com^$genericblock"],
160 [[undefined, ["*example.com"]]],
161 rules => rules.map(rule => [rule.trigger["if-domain"],
162 rule.trigger["unless-domain"]]));
163 testRules(test, ["^ad.jpg|$domain=test.com",
164 "@@||example.com^$genericblock"],
165 [[["*test.com"], undefined]],
166 rules => rules.map(rule => [rule.trigger["if-domain"],
167 rule.trigger["unless-domain"]]));
168 testRules(test, ["^ad.jpg|$domain=~test.com",
169 "@@||example.com^$genericblock"],
170 [[undefined, ["*example.com", "*test.com"]]],
171 rules => rules.map(rule => [rule.trigger["if-domain"],
172 rule.trigger["unless-domain"]]));
173
174 test.done();
175 },
176
157 testRuleOrdering: function(test) 177 testRuleOrdering: function(test)
158 { 178 {
159 testRules( 179 testRules(
160 test, 180 test,
161 ["/ads.jpg", "@@example.com", "test.com#@#foo", "##bar"], 181 ["/ads.jpg", "@@example.com", "test.com#@#foo", "##bar"],
162 ["css-display-none", "block", "ignore-previous-rules"], 182 ["css-display-none", "block", "ignore-previous-rules"],
163 rules => rules.map(rule => rule.action.type) 183 rules => rules.map(rule => rule.action.type)
164 ); 184 );
165 testRules( 185 testRules(
166 test, 186 test,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 ["style-sheet", "script", "font", "media", "raw", "document"]], 218 ["style-sheet", "script", "font", "media", "raw", "document"]],
199 rules => rules.map(rule => rule.trigger["resource-type"]) 219 rules => rules.map(rule => rule.trigger["resource-type"])
200 ); 220 );
201 221
202 test.done(); 222 test.done();
203 }, 223 },
204 224
205 testUnsupportedfilters: function(test) 225 testUnsupportedfilters: function(test)
206 { 226 {
207 // These types of filters are currently completely unsupported. 227 // These types of filters are currently completely unsupported.
208 testRules(test, ["foo$sitekey=bar", "@@foo$genericblock", 228 testRules(test, ["foo$sitekey=bar", "@@bar$generichide"], []);
209 "@@bar$generichide"], []);
210 229
211 test.done(); 230 test.done();
212 }, 231 },
213 232
214 testFilterOptions: function(test) 233 testFilterOptions: function(test)
215 { 234 {
216 testRules(test, ["1$domain=foo.com"], ["*foo.com"], 235 testRules(test, ["1$domain=foo.com"], ["*foo.com"],
217 rules => rules[0]["trigger"]["if-domain"]); 236 rules => rules[0]["trigger"]["if-domain"]);
218 testRules(test, ["2$third-party"], ["third-party"], 237 testRules(test, ["2$third-party"], ["third-party"],
219 rules => rules[0]["trigger"]["load-type"]); 238 rules => rules[0]["trigger"]["load-type"]);
220 testRules(test, ["foo$match_case"], true, 239 testRules(test, ["foo$match_case"], true,
221 rules => rules[0]["trigger"]["url-filter-is-case-sensitive"]); 240 rules => rules[0]["trigger"]["url-filter-is-case-sensitive"]);
222 241
223 test.done(); 242 test.done();
224 }, 243 },
225 244
226 testUnicode: function(test) 245 testUnicode: function(test)
227 { 246 {
228 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], 247 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"],
229 rules => rules[0]["trigger"]["if-domain"]); 248 rules => rules[0]["trigger"]["if-domain"]);
230 testRules(test, ["🐈$domain=🐈.cat"], []); 249 testRules(test, ["🐈$domain=🐈.cat"], []);
231 testRules(test, ["###🐈"], []); 250 testRules(test, ["###🐈"], []);
232 251
233 test.done(); 252 test.done();
234 } 253 }
235 }; 254 };
OLDNEW
« lib/abp2blocklist.js ('K') | « lib/abp2blocklist.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld