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

Side by Side Diff: test/abp2blocklist.js

Issue 29452289: Issue 5283 - Add support for $websocket and $webrtc (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Generate additional rules if filter contains URL scheme Created June 2, 2017, 7:43 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 | « node_modules/filterClasses.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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
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", "document"]},
91 action: {type: "block"}}, 91 action: {type: "block"}},
92 {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com", 92 {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com",
93 "url-filter-is-case-sensitive": true, 93 "url-filter-is-case-sensitive": true,
94 "resource-type": ["image", "style-sheet", "script", "font", 94 "resource-type": ["image", "style-sheet", "script", "font",
95 "media", "raw", "document"]}, 95 "media", "raw", "document"]},
96 action: {type: "block"}}, 96 action: {type: "block"}},
97 {trigger: {"url-filter": "http://example\\.com/foo", 97 {trigger: {"url-filter": "^http://example\\.com/foo",
98 "resource-type": ["image", "style-sheet", "script", "font",
99 "media", "raw", "document"]},
100 action: {type: "block"}},
101 {trigger: {"url-filter": "^https?://.*http://example\\.com/foo",
98 "resource-type": ["image", "style-sheet", "script", "font", 102 "resource-type": ["image", "style-sheet", "script", "font",
99 "media", "raw", "document"]}, 103 "media", "raw", "document"]},
100 action: {type: "block"}} 104 action: {type: "block"}}
101 ]); 105 ]);
102 106
103 testRules(test, ["||example.com"], [ 107 testRules(test, ["||example.com"], [
104 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", 108 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com",
105 "url-filter-is-case-sensitive": true, 109 "url-filter-is-case-sensitive": true,
106 "resource-type": ["image", "style-sheet", "script", "font", 110 "resource-type": ["image", "style-sheet", "script", "font",
107 "media", "raw", "document"]}, 111 "media", "raw", "document"]},
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 211
208 test.done(); 212 test.done();
209 }, 213 },
210 214
211 testRequestTypeMapping: function(test) 215 testRequestTypeMapping: function(test)
212 { 216 {
213 testRules( 217 testRules(
214 test, 218 test,
215 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", 219 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media",
216 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", 220 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest",
217 "11$ping", "12$subdocument", "13$other", "14$IMAGE", 221 "11$websocket", "12$webrtc",
218 "15$script,PING,Popup", "16$~image"], 222 "13$ping", "14$subdocument", "15$other", "16$IMAGE",
223 "17$script,PING,Popup", "18$~image"],
219 [["image", "style-sheet", "script", "font", "media", "raw", "document" ], 224 [["image", "style-sheet", "script", "font", "media", "raw", "document" ],
220 ["image"], 225 ["image"],
221 ["style-sheet"], 226 ["style-sheet"],
222 ["script"], 227 ["script"],
223 ["font"], 228 ["font"],
224 ["media"], 229 ["media"],
225 ["popup"], 230 ["popup"],
226 ["media"], 231 ["media"],
227 ["raw"], 232 ["raw"],
228 ["raw"], 233 ["raw"],
234 ["raw"], // WebSocket
235 ["raw"], // WebRTC: STUN
236 ["raw"], // WebRTC: TURN
229 ["raw"], 237 ["raw"],
230 ["document"], 238 ["document"],
231 ["raw"], 239 ["raw"],
232 ["image"], 240 ["image"],
233 ["script", "popup", "raw" ], 241 ["script", "popup", "raw" ],
234 ["style-sheet", "script", "font", "media", "raw", "document"]], 242 ["style-sheet", "script", "font", "media", "raw", "document"]],
235 rules => rules.map(rule => rule.trigger["resource-type"]) 243 rules => rules.map(rule => rule.trigger["resource-type"])
236 ); 244 );
237 245
238 test.done(); 246 test.done();
(...skipping 28 matching lines...) Expand all
267 }, 275 },
268 276
269 testUnicode: function(test) 277 testUnicode: function(test)
270 { 278 {
271 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], 279 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"],
272 rules => rules[0]["trigger"]["if-domain"]); 280 rules => rules[0]["trigger"]["if-domain"]);
273 testRules(test, ["🐈$domain=🐈.cat"], []); 281 testRules(test, ["🐈$domain=🐈.cat"], []);
274 testRules(test, ["###🐈"], []); 282 testRules(test, ["###🐈"], []);
275 283
276 test.done(); 284 test.done();
285 },
286
287 testWebSocket: function(test)
288 {
289 testRules(test, ["foo$websocket"], [
290 {trigger: {"url-filter": "^wss?://.*foo", "resource-type": ["raw"]},
291 action: {type: "block"}}
292 ]);
293
294 test.done();
295 },
296
297 testWebRTC: function(test)
298 {
299 testRules(test, ["foo$webrtc"], [
300 {trigger: {"url-filter": "^stuns?:.*foo", "resource-type": ["raw"]},
301 action: {type: "block"}},
302 {trigger: {"url-filter": "^turns?:.*foo", "resource-type": ["raw"]},
303 action: {type: "block"}}
304 ]);
305
306 test.done();
277 } 307 }
278 }; 308 };
OLDNEW
« no previous file with comments | « node_modules/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld