| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // should be hidden for all domains not ending in test.com instead of | 74 // should be hidden for all domains not ending in test.com instead of |
| 75 // nowhere! | 75 // nowhere! |
| 76 testRules(test, ["test.com#@#whatever", "##whatever"], []); | 76 testRules(test, ["test.com#@#whatever", "##whatever"], []); |
| 77 testRules(test, ["~test.com##whatever"], []); | 77 testRules(test, ["~test.com##whatever"], []); |
| 78 | 78 |
| 79 test.done(); | 79 test.done(); |
| 80 }, | 80 }, |
| 81 | 81 |
| 82 testRequestFilters: function(test) | 82 testRequestFilters: function(test) |
| 83 { | 83 { |
| 84 testRules(test, ["/foo", "||test.com", "http://example.com/foo"], [ | 84 testRules(test, [ |
| 85 {trigger: {"url-filter": "^https?://.*/foo", | 85 "/foo", "||test.com^", "http://example.com/foo", "^foo^" |
| 86 "resource-type": ["image", "style-sheet", "script", "font", | 86 ], [ |
| 87 "media", "raw"]}, | 87 { |
| 88 action: {type: "block"}}, | 88 trigger: { |
| 89 {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com", | 89 "url-filter": "^https?://.*/foo", |
| 90 "url-filter-is-case-sensitive": true, | 90 "resource-type": ["image", "style-sheet", "script", "font", |
| 91 "resource-type": ["image", "style-sheet", "script", "font", | 91 "media", "raw"] |
| 92 "media", "raw", "document"], | 92 }, |
| 93 "unless-top-url": ["^https?://([^/]+\\.)?test\\.com"], | 93 action: {type: "block"} |
| 94 "top-url-filter-is-case-sensitive": true}, | 94 }, |
| 95 action: {type: "block"}}, | 95 { |
| 96 {trigger: {"url-filter": "http://example\\.com/foo", | 96 trigger: { |
| 97 "resource-type": ["image", "style-sheet", "script", "font", | 97 "url-filter": "^https?://([^/]+\\.)?test\\.com([^-_.%a-z0-9].*)?$", |
| 98 "media", "raw", "document"], | 98 "url-filter-is-case-sensitive": true, |
| 99 "unless-top-url": ["http://example\\.com/foo"]}, | 99 "resource-type": ["image", "style-sheet", "script", "font", |
| 100 action: {type: "block"}} | 100 "media", "raw", "document"], |
| 101 "unless-top-url": [ |
| 102 "^https?://([^/]+\\.)?test\\.com([^-_.%a-z0-9].*)?$" |
| 103 ], |
| 104 "top-url-filter-is-case-sensitive": true |
| 105 }, |
| 106 action: {type: "block"} |
| 107 }, |
| 108 { |
| 109 trigger: { |
| 110 "url-filter": "http://example\\.com/foo", |
| 111 "resource-type": ["image", "style-sheet", "script", "font", |
| 112 "media", "raw", "document"], |
| 113 "unless-top-url": ["http://example\\.com/foo"] |
| 114 }, |
| 115 action: {type: "block"} |
| 116 }, |
| 117 { |
| 118 trigger: { |
| 119 "url-filter": |
| 120 "^https?://(.*[^-_.%A-Za-z0-9])?foo([^-_.%A-Za-z0-9].*)?$", |
| 121 "resource-type": ["image", "style-sheet", "script", "font", |
| 122 "media", "raw"] |
| 123 }, |
| 124 action: {type: "block"} |
| 125 } |
| 101 ]); | 126 ]); |
| 102 | 127 |
| 103 testRules(test, ["||example.com"], [ | 128 testRules(test, ["||example.com"], [ |
| 104 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", | 129 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", |
| 105 "url-filter-is-case-sensitive": true, | 130 "url-filter-is-case-sensitive": true, |
| 106 "resource-type": ["image", "style-sheet", "script", "font", | 131 "resource-type": ["image", "style-sheet", "script", "font", |
| 107 "media", "raw", "document"], | 132 "media", "raw", "document"], |
| 108 "unless-top-url": ["^https?://([^/]+\\.)?example\\.com"], | 133 "unless-top-url": ["^https?://([^/]+\\.)?example\\.com"], |
| 109 "top-url-filter-is-case-sensitive": true}, | 134 "top-url-filter-is-case-sensitive": true}, |
| 110 | 135 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 ["###example", "test.com###EXAMPLE"], | 168 ["###example", "test.com###EXAMPLE"], |
| 144 ["[id=example]", "[id=EXAMPLE]"], | 169 ["[id=example]", "[id=EXAMPLE]"], |
| 145 rules => rules.map(rule => rule.action.selector)); | 170 rules => rules.map(rule => rule.action.selector)); |
| 146 | 171 |
| 147 test.done(); | 172 test.done(); |
| 148 }, | 173 }, |
| 149 | 174 |
| 150 testDomainWhitelisting: function(test) | 175 testDomainWhitelisting: function(test) |
| 151 { | 176 { |
| 152 testRules(test, ["@@||example.com^$document"], [ | 177 testRules(test, ["@@||example.com^$document"], [ |
| 153 {trigger: {"url-filter": ".*", | 178 { |
| 154 "if-domain": ["*example.com"]}, | 179 trigger: { |
| 155 action: {type: "ignore-previous-rules"}} | 180 "url-filter": ".*", |
| 181 "if-domain": ["*example.com"] |
| 182 }, |
| 183 action: {type: "ignore-previous-rules"} |
| 184 } |
| 156 ]); | 185 ]); |
| 157 testRules(test, ["@@||example.com^$document,image"], [ | 186 testRules(test, ["@@||example.com^$document,image"], [ |
| 158 {trigger: {"url-filter": ".*", | 187 { |
| 159 "if-domain": ["*example.com"]}, | 188 trigger: { |
| 160 action: {type: "ignore-previous-rules"}}, | 189 "url-filter": ".*", |
| 161 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com", | 190 "if-domain": ["*example.com"] |
| 162 "url-filter-is-case-sensitive": true, | 191 }, |
| 163 "resource-type": ["image"]}, | 192 action: {type: "ignore-previous-rules"} |
| 164 action: {type: "ignore-previous-rules"}} | 193 }, |
| 194 { |
| 195 trigger: { |
| 196 "url-filter": "^https?://([^/]+\\.)?example\\.com([^-_.%a-z0-9].*)?$", |
| 197 "url-filter-is-case-sensitive": true, |
| 198 "resource-type": ["image"] |
| 199 }, |
| 200 action: {type: "ignore-previous-rules"} |
| 201 } |
| 165 ]); | 202 ]); |
| 166 testRules(test, ["@@||example.com/path^$font,document"], [ | 203 testRules(test, ["@@||example.com/path^$font,document"], [ |
| 167 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com/path", | 204 { |
| 168 "resource-type": ["font"]}, | 205 trigger: { |
| 169 action: {type: "ignore-previous-rules"}} | 206 "url-filter": |
| 207 "^https?://([^/]+\\.)?example\\.com/path([^-_.%A-Za-z0-9].*)?$", |
| 208 "resource-type": ["font"] |
| 209 }, |
| 210 action: {type: "ignore-previous-rules"} |
| 211 } |
| 170 ]); | 212 ]); |
| 171 | 213 |
| 172 test.done(); | 214 test.done(); |
| 173 }, | 215 }, |
| 174 | 216 |
| 175 testGenericblockExceptions: function(test) | 217 testGenericblockExceptions: function(test) |
| 176 { | 218 { |
| 177 testRules(test, ["^ad.jpg|", "@@||example.com^$genericblock"], | 219 testRules(test, ["^ad.jpg|", "@@||example.com^$genericblock"], |
| 178 [[undefined, ["*example.com"]]], | 220 [[undefined, ["*example.com"]]], |
| 179 rules => rules.map(rule => [rule.trigger["if-domain"], | 221 rules => rules.map(rule => [rule.trigger["if-domain"], |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 rules => rules[0]["trigger"]["url-filter"]); | 319 rules => rules[0]["trigger"]["url-filter"]); |
| 278 testRules(test, ["🐈%F0%9F%90%88$domain=🐈.cat"], | 320 testRules(test, ["🐈%F0%9F%90%88$domain=🐈.cat"], |
| 279 "^https?://.*%F0%9F%90%88%F0%9F%90%88", | 321 "^https?://.*%F0%9F%90%88%F0%9F%90%88", |
| 280 rules => rules[0]["trigger"]["url-filter"]); | 322 rules => rules[0]["trigger"]["url-filter"]); |
| 281 testRules(test, ["###🐈"], "[id=🐈]", | 323 testRules(test, ["###🐈"], "[id=🐈]", |
| 282 rules => rules[0]["action"]["selector"]); | 324 rules => rules[0]["action"]["selector"]); |
| 283 | 325 |
| 284 test.done(); | 326 test.done(); |
| 285 } | 327 } |
| 286 }; | 328 }; |
| OLD | NEW |