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

Delta Between Two Patch Sets: test/abp2blocklist.js

Issue 29467595: Issue 5325 - Add support for separator characters (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Left Patch Set: Add comment about using only lower case for hostname Created July 11, 2017, 5:06 p.m.
Right Patch Set: Rebase Created July 12, 2017, 12:45 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, [ 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([^-_.%a-z0-9].*)?$", 64 ["^https?://([^/:]*\\.)?test\\.com[/:]", ["*special.test.com"]]
66 "ignore-previous-rules"],
67 ["^https?://([^/:]*\\.)?test\\.com[/:]", "css-display-none"],
68 ["^https?://([^/]+\\.)?special\\.test\\.com([^-_.%a-z0-9].*)?$",
69 "ignore-previous-rules"]
70 ], rules => rules.map(rule => [rule.trigger["url-filter"], 65 ], rules => rules.map(rule => [rule.trigger["url-filter"],
71 rule.action.type])); 66 rule.trigger["unless-domain"]]));
72 67
73 testRules(test, ["#@#whatever"], []); 68 testRules(test, ["#@#whatever"], []);
74 testRules(test, ["test.com#@#whatever"], []); 69 testRules(test, ["test.com#@#whatever"], []);
75 testRules(test, ["~test.com#@#whatever"], []); 70 testRules(test, ["~test.com#@#whatever"], []);
76 71
77 // We currently completely ignore any element hiding filters that have the 72 // We currently completely ignore any element hiding filters that have the
78 // same selector as an element hiding exception. In these examples #whatever 73 // same selector as an element hiding exception. In these examples #whatever
79 // 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
80 // nowhere! 75 // nowhere!
81 testRules(test, ["test.com#@#whatever", "##whatever"], []); 76 testRules(test, ["test.com#@#whatever", "##whatever"], []);
82 testRules(test, ["~test.com##whatever"], []); 77 testRules(test, ["~test.com##whatever"], []);
83 78
84 test.done(); 79 test.done();
85 }, 80 },
86 81
87 testRequestFilters: function(test) 82 testRequestFilters: function(test)
88 { 83 {
89 testRules(test, [ 84 testRules(test, [
90 "/foo", "||test.com^", "http://example.com/foo", "^foo^" 85 "/foo", "||test.com^", "http://example.com/foo", "^foo^"
91 ], [ 86 ], [
92 { 87 {
93 trigger: { 88 trigger: {
94 "url-filter": "^https?://.*/foo", 89 "url-filter": "^https?://.*/foo",
95 "resource-type": ["image", "style-sheet", "script", "font", 90 "resource-type": ["image", "style-sheet", "script", "font",
96 "media", "raw", "document"], 91 "media", "raw"]
97 "unless-top-url": ["^https?://.*/foo"]
98 }, 92 },
99 action: {type: "block"} 93 action: {type: "block"}
100 }, 94 },
101 { 95 {
102 trigger: { 96 trigger: {
103 "url-filter": "^https?://([^/]+\\.)?test\\.com([^-_.%a-z0-9].*)?$", 97 "url-filter": "^https?://([^/]+\\.)?test\\.com([^-_.%a-z0-9].*)?$",
104 "url-filter-is-case-sensitive": true, 98 "url-filter-is-case-sensitive": true,
105 "resource-type": ["image", "style-sheet", "script", "font", 99 "resource-type": ["image", "style-sheet", "script", "font",
106 "media", "raw", "document"], 100 "media", "raw", "document"],
107 "unless-top-url": [ 101 "unless-top-url": [
(...skipping 10 matching lines...) Expand all
118 "media", "raw", "document"], 112 "media", "raw", "document"],
119 "unless-top-url": ["http://example\\.com/foo"] 113 "unless-top-url": ["http://example\\.com/foo"]
120 }, 114 },
121 action: {type: "block"} 115 action: {type: "block"}
122 }, 116 },
123 { 117 {
124 trigger: { 118 trigger: {
125 "url-filter": 119 "url-filter":
126 "^https?://(.*[^-_.%A-Za-z0-9])?foo([^-_.%A-Za-z0-9].*)?$", 120 "^https?://(.*[^-_.%A-Za-z0-9])?foo([^-_.%A-Za-z0-9].*)?$",
127 "resource-type": ["image", "style-sheet", "script", "font", 121 "resource-type": ["image", "style-sheet", "script", "font",
128 "media", "raw", "document"], 122 "media", "raw"]
129 "unless-top-url": [
130 "^https?://(.*[^-_.%A-Za-z0-9])?foo([^-_.%A-Za-z0-9].*)?$"
131 ]
132 }, 123 },
133 action: {type: "block"} 124 action: {type: "block"}
134 } 125 }
135 ]); 126 ]);
136 127
137 testRules(test, ["||example.com"], [ 128 testRules(test, ["||example.com"], [
138 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", 129 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com",
139 "url-filter-is-case-sensitive": true, 130 "url-filter-is-case-sensitive": true,
140 "resource-type": ["image", "style-sheet", "script", "font", 131 "resource-type": ["image", "style-sheet", "script", "font",
141 "media", "raw", "document"], 132 "media", "raw", "document"],
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 }, 253 },
263 254
264 testRequestTypeMapping: function(test) 255 testRequestTypeMapping: function(test)
265 { 256 {
266 testRules( 257 testRules(
267 test, 258 test,
268 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", 259 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media",
269 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", 260 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest",
270 "11$ping", "12$subdocument", "13$other", "14$IMAGE", 261 "11$ping", "12$subdocument", "13$other", "14$IMAGE",
271 "15$script,PING,Popup", "16$~image"], 262 "15$script,PING,Popup", "16$~image"],
272 [["image", "style-sheet", "script", "font", "media", "raw", "document" ], 263 [["image", "style-sheet", "script", "font", "media", "raw"],
273 ["image"], 264 ["image"],
274 ["style-sheet"], 265 ["style-sheet"],
275 ["script"], 266 ["script"],
276 ["font"], 267 ["font"],
277 ["media"], 268 ["media"],
278 ["popup"], 269 ["popup"],
279 ["media"], 270 ["media"],
280 ["raw"], 271 ["raw"],
281 ["raw"], 272 ["raw"],
282 ["raw"], 273 ["raw"],
283 ["document"],
284 ["raw"], 274 ["raw"],
285 ["image"], 275 ["image"],
286 ["script", "popup", "raw" ], 276 ["script", "popup", "raw" ],
287 ["style-sheet", "script", "font", "media", "raw", "document"]], 277 ["style-sheet", "script", "font", "media", "raw"]],
288 rules => rules.map(rule => rule.trigger["resource-type"]) 278 rules => rules.map(rule => rule.trigger["resource-type"])
289 ); 279 );
290 280
291 test.done(); 281 test.done();
292 }, 282 },
293 283
294 testUnsupportedfilters: function(test) 284 testUnsupportedfilters: function(test)
295 { 285 {
296 // These types of filters are currently completely unsupported. 286 // These types of filters are currently completely unsupported.
297 testRules(test, ["foo$sitekey=bar"], []); 287 testRules(test, ["foo$sitekey=bar"], []);
(...skipping 18 matching lines...) Expand all
316 ["foo.com"], 306 ["foo.com"],
317 rules => rules[0]["trigger"]["if-domain"]); 307 rules => rules[0]["trigger"]["if-domain"]);
318 308
319 test.done(); 309 test.done();
320 }, 310 },
321 311
322 testUnicode: function(test) 312 testUnicode: function(test)
323 { 313 {
324 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], 314 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"],
325 rules => rules[0]["trigger"]["if-domain"]); 315 rules => rules[0]["trigger"]["if-domain"]);
326 testRules(test, ["🐈$domain=🐈.cat"], []); 316 testRules(test, ["||🐈"], "^https?://([^/]+\\.)?xn--zn8h",
327 testRules(test, ["###🐈"], []); 317 rules => rules[0]["trigger"]["url-filter"]);
318 testRules(test, ["🐈$domain=🐈.cat"], "^https?://.*%F0%9F%90%88",
319 rules => rules[0]["trigger"]["url-filter"]);
320 testRules(test, ["🐈%F0%9F%90%88$domain=🐈.cat"],
321 "^https?://.*%F0%9F%90%88%F0%9F%90%88",
322 rules => rules[0]["trigger"]["url-filter"]);
323 testRules(test, ["###🐈"], "[id=🐈]",
324 rules => rules[0]["action"]["selector"]);
328 325
329 test.done(); 326 test.done();
330 } 327 }
331 }; 328 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld