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

Side by Side Diff: test/abp2blocklist.js

Issue 29467595: Issue 5325 - Add support for separator characters (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Created June 16, 2017, 5:25 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // Element hiding rules should be in the following order: (1) generic 55 // Element hiding rules should be in the following order: (1) generic
56 // rules, (2) exceptions for generic rules, (3) domain-specific rules, 56 // rules, (2) exceptions for generic rules, (3) domain-specific rules,
57 // (4) exceptions for all rules. 57 // (4) exceptions for all rules.
58 testRules(test, [ 58 testRules(test, [
59 "##.whatever", 59 "##.whatever",
60 "test.com###something", 60 "test.com###something",
61 "@@||special.test.com^$elemhide", 61 "@@||special.test.com^$elemhide",
62 "@@||test.com^$generichide" 62 "@@||test.com^$generichide"
63 ], [ 63 ], [
64 ["^https?://", "css-display-none"], 64 ["^https?://", "css-display-none"],
65 ["^https?://([^/]+\\.)?test\\.com", "ignore-previous-rules"], 65 ["^https?://([^/]+\\.)?test\\.com([^.%A-Za-z0-9_].*)?$", "ignore-previous- rules"],
66 ["^https?://([^/:]*\\.)?test\\.com[/:]", "css-display-none"], 66 ["^https?://([^/:]*\\.)?test\\.com[/:]", "css-display-none"],
67 ["^https?://([^/]+\\.)?special\\.test\\.com", "ignore-previous-rules"] 67 ["^https?://([^/]+\\.)?special\\.test\\.com([^.%A-Za-z0-9_].*)?$", "ignore -previous-rules"]
68 ], rules => rules.map(rule => [rule.trigger["url-filter"], 68 ], rules => rules.map(rule => [rule.trigger["url-filter"],
69 rule.action.type])); 69 rule.action.type]));
70 70
71 testRules(test, ["#@#whatever"], []); 71 testRules(test, ["#@#whatever"], []);
72 testRules(test, ["test.com#@#whatever"], []); 72 testRules(test, ["test.com#@#whatever"], []);
73 testRules(test, ["~test.com#@#whatever"], []); 73 testRules(test, ["~test.com#@#whatever"], []);
74 74
75 // We currently completely ignore any element hiding filters that have the 75 // We currently completely ignore any element hiding filters that have the
76 // same selector as an element hiding exception. In these examples #whatever 76 // 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 77 // should be hidden for all domains not ending in test.com instead of
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 { 155 {
156 testRules(test, ["@@||example.com^$document"], [ 156 testRules(test, ["@@||example.com^$document"], [
157 {trigger: {"url-filter": ".*", 157 {trigger: {"url-filter": ".*",
158 "if-domain": ["*example.com"]}, 158 "if-domain": ["*example.com"]},
159 action: {type: "ignore-previous-rules"}} 159 action: {type: "ignore-previous-rules"}}
160 ]); 160 ]);
161 testRules(test, ["@@||example.com^$document,image"], [ 161 testRules(test, ["@@||example.com^$document,image"], [
162 {trigger: {"url-filter": ".*", 162 {trigger: {"url-filter": ".*",
163 "if-domain": ["*example.com"]}, 163 "if-domain": ["*example.com"]},
164 action: {type: "ignore-previous-rules"}}, 164 action: {type: "ignore-previous-rules"}},
165 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", 165 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com([^.%A-Za-z0-9 _].*)?$",
166 "url-filter-is-case-sensitive": true,
167 "resource-type": ["image"]}, 166 "resource-type": ["image"]},
168 action: {type: "ignore-previous-rules"}} 167 action: {type: "ignore-previous-rules"}}
169 ]); 168 ]);
170 testRules(test, ["@@||example.com/path^$font,document"], [ 169 testRules(test, ["@@||example.com/path^$font,document"], [
171 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com/path", 170 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com/path([^.%A-Za -z0-9_].*)?$",
172 "resource-type": ["font"]}, 171 "resource-type": ["font"]},
173 action: {type: "ignore-previous-rules"}} 172 action: {type: "ignore-previous-rules"}}
174 ]); 173 ]);
175 174
176 test.done(); 175 test.done();
177 }, 176 },
178 177
179 testGenericblockExceptions: function(test) 178 testGenericblockExceptions: function(test)
180 { 179 {
181 testRules(test, ["^ad.jpg|", "@@||example.com^$genericblock"], 180 testRules(test, ["^ad.jpg|", "@@||example.com^$genericblock"],
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 testUnicode: function(test) 274 testUnicode: function(test)
276 { 275 {
277 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], 276 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"],
278 rules => rules[0]["trigger"]["if-domain"]); 277 rules => rules[0]["trigger"]["if-domain"]);
279 testRules(test, ["🐈$domain=🐈.cat"], []); 278 testRules(test, ["🐈$domain=🐈.cat"], []);
280 testRules(test, ["###🐈"], []); 279 testRules(test, ["###🐈"], []);
281 280
282 test.done(); 281 test.done();
283 } 282 }
284 }; 283 };
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