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

Side by Side Diff: test/abp2blocklist.js

Issue 29467585: Issue 4327 - Prevent filters with no hostname from blocking documents (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Add comments Created July 8, 2017, 11:28 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 testRules(test, ["~test.com##whatever"], []); 80 testRules(test, ["~test.com##whatever"], []);
81 81
82 test.done(); 82 test.done();
83 }, 83 },
84 84
85 testRequestFilters: function(test) 85 testRequestFilters: function(test)
86 { 86 {
87 testRules(test, ["/foo", "||test.com", "http://example.com/foo"], [ 87 testRules(test, ["/foo", "||test.com", "http://example.com/foo"], [
88 {trigger: {"url-filter": "^https?://.*/foo", 88 {trigger: {"url-filter": "^https?://.*/foo",
89 "resource-type": ["image", "style-sheet", "script", "font", 89 "resource-type": ["image", "style-sheet", "script", "font",
90 "media", "raw", "document"], 90 "media", "raw"]},
91 "unless-top-url": ["^https?://.*/foo"]},
92 action: {type: "block"}}, 91 action: {type: "block"}},
93 {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com", 92 {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com",
94 "url-filter-is-case-sensitive": true, 93 "url-filter-is-case-sensitive": true,
95 "resource-type": ["image", "style-sheet", "script", "font", 94 "resource-type": ["image", "style-sheet", "script", "font",
96 "media", "raw", "document"], 95 "media", "raw", "document"],
97 "unless-top-url": ["^https?://([^/]+\\.)?test\\.com"], 96 "unless-top-url": ["^https?://([^/]+\\.)?test\\.com"],
98 "top-url-filter-is-case-sensitive": true}, 97 "top-url-filter-is-case-sensitive": true},
99 action: {type: "block"}}, 98 action: {type: "block"}},
100 {trigger: {"url-filter": "http://example\\.com/foo", 99 {trigger: {"url-filter": "http://example\\.com/foo",
101 "resource-type": ["image", "style-sheet", "script", "font", 100 "resource-type": ["image", "style-sheet", "script", "font",
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 }, 214 },
216 215
217 testRequestTypeMapping: function(test) 216 testRequestTypeMapping: function(test)
218 { 217 {
219 testRules( 218 testRules(
220 test, 219 test,
221 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", 220 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media",
222 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", 221 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest",
223 "11$ping", "12$subdocument", "13$other", "14$IMAGE", 222 "11$ping", "12$subdocument", "13$other", "14$IMAGE",
224 "15$script,PING,Popup", "16$~image"], 223 "15$script,PING,Popup", "16$~image"],
225 [["image", "style-sheet", "script", "font", "media", "raw", "document" ], 224 [["image", "style-sheet", "script", "font", "media", "raw"],
226 ["image"], 225 ["image"],
227 ["style-sheet"], 226 ["style-sheet"],
228 ["script"], 227 ["script"],
229 ["font"], 228 ["font"],
230 ["media"], 229 ["media"],
231 ["popup"], 230 ["popup"],
232 ["media"], 231 ["media"],
233 ["raw"], 232 ["raw"],
234 ["raw"], 233 ["raw"],
235 ["raw"], 234 ["raw"],
236 ["document"],
237 ["raw"], 235 ["raw"],
238 ["image"], 236 ["image"],
239 ["script", "popup", "raw" ], 237 ["script", "popup", "raw" ],
240 ["style-sheet", "script", "font", "media", "raw", "document"]], 238 ["style-sheet", "script", "font", "media", "raw"]],
241 rules => rules.map(rule => rule.trigger["resource-type"]) 239 rules => rules.map(rule => rule.trigger["resource-type"])
242 ); 240 );
243 241
244 test.done(); 242 test.done();
245 }, 243 },
246 244
247 testUnsupportedfilters: function(test) 245 testUnsupportedfilters: function(test)
248 { 246 {
249 // These types of filters are currently completely unsupported. 247 // These types of filters are currently completely unsupported.
250 testRules(test, ["foo$sitekey=bar"], []); 248 testRules(test, ["foo$sitekey=bar"], []);
(...skipping 24 matching lines...) Expand all
275 testUnicode: function(test) 273 testUnicode: function(test)
276 { 274 {
277 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], 275 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"],
278 rules => rules[0]["trigger"]["if-domain"]); 276 rules => rules[0]["trigger"]["if-domain"]);
279 testRules(test, ["🐈$domain=🐈.cat"], []); 277 testRules(test, ["🐈$domain=🐈.cat"], []);
280 testRules(test, ["###🐈"], []); 278 testRules(test, ["###🐈"], []);
281 279
282 test.done(); 280 test.done();
283 } 281 }
284 }; 282 };
OLDNEW
« no previous file with comments | « lib/abp2blocklist.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld