Left: | ||
Right: |
OLD | NEW |
---|---|
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 // should be hidden for all domains not ending in test.com instead of | 77 // should be hidden for all domains not ending in test.com instead of |
78 // nowhere! | 78 // nowhere! |
79 testRules(test, ["test.com#@#whatever", "##whatever"], []); | 79 testRules(test, ["test.com#@#whatever", "##whatever"], []); |
80 testRules(test, ["~test.com##whatever"], []); | 80 testRules(test, ["~test.com##whatever"], []); |
81 | 81 |
82 test.done(); | 82 test.done(); |
83 }, | 83 }, |
84 | 84 |
85 testRequestFilters: function(test) | 85 testRequestFilters: function(test) |
86 { | 86 { |
87 testRules(test, ["/foo", "||test.com", "http://example.com/foo"], [ | 87 testRules(test, ["/foo", "||test.com", "|http://example.com/foo"], [ |
Manish Jethani
2017/05/31 02:51:43
We can talk about this. As I said earlier, I don't
Sebastian Noack
2017/05/31 07:09:26
A pattern of "http://example.com" should match any
Manish Jethani
2017/05/31 07:22:46
I see what you mean. In that case we should check
Sebastian Noack
2017/05/31 08:05:46
How about this:
* If the filter neither starts wi
Manish Jethani
2017/06/02 08:02:36
These rules are both complicated and wrong. For ex
Sebastian Noack
2017/06/02 10:58:50
Note that "raw" is for all requests initiated by c
Manish Jethani
2017/07/03 18:34:52
Makes sense, done.
| |
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", | 98 "resource-type": ["image", "style-sheet", "script", "font", |
99 "media", "raw", "document"]}, | 99 "media", "raw", "document"]}, |
100 action: {type: "block"}} | 100 action: {type: "block"}} |
101 ]); | 101 ]); |
102 | 102 |
103 testRules(test, ["||example.com"], [ | 103 testRules(test, ["||example.com"], [ |
104 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", | 104 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", |
105 "url-filter-is-case-sensitive": true, | 105 "url-filter-is-case-sensitive": true, |
106 "resource-type": ["image", "style-sheet", "script", "font", | 106 "resource-type": ["image", "style-sheet", "script", "font", |
107 "media", "raw", "document"]}, | 107 "media", "raw", "document"]}, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 | 207 |
208 test.done(); | 208 test.done(); |
209 }, | 209 }, |
210 | 210 |
211 testRequestTypeMapping: function(test) | 211 testRequestTypeMapping: function(test) |
212 { | 212 { |
213 testRules( | 213 testRules( |
214 test, | 214 test, |
215 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", | 215 ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", |
216 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", | 216 "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", |
217 "11$ping", "12$subdocument", "13$other", "14$IMAGE", | 217 "11$websocket", "12$webrtc", |
218 "15$script,PING,Popup", "16$~image"], | 218 "13$ping", "14$subdocument", "15$other", "16$IMAGE", |
219 "17$script,PING,Popup", "18$~image"], | |
219 [["image", "style-sheet", "script", "font", "media", "raw", "document" ], | 220 [["image", "style-sheet", "script", "font", "media", "raw", "document" ], |
220 ["image"], | 221 ["image"], |
221 ["style-sheet"], | 222 ["style-sheet"], |
222 ["script"], | 223 ["script"], |
223 ["font"], | 224 ["font"], |
224 ["media"], | 225 ["media"], |
225 ["popup"], | 226 ["popup"], |
226 ["media"], | 227 ["media"], |
227 ["raw"], | 228 ["raw"], |
228 ["raw"], | 229 ["raw"], |
230 ["raw"], // WebSocket | |
231 ["raw"], // WebRTC: STUN | |
232 ["raw"], // WebRTC: TURN | |
229 ["raw"], | 233 ["raw"], |
230 ["document"], | 234 ["document"], |
231 ["raw"], | 235 ["raw"], |
232 ["image"], | 236 ["image"], |
233 ["script", "popup", "raw" ], | 237 ["script", "popup", "raw" ], |
234 ["style-sheet", "script", "font", "media", "raw", "document"]], | 238 ["style-sheet", "script", "font", "media", "raw", "document"]], |
235 rules => rules.map(rule => rule.trigger["resource-type"]) | 239 rules => rules.map(rule => rule.trigger["resource-type"]) |
236 ); | 240 ); |
237 | 241 |
238 test.done(); | 242 test.done(); |
(...skipping 28 matching lines...) Expand all Loading... | |
267 }, | 271 }, |
268 | 272 |
269 testUnicode: function(test) | 273 testUnicode: function(test) |
270 { | 274 { |
271 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], | 275 testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], |
272 rules => rules[0]["trigger"]["if-domain"]); | 276 rules => rules[0]["trigger"]["if-domain"]); |
273 testRules(test, ["🐈$domain=🐈.cat"], []); | 277 testRules(test, ["🐈$domain=🐈.cat"], []); |
274 testRules(test, ["###🐈"], []); | 278 testRules(test, ["###🐈"], []); |
275 | 279 |
276 test.done(); | 280 test.done(); |
281 }, | |
282 | |
283 testWebSocket: function(test) | |
284 { | |
285 testRules(test, ["foo$websocket"], [ | |
286 {trigger: {"url-filter": "^wss?://.*foo", "resource-type": ["raw"]}, | |
287 action: {type: "block"}} | |
288 ]); | |
289 | |
290 test.done(); | |
291 }, | |
292 | |
293 testWebRTC: function(test) | |
294 { | |
295 testRules(test, ["foo$webrtc"], [ | |
296 {trigger: {"url-filter": "^stuns?:.*foo", "resource-type": ["raw"]}, | |
297 action: {type: "block"}}, | |
298 {trigger: {"url-filter": "^turns?:.*foo", "resource-type": ["raw"]}, | |
299 action: {type: "block"}} | |
300 ]); | |
301 | |
302 test.done(); | |
277 } | 303 } |
278 }; | 304 }; |
OLD | NEW |