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: Created Aug. 19, 2016, 5:33 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-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$~image,~stylesheet,~script,~font,~media,~object," +
98 "~xmlhttprequest,~object_subrequest,~ping,~other," +
Sebastian Noack 2016/08/20 13:42:50 It's document as $object-subrequest, with dash, no
kzar 2016/08/22 12:44:36 Good point, but since it's kind of a stupid test I
99 "~subdocument", "foo$document"], []);
96 100
97 test.done(); 101 test.done();
98 }, 102 },
99 103
100 testRequestFilterExceptions: function(test) 104 testRequestFilterExceptions: function(test)
101 { 105 {
102 testRules(test, ["@@example.com"], [ 106 testRules(test, ["@@example.com"], [
103 {trigger: {"url-filter": "^https?://.*example\\.com", 107 {trigger: {"url-filter": "^https?://.*example\\.com",
104 "resource-type": ["image", "style-sheet", "script", "font", 108 "resource-type": ["image", "style-sheet", "script", "font",
105 "media", "raw", "document"]}, 109 "media", "raw", "document"]},
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 173
170 test.done(); 174 test.done();
171 }, 175 },
172 176
173 testRequestTypeMapping: function(test) 177 testRequestTypeMapping: function(test)
174 { 178 {
175 testRules( 179 testRules(
176 test, 180 test,
177 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", 181 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media",
178 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", 182 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest",
179 "11$ping", "12$subdocument", "13$other", "14$IMAGE", "15$document", 183 "11$ping", "12$subdocument", "13$other", "14$IMAGE",
180 "16$script,PING,Popup", "17$~image"], 184 "15$script,PING,Popup", "16$~image"],
181 [["image", "style-sheet", "script", "font", "media", "raw", "document" ], 185 [["image", "style-sheet", "script", "font", "media", "raw", "document" ],
182 ["image"], 186 ["image"],
183 ["style-sheet"], 187 ["style-sheet"],
184 ["script"], 188 ["script"],
185 ["font"], 189 ["font"],
186 ["media"], 190 ["media"],
187 ["popup"], 191 ["popup"],
188 ["media"], 192 ["media"],
189 ["raw"], 193 ["raw"],
190 ["raw"], 194 ["raw"],
191 ["raw"], 195 ["raw"],
192 ["document"], 196 ["document"],
193 ["raw"], 197 ["raw"],
194 ["image"], 198 ["image"],
195 [],
196 ["script", "popup", "raw" ], 199 ["script", "popup", "raw" ],
197 ["style-sheet", "script", "font", "media", "raw", "document"]], 200 ["style-sheet", "script", "font", "media", "raw", "document"]],
198 rules => rules.map(rule => rule.trigger["resource-type"]) 201 rules => rules.map(rule => rule.trigger["resource-type"])
199 ); 202 );
200 203
201 test.done(); 204 test.done();
202 }, 205 },
203 206
204 testUnsupportedfilters: function(test) 207 testUnsupportedfilters: function(test)
205 { 208 {
(...skipping 19 matching lines...) Expand all
225 testUnicode: function(test) 228 testUnicode: function(test)
226 { 229 {
227 testRules(test, ["$domain=🐈.cat"], ["xn--zn8h.cat", "www.xn--zn8h.cat"], 230 testRules(test, ["$domain=🐈.cat"], ["xn--zn8h.cat", "www.xn--zn8h.cat"],
228 rules => rules[0]["trigger"]["if-domain"]); 231 rules => rules[0]["trigger"]["if-domain"]);
229 testRules(test, ["🐈$domain=🐈.cat"], []); 232 testRules(test, ["🐈$domain=🐈.cat"], []);
230 testRules(test, ["###🐈"], []); 233 testRules(test, ["###🐈"], []);
231 234
232 test.done(); 235 test.done();
233 } 236 }
234 }; 237 };
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