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

Side by Side Diff: test/abp2blocklist.js

Issue 29349981: Noissue - Remove rules which match no resource types (Closed)
Patch Set: Remove redundant comment, use simpler test filters Created Aug. 22, 2016, 12:43 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
« 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 testRules(test, ["||example.com"], [ 87 testRules(test, ["||example.com"], [
88 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", 88 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com",
89 "url-filter-is-case-sensitive": true, 89 "url-filter-is-case-sensitive": true,
90 "resource-type": ["image", "style-sheet", "script", "font", 90 "resource-type": ["image", "style-sheet", "script", "font",
91 "media", "raw", "document"]}, 91 "media", "raw", "document"]},
92 92
93 action: {type: "block"}} 93 action: {type: "block"}}
94 ]); 94 ]);
95 95
96 // Rules which would match no resource-types shouldn't be generated.
97 testRules(test, ["foo$document", "||foo.com$document"], []);
96 98
97 test.done(); 99 test.done();
98 }, 100 },
99 101
100 testRequestFilterExceptions: function(test) 102 testRequestFilterExceptions: function(test)
101 { 103 {
102 testRules(test, ["@@example.com"], [ 104 testRules(test, ["@@example.com"], [
103 {trigger: {"url-filter": "^https?://.*example\\.com", 105 {trigger: {"url-filter": "^https?://.*example\\.com",
104 "resource-type": ["image", "style-sheet", "script", "font", 106 "resource-type": ["image", "style-sheet", "script", "font",
105 "media", "raw", "document"]}, 107 "media", "raw", "document"]},
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 171
170 test.done(); 172 test.done();
171 }, 173 },
172 174
173 testRequestTypeMapping: function(test) 175 testRequestTypeMapping: function(test)
174 { 176 {
175 testRules( 177 testRules(
176 test, 178 test,
177 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", 179 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media",
178 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", 180 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest",
179 "11$ping", "12$subdocument", "13$other", "14$IMAGE", "15$document", 181 "11$ping", "12$subdocument", "13$other", "14$IMAGE",
180 "16$script,PING,Popup", "17$~image"], 182 "15$script,PING,Popup", "16$~image"],
181 [["image", "style-sheet", "script", "font", "media", "raw", "document" ], 183 [["image", "style-sheet", "script", "font", "media", "raw", "document" ],
182 ["image"], 184 ["image"],
183 ["style-sheet"], 185 ["style-sheet"],
184 ["script"], 186 ["script"],
185 ["font"], 187 ["font"],
186 ["media"], 188 ["media"],
187 ["popup"], 189 ["popup"],
188 ["media"], 190 ["media"],
189 ["raw"], 191 ["raw"],
190 ["raw"], 192 ["raw"],
191 ["raw"], 193 ["raw"],
192 ["document"], 194 ["document"],
193 ["raw"], 195 ["raw"],
194 ["image"], 196 ["image"],
195 [],
196 ["script", "popup", "raw" ], 197 ["script", "popup", "raw" ],
197 ["style-sheet", "script", "font", "media", "raw", "document"]], 198 ["style-sheet", "script", "font", "media", "raw", "document"]],
198 rules => rules.map(rule => rule.trigger["resource-type"]) 199 rules => rules.map(rule => rule.trigger["resource-type"])
199 ); 200 );
200 201
201 test.done(); 202 test.done();
202 }, 203 },
203 204
204 testUnsupportedfilters: function(test) 205 testUnsupportedfilters: function(test)
205 { 206 {
(...skipping 19 matching lines...) Expand all
225 testUnicode: function(test) 226 testUnicode: function(test)
226 { 227 {
227 testRules(test, ["$domain=🐈.cat"], ["xn--zn8h.cat", "www.xn--zn8h.cat"], 228 testRules(test, ["$domain=🐈.cat"], ["xn--zn8h.cat", "www.xn--zn8h.cat"],
228 rules => rules[0]["trigger"]["if-domain"]); 229 rules => rules[0]["trigger"]["if-domain"]);
229 testRules(test, ["🐈$domain=🐈.cat"], []); 230 testRules(test, ["🐈$domain=🐈.cat"], []);
230 testRules(test, ["###🐈"], []); 231 testRules(test, ["###🐈"], []);
231 232
232 test.done(); 233 test.done();
233 } 234 }
234 }; 235 };
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