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

Side by Side Diff: test/abp2blocklist.js

Issue 29349989: Issue 4327 - Prevent generic document blocking (Closed)
Patch Set: Rebased. Created Aug. 22, 2016, 4:31 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 testRules(test, ["~test.com##whatever"], []); 64 testRules(test, ["~test.com##whatever"], []);
65 65
66 test.done(); 66 test.done();
67 }, 67 },
68 68
69 testRequestFilters: function(test) 69 testRequestFilters: function(test)
70 { 70 {
71 testRules(test, ["/foo", "||test.com", "http://example.com/foo"], [ 71 testRules(test, ["/foo", "||test.com", "http://example.com/foo"], [
72 {trigger: {"url-filter": "^https?://.*/foo", 72 {trigger: {"url-filter": "^https?://.*/foo",
73 "resource-type": ["image", "style-sheet", "script", "font", 73 "resource-type": ["image", "style-sheet", "script", "font",
74 "media", "raw", "document"]}, 74 "media", "raw"]},
75 action: {type: "block"}}, 75 action: {type: "block"}},
76 {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com", 76 {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com",
77 "url-filter-is-case-sensitive": true, 77 "url-filter-is-case-sensitive": true,
78 "resource-type": ["image", "style-sheet", "script", "font", 78 "resource-type": ["image", "style-sheet", "script", "font",
79 "media", "raw", "document"]}, 79 "media", "raw", "document"]},
80 action: {type: "block"}}, 80 action: {type: "block"}},
81 {trigger: {"url-filter": "http://example\\.com/foo", 81 {trigger: {"url-filter": "http://example\\.com/foo",
82 "resource-type": ["image", "style-sheet", "script", "font", 82 "resource-type": ["image", "style-sheet", "script", "font",
83 "media", "raw", "document"]}, 83 "media", "raw", "document"]},
84 action: {type: "block"}} 84 action: {type: "block"}}
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 test.done(); 172 test.done();
173 }, 173 },
174 174
175 testRequestTypeMapping: function(test) 175 testRequestTypeMapping: function(test)
176 { 176 {
177 testRules( 177 testRules(
178 test, 178 test,
179 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", 179 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media",
180 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", 180 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest",
181 "11$ping", "12$subdocument", "13$other", "14$IMAGE", 181 "11$ping", "12$other", "13$IMAGE", "14$script,PING,Popup", "15$~image"],
182 "15$script,PING,Popup", "16$~image"], 182 [["image", "style-sheet", "script", "font", "media", "raw"],
183 [["image", "style-sheet", "script", "font", "media", "raw", "document" ],
184 ["image"], 183 ["image"],
185 ["style-sheet"], 184 ["style-sheet"],
186 ["script"], 185 ["script"],
187 ["font"], 186 ["font"],
188 ["media"], 187 ["media"],
189 ["popup"], 188 ["popup"],
190 ["media"], 189 ["media"],
191 ["raw"], 190 ["raw"],
192 ["raw"], 191 ["raw"],
193 ["raw"], 192 ["raw"],
194 ["document"],
195 ["raw"], 193 ["raw"],
196 ["image"], 194 ["image"],
197 ["script", "popup", "raw" ], 195 ["script", "popup", "raw" ],
196 ["style-sheet", "script", "font", "media", "raw"]],
197 rules => rules.map(rule => rule.trigger["resource-type"])
198 );
199
200 testRules(
201 test,
202 ["foo$subdocument", "||foo.com$subdocument", "||foo.com$~image"],
203 [["document"],
198 ["style-sheet", "script", "font", "media", "raw", "document"]], 204 ["style-sheet", "script", "font", "media", "raw", "document"]],
199 rules => rules.map(rule => rule.trigger["resource-type"]) 205 rules => rules.map(rule => rule.trigger["resource-type"])
200 ); 206 );
201 207
202 test.done(); 208 test.done();
203 }, 209 },
204 210
205 testUnsupportedfilters: function(test) 211 testUnsupportedfilters: function(test)
206 { 212 {
207 // These types of filters are currently completely unsupported. 213 // These types of filters are currently completely unsupported.
(...skipping 18 matching lines...) Expand all
226 testUnicode: function(test) 232 testUnicode: function(test)
227 { 233 {
228 testRules(test, ["$domain=🐈.cat"], ["xn--zn8h.cat", "www.xn--zn8h.cat"], 234 testRules(test, ["$domain=🐈.cat"], ["xn--zn8h.cat", "www.xn--zn8h.cat"],
229 rules => rules[0]["trigger"]["if-domain"]); 235 rules => rules[0]["trigger"]["if-domain"]);
230 testRules(test, ["🐈$domain=🐈.cat"], []); 236 testRules(test, ["🐈$domain=🐈.cat"], []);
231 testRules(test, ["###🐈"], []); 237 testRules(test, ["###🐈"], []);
232 238
233 test.done(); 239 test.done();
234 } 240 }
235 }; 241 };
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