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