| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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"], [ | 
| 88       {trigger: {"url-filter": "^https?://.*/foo", | 88       {trigger: {"url-filter": "^[^:]+:(//)?.*/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                  "unless-top-url": ["^https?://.*/foo"]}, |  | 
| 92        action: {type: "block"}}, | 91        action: {type: "block"}}, | 
| 93       {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com", | 92       {trigger: {"url-filter": "^[^:]+:(//)?([^/]+\\.)?test\\.com", | 
| 94                  "url-filter-is-case-sensitive": true, | 93                  "url-filter-is-case-sensitive": true, | 
| 95                  "resource-type": ["image", "style-sheet", "script", "font", | 94                  "resource-type": ["image", "style-sheet", "script", "font", | 
| 96                                    "media", "raw", "document"], | 95                                    "media", "raw", "document"]}, | 
| 97                  "unless-top-url": ["^https?://([^/]+\\.)?test\\.com"], |  | 
| 98                  "top-url-filter-is-case-sensitive": true}, |  | 
| 99        action: {type: "block"}}, | 96        action: {type: "block"}}, | 
| 100       {trigger: {"url-filter": "http://example\\.com/foo", | 97       {trigger: {"url-filter": "^http://example\\.com/foo", | 
| 101                  "resource-type": ["image", "style-sheet", "script", "font", | 98                  "resource-type": ["image", "style-sheet", "script", "font", | 
| 102                                    "media", "raw", "document"], | 99                                    "media", "raw", "document"]}, | 
| 103                  "unless-top-url": ["http://example\\.com/foo"]}, | 100        action: {type: "block"}}, | 
|  | 101       {trigger: {"url-filter": "^[^:]+:(//)?.*http://example\\.com/foo", | 
|  | 102                  "resource-type": ["image", "style-sheet", "script", "font", | 
|  | 103                                    "media", "raw", "document"]}, | 
| 104        action: {type: "block"}} | 104        action: {type: "block"}} | 
| 105     ]); | 105     ]); | 
| 106 | 106 | 
| 107     testRules(test, ["||example.com"], [ | 107     testRules(test, ["||example.com"], [ | 
| 108       {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", | 108       {trigger: {"url-filter": "^[^:]+:(//)?([^/]+\\.)?example\\.com", | 
| 109                  "url-filter-is-case-sensitive": true, | 109                  "url-filter-is-case-sensitive": true, | 
| 110                  "resource-type": ["image", "style-sheet", "script", "font", | 110                  "resource-type": ["image", "style-sheet", "script", "font", | 
| 111                                    "media", "raw", "document"], | 111                                    "media", "raw", "document"]}, | 
| 112                  "unless-top-url": ["^https?://([^/]+\\.)?example\\.com"], |  | 
| 113                  "top-url-filter-is-case-sensitive": true}, |  | 
| 114 | 112 | 
| 115        action: {type: "block"}} | 113        action: {type: "block"}} | 
| 116     ]); | 114     ]); | 
| 117 | 115 | 
| 118     // Rules which would match no resource-types shouldn't be generated. | 116     // Rules which would match no resource-types shouldn't be generated. | 
| 119     testRules(test, ["foo$document", "||foo.com$document"], []); | 117     testRules(test, ["foo$document", "||foo.com$document"], []); | 
| 120 | 118 | 
| 121     test.done(); | 119     test.done(); | 
| 122   }, | 120   }, | 
| 123 | 121 | 
| 124   testRequestFilterExceptions: function(test) | 122   testRequestFilterExceptions: function(test) | 
| 125   { | 123   { | 
| 126     testRules(test, ["@@example.com"], [ | 124     testRules(test, ["@@example.com"], [ | 
| 127       {trigger: {"url-filter": "^https?://.*example\\.com", | 125       {trigger: {"url-filter": "^[^:]+:(//)?.*example\\.com", | 
| 128                  "resource-type": ["image", "style-sheet", "script", "font", | 126                  "resource-type": ["image", "style-sheet", "script", "font", | 
| 129                                    "media", "raw", "document"]}, | 127                                    "media", "raw", "document"]}, | 
| 130        action: {type: "ignore-previous-rules"}} | 128        action: {type: "ignore-previous-rules"}} | 
| 131     ]); | 129     ]); | 
| 132 | 130 | 
| 133     testRules(test, ["@@||example.com"], [ | 131     testRules(test, ["@@||example.com"], [ | 
| 134       {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", | 132       {trigger: {"url-filter": "^[^:]+:(//)?([^/]+\\.)?example\\.com", | 
| 135                  "url-filter-is-case-sensitive": true, | 133                  "url-filter-is-case-sensitive": true, | 
| 136                  "resource-type": ["image", "style-sheet", "script", "font", | 134                  "resource-type": ["image", "style-sheet", "script", "font", | 
| 137                                    "media", "raw", "document"]}, | 135                                    "media", "raw", "document"]}, | 
| 138        action: {type: "ignore-previous-rules"}} | 136        action: {type: "ignore-previous-rules"}} | 
| 139     ]); | 137     ]); | 
| 140 | 138 | 
| 141     test.done(); | 139     test.done(); | 
| 142   }, | 140   }, | 
| 143 | 141 | 
| 144   testElementIDattributeFormat: function(test) | 142   testElementIDattributeFormat: function(test) | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 213 | 211 | 
| 214     test.done(); | 212     test.done(); | 
| 215   }, | 213   }, | 
| 216 | 214 | 
| 217   testRequestTypeMapping: function(test) | 215   testRequestTypeMapping: function(test) | 
| 218   { | 216   { | 
| 219     testRules( | 217     testRules( | 
| 220       test, | 218       test, | 
| 221       ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", | 219       ["1", "2$image", "3$stylesheet", "4$script", "5$font", "6$media", | 
| 222        "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", | 220        "7$popup", "8$object", "9$object_subrequest", "10$xmlhttprequest", | 
| 223        "11$ping", "12$subdocument", "13$other", "14$IMAGE", | 221        "11$websocket", "12$webrtc", | 
| 224        "15$script,PING,Popup", "16$~image"], | 222        "13$ping", "14$subdocument", "15$other", "16$IMAGE", | 
|  | 223        "17$script,PING,Popup", "18$~image"], | 
| 225       [["image", "style-sheet", "script", "font", "media", "raw", "document" ], | 224       [["image", "style-sheet", "script", "font", "media", "raw", "document" ], | 
| 226        ["image"], | 225        ["image"], | 
| 227        ["style-sheet"], | 226        ["style-sheet"], | 
| 228        ["script"], | 227        ["script"], | 
| 229        ["font"], | 228        ["font"], | 
| 230        ["media"], | 229        ["media"], | 
| 231        ["popup"], | 230        ["popup"], | 
| 232        ["media"], | 231        ["media"], | 
| 233        ["raw"], | 232        ["raw"], | 
| 234        ["raw"], | 233        ["raw"], | 
|  | 234        ["raw"], // WebSocket | 
|  | 235        ["raw"], // WebRTC: STUN | 
|  | 236        ["raw"], // WebRTC: TURN | 
| 235        ["raw"], | 237        ["raw"], | 
| 236        ["document"], | 238        ["document"], | 
| 237        ["raw"], | 239        ["raw"], | 
| 238        ["image"], | 240        ["image"], | 
| 239        ["script", "popup", "raw" ], | 241        ["script", "popup", "raw" ], | 
| 240        ["style-sheet", "script", "font", "media", "raw", "document"]], | 242        ["style-sheet", "script", "font", "media", "raw", "document"]], | 
| 241       rules => rules.map(rule => rule.trigger["resource-type"]) | 243       rules => rules.map(rule => rule.trigger["resource-type"]) | 
| 242     ); | 244     ); | 
| 243 | 245 | 
| 244     test.done(); | 246     test.done(); | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 273   }, | 275   }, | 
| 274 | 276 | 
| 275   testUnicode: function(test) | 277   testUnicode: function(test) | 
| 276   { | 278   { | 
| 277     testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], | 279     testRules(test, ["$domain=🐈.cat"], ["*xn--zn8h.cat"], | 
| 278               rules => rules[0]["trigger"]["if-domain"]); | 280               rules => rules[0]["trigger"]["if-domain"]); | 
| 279     testRules(test, ["🐈$domain=🐈.cat"], []); | 281     testRules(test, ["🐈$domain=🐈.cat"], []); | 
| 280     testRules(test, ["###🐈"], []); | 282     testRules(test, ["###🐈"], []); | 
| 281 | 283 | 
| 282     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(); | 
| 283   } | 307   } | 
| 284 }; | 308 }; | 
| OLD | NEW | 
|---|