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

Side by Side Diff: test/abp2blocklist.js

Issue 29473555: Issue 5345 - Whitelist $elemhide and $generichide domains where possible (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Rebase Created July 11, 2017, 5:28 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
« 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 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, [ 55 testRules(test, [
59 "##.whatever", 56 "##.whatever",
60 "test.com###something", 57 "test.com###something",
61 "@@||special.test.com^$elemhide", 58 "@@||special.test.com^$elemhide",
62 "@@||test.com^$generichide" 59 "@@||test.com^$generichide",
60 "@@^something^$elemhide",
61 "@@^anything^$generichide"
63 ], [ 62 ], [
64 ["^https?://", "css-display-none"], 63 ["^https?://", ["*test.com", "*special.test.com"]],
65 ["^https?://([^/]+\\.)?test\\.com", "ignore-previous-rules"], 64 ["^https?://([^/:]*\\.)?test\\.com[/:]", ["*special.test.com"]]
66 ["^https?://([^/:]*\\.)?test\\.com[/:]", "css-display-none"],
67 ["^https?://([^/]+\\.)?special\\.test\\.com", "ignore-previous-rules"]
68 ], rules => rules.map(rule => [rule.trigger["url-filter"], 65 ], rules => rules.map(rule => [rule.trigger["url-filter"],
69 rule.action.type])); 66 rule.trigger["unless-domain"]]));
70 67
71 testRules(test, ["#@#whatever"], []); 68 testRules(test, ["#@#whatever"], []);
72 testRules(test, ["test.com#@#whatever"], []); 69 testRules(test, ["test.com#@#whatever"], []);
73 testRules(test, ["~test.com#@#whatever"], []); 70 testRules(test, ["~test.com#@#whatever"], []);
74 71
75 // We currently completely ignore any element hiding filters that have the 72 // We currently completely ignore any element hiding filters that have the
76 // same selector as an element hiding exception. In these examples #whatever 73 // same selector as an element hiding exception. In these examples #whatever
77 // should be hidden for all domains not ending in test.com instead of 74 // should be hidden for all domains not ending in test.com instead of
78 // nowhere! 75 // nowhere!
79 testRules(test, ["test.com#@#whatever", "##whatever"], []); 76 testRules(test, ["test.com#@#whatever", "##whatever"], []);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 rules => rules[0]["trigger"]["url-filter"]); 277 rules => rules[0]["trigger"]["url-filter"]);
281 testRules(test, ["🐈%F0%9F%90%88$domain=🐈.cat"], 278 testRules(test, ["🐈%F0%9F%90%88$domain=🐈.cat"],
282 "^https?://.*%F0%9F%90%88%F0%9F%90%88", 279 "^https?://.*%F0%9F%90%88%F0%9F%90%88",
283 rules => rules[0]["trigger"]["url-filter"]); 280 rules => rules[0]["trigger"]["url-filter"]);
284 testRules(test, ["###🐈"], "[id=🐈]", 281 testRules(test, ["###🐈"], "[id=🐈]",
285 rules => rules[0]["action"]["selector"]); 282 rules => rules[0]["action"]["selector"]);
286 283
287 test.done(); 284 test.done();
288 } 285 }
289 }; 286 };
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