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

Delta Between Two Patch Sets: test/abp2blocklist.js

Issue 29441592: Issue 4329 - Add $genericblock support (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Left Patch Set: Add unit tests Created May 19, 2017, 2:10 a.m.
Right Patch Set: Rebase Created May 21, 2017, 9:26 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/abp2blocklist.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 {trigger: {"url-filter": "^https?://([^/:]*\\.)?test\\.com[/:]", 45 {trigger: {"url-filter": "^https?://([^/:]*\\.)?test\\.com[/:]",
46 "url-filter-is-case-sensitive": true}, 46 "url-filter-is-case-sensitive": true},
47 action: {type: "css-display-none", selector: ".whatever"}} 47 action: {type: "css-display-none", selector: ".whatever"}}
48 ]); 48 ]);
49 49
50 test.done(); 50 test.done();
51 }, 51 },
52 52
53 testElementHidingExceptions: function(test) 53 testElementHidingExceptions: function(test)
54 { 54 {
55 // Element hiding rules should be in the following order: (1) generic
56 // rules, (2) exceptions for generic rules, (3) domain-specific rules,
57 // (4) exceptions for all rules.
58 testRules(test, [
59 "##.whatever",
60 "test.com###something",
61 "@@||special.test.com^$elemhide",
62 "@@||test.com^$generichide"
63 ], [
64 ["^https?://", "css-display-none"],
65 ["^https?://([^/]+\\.)?test\\.com", "ignore-previous-rules"],
66 ["^https?://([^/:]*\\.)?test\\.com[/:]", "css-display-none"],
67 ["^https?://([^/]+\\.)?special\\.test\\.com", "ignore-previous-rules"]
68 ], rules => rules.map(rule => [rule.trigger["url-filter"],
69 rule.action.type]));
70
55 testRules(test, ["#@#whatever"], []); 71 testRules(test, ["#@#whatever"], []);
56 testRules(test, ["test.com#@#whatever"], []); 72 testRules(test, ["test.com#@#whatever"], []);
57 testRules(test, ["~test.com#@#whatever"], []); 73 testRules(test, ["~test.com#@#whatever"], []);
58 74
59 // We currently completely ignore any element hiding filters that have the 75 // We currently completely ignore any element hiding filters that have the
60 // same selector as an element hiding exception. In these examples #whatever 76 // same selector as an element hiding exception. In these examples #whatever
61 // should be hidden for all domains not ending in test.com instead of 77 // should be hidden for all domains not ending in test.com instead of
62 // nowhere! 78 // nowhere!
63 testRules(test, ["test.com#@#whatever", "##whatever"], []); 79 testRules(test, ["test.com#@#whatever", "##whatever"], []);
64 testRules(test, ["~test.com##whatever"], []); 80 testRules(test, ["~test.com##whatever"], []);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 [[undefined, ["*example.com"]]], 176 [[undefined, ["*example.com"]]],
161 rules => rules.map(rule => [rule.trigger["if-domain"], 177 rules => rules.map(rule => [rule.trigger["if-domain"],
162 rule.trigger["unless-domain"]])); 178 rule.trigger["unless-domain"]]));
163 testRules(test, ["^ad.jpg|$domain=test.com", 179 testRules(test, ["^ad.jpg|$domain=test.com",
164 "@@||example.com^$genericblock"], 180 "@@||example.com^$genericblock"],
165 [[["*test.com"], undefined]], 181 [[["*test.com"], undefined]],
166 rules => rules.map(rule => [rule.trigger["if-domain"], 182 rules => rules.map(rule => [rule.trigger["if-domain"],
167 rule.trigger["unless-domain"]])); 183 rule.trigger["unless-domain"]]));
168 testRules(test, ["^ad.jpg|$domain=~test.com", 184 testRules(test, ["^ad.jpg|$domain=~test.com",
169 "@@||example.com^$genericblock"], 185 "@@||example.com^$genericblock"],
170 [[undefined, ["*example.com", "*test.com"]]], 186 [[undefined, ["*test.com", "*example.com"]]],
171 rules => rules.map(rule => [rule.trigger["if-domain"], 187 rules => rules.map(rule => [rule.trigger["if-domain"],
172 rule.trigger["unless-domain"]])); 188 rule.trigger["unless-domain"]]));
173 189
174 test.done(); 190 test.done();
175 }, 191 },
176 192
177 testRuleOrdering: function(test) 193 testRuleOrdering: function(test)
178 { 194 {
179 testRules( 195 testRules(
180 test, 196 test,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 ["style-sheet", "script", "font", "media", "raw", "document"]], 234 ["style-sheet", "script", "font", "media", "raw", "document"]],
219 rules => rules.map(rule => rule.trigger["resource-type"]) 235 rules => rules.map(rule => rule.trigger["resource-type"])
220 ); 236 );
221 237
222 test.done(); 238 test.done();
223 }, 239 },
224 240
225 testUnsupportedfilters: function(test) 241 testUnsupportedfilters: function(test)
226 { 242 {
227 // These types of filters are currently completely unsupported. 243 // These types of filters are currently completely unsupported.
228 testRules(test, ["foo$sitekey=bar", "@@bar$generichide"], []); 244 testRules(test, ["foo$sitekey=bar"], []);
229 245
230 test.done(); 246 test.done();
231 }, 247 },
232 248
233 testFilterOptions: function(test) 249 testFilterOptions: function(test)
234 { 250 {
235 testRules(test, ["1$domain=foo.com"], ["*foo.com"], 251 testRules(test, ["1$domain=foo.com"], ["*foo.com"],
236 rules => rules[0]["trigger"]["if-domain"]); 252 rules => rules[0]["trigger"]["if-domain"]);
237 testRules(test, ["2$third-party"], ["third-party"], 253 testRules(test, ["2$third-party"], ["third-party"],
238 rules => rules[0]["trigger"]["load-type"]); 254 rules => rules[0]["trigger"]["load-type"]);
239 testRules(test, ["foo$match_case"], true, 255 testRules(test, ["foo$match_case"], true,
240 rules => rules[0]["trigger"]["url-filter-is-case-sensitive"]); 256 rules => rules[0]["trigger"]["url-filter-is-case-sensitive"]);
241 257
242 test.done(); 258 test.done();
243 }, 259 },
244 260
245 testUnicode: function(test) 261 testUnicode: function(test)
246 { 262 {
247 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], 263 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"],
248 rules => rules[0]["trigger"]["if-domain"]); 264 rules => rules[0]["trigger"]["if-domain"]);
249 testRules(test, ["🐈$domain=🐈.cat"], []); 265 testRules(test, ["🐈$domain=🐈.cat"], []);
250 testRules(test, ["###🐈"], []); 266 testRules(test, ["###🐈"], []);
251 267
252 test.done(); 268 test.done();
253 } 269 }
254 }; 270 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld