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

Delta Between Two Patch Sets: test/abp2blocklist.js

Issue 29443587: Noissue - Do not add subdomain wildcard if subdomain excluded (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Left Patch Set: Add unit tests Created May 21, 2017, 9:43 p.m.
Right Patch Set: Rebase Created May 23, 2017, 5:03 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 ["style-sheet", "script", "font", "media", "raw", "document"]], 214 ["style-sheet", "script", "font", "media", "raw", "document"]],
199 rules => rules.map(rule => rule.trigger["resource-type"]) 215 rules => rules.map(rule => rule.trigger["resource-type"])
200 ); 216 );
201 217
202 test.done(); 218 test.done();
203 }, 219 },
204 220
205 testUnsupportedfilters: function(test) 221 testUnsupportedfilters: function(test)
206 { 222 {
207 // These types of filters are currently completely unsupported. 223 // These types of filters are currently completely unsupported.
208 testRules(test, ["foo$sitekey=bar", "@@foo$genericblock", 224 testRules(test, ["foo$sitekey=bar", "@@foo$genericblock"], []);
209 "@@bar$generichide"], []);
210 225
211 test.done(); 226 test.done();
212 }, 227 },
213 228
214 testFilterOptions: function(test) 229 testFilterOptions: function(test)
215 { 230 {
216 testRules(test, ["1$domain=foo.com"], ["*foo.com"], 231 testRules(test, ["1$domain=foo.com"], ["*foo.com"],
217 rules => rules[0]["trigger"]["if-domain"]); 232 rules => rules[0]["trigger"]["if-domain"]);
218 testRules(test, ["2$third-party"], ["third-party"], 233 testRules(test, ["2$third-party"], ["third-party"],
219 rules => rules[0]["trigger"]["load-type"]); 234 rules => rules[0]["trigger"]["load-type"]);
(...skipping 14 matching lines...) Expand all
234 testUnicode: function(test) 249 testUnicode: function(test)
235 { 250 {
236 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], 251 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"],
237 rules => rules[0]["trigger"]["if-domain"]); 252 rules => rules[0]["trigger"]["if-domain"]);
238 testRules(test, ["🐈$domain=🐈.cat"], []); 253 testRules(test, ["🐈$domain=🐈.cat"], []);
239 testRules(test, ["###🐈"], []); 254 testRules(test, ["###🐈"], []);
240 255
241 test.done(); 256 test.done();
242 } 257 }
243 }; 258 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld