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: Created Aug. 19, 2016, 5:55 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 test.done(); 174 test.done();
175 }, 175 },
176 176
177 testRequestTypeMapping: function(test) 177 testRequestTypeMapping: function(test)
178 { 178 {
179 testRules( 179 testRules(
180 test, 180 test,
181 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", 181 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media",
182 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", 182 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest",
183 "11$ping", "12$subdocument", "13$other", "14$IMAGE", 183 "11$ping", "12$other", "13$IMAGE", "14$script,PING,Popup", "15$~image"],
184 "15$script,PING,Popup", "16$~image"], 184 [["image", "style-sheet", "script", "font", "media", "raw"],
185 [["image", "style-sheet", "script", "font", "media", "raw", "document" ],
186 ["image"], 185 ["image"],
187 ["style-sheet"], 186 ["style-sheet"],
188 ["script"], 187 ["script"],
189 ["font"], 188 ["font"],
190 ["media"], 189 ["media"],
191 ["popup"], 190 ["popup"],
192 ["media"], 191 ["media"],
193 ["raw"], 192 ["raw"],
194 ["raw"], 193 ["raw"],
195 ["raw"], 194 ["raw"],
196 ["document"],
197 ["raw"], 195 ["raw"],
198 ["image"], 196 ["image"],
199 ["script", "popup", "raw" ], 197 ["script", "popup", "raw" ],
198 ["style-sheet", "script", "font", "media", "raw"]],
199 rules => rules.map(rule => rule.trigger["resource-type"])
200 );
201
202 testRules(
203 test,
204 ["foo$subdocument", "||foo.com$subdocument", "||foo.com$~image"],
205 [["document"],
200 ["style-sheet", "script", "font", "media", "raw", "document"]], 206 ["style-sheet", "script", "font", "media", "raw", "document"]],
201 rules => rules.map(rule => rule.trigger["resource-type"]) 207 rules => rules.map(rule => rule.trigger["resource-type"])
202 ); 208 );
203 209
204 test.done(); 210 test.done();
205 }, 211 },
206 212
207 testUnsupportedfilters: function(test) 213 testUnsupportedfilters: function(test)
208 { 214 {
209 // These types of filters are currently completely unsupported. 215 // These types of filters are currently completely unsupported.
(...skipping 18 matching lines...) Expand all
228 testUnicode: function(test) 234 testUnicode: function(test)
229 { 235 {
230 testRules(test, ["$domain=🐈.cat"], ["xn--zn8h.cat", "www.xn--zn8h.cat"], 236 testRules(test, ["$domain=🐈.cat"], ["xn--zn8h.cat", "www.xn--zn8h.cat"],
231 rules => rules[0]["trigger"]["if-domain"]); 237 rules => rules[0]["trigger"]["if-domain"]);
232 testRules(test, ["🐈$domain=🐈.cat"], []); 238 testRules(test, ["🐈$domain=🐈.cat"], []);
233 testRules(test, ["###🐈"], []); 239 testRules(test, ["###🐈"], []);
234 240
235 test.done(); 241 test.done();
236 } 242 }
237 }; 243 };
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