| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 let {createSandbox} = require("./_common"); | 20 const {createSandbox} = require("./_common"); |
| 21 | 21 |
| 22 let Filter = null; | 22 let Filter = null; |
| 23 let InvalidFilter = null; | 23 let InvalidFilter = null; |
| 24 let CommentFilter = null; | 24 let CommentFilter = null; |
| 25 let ActiveFilter = null; | 25 let ActiveFilter = null; |
| 26 let RegExpFilter = null; | 26 let RegExpFilter = null; |
| 27 let BlockingFilter = null; | 27 let BlockingFilter = null; |
| 28 let WhitelistFilter = null; | 28 let WhitelistFilter = null; |
| 29 let ElemHideBase = null; | 29 let ElemHideBase = null; |
| 30 let ElemHideFilter = null; | 30 let ElemHideFilter = null; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 54 { | 54 { |
| 55 // Filter serialization only writes out essential properties, need to do a ful
l serialization here | 55 // Filter serialization only writes out essential properties, need to do a ful
l serialization here |
| 56 let result = []; | 56 let result = []; |
| 57 result.push("text=" + filter.text); | 57 result.push("text=" + filter.text); |
| 58 if (filter instanceof InvalidFilter) | 58 if (filter instanceof InvalidFilter) |
| 59 { | 59 { |
| 60 result.push("type=invalid"); | 60 result.push("type=invalid"); |
| 61 result.push("reason=" + filter.reason); | 61 result.push("reason=" + filter.reason); |
| 62 } | 62 } |
| 63 else if (filter instanceof CommentFilter) | 63 else if (filter instanceof CommentFilter) |
| 64 { | |
| 65 result.push("type=comment"); | 64 result.push("type=comment"); |
| 66 } | |
| 67 else if (filter instanceof ActiveFilter) | 65 else if (filter instanceof ActiveFilter) |
| 68 { | 66 { |
| 69 result.push("disabled=" + filter.disabled); | 67 result.push("disabled=" + filter.disabled); |
| 70 result.push("lastHit=" + filter.lastHit); | 68 result.push("lastHit=" + filter.lastHit); |
| 71 result.push("hitCount=" + filter.hitCount); | 69 result.push("hitCount=" + filter.hitCount); |
| 72 | 70 |
| 73 let domains = []; | 71 let domains = []; |
| 74 if (filter.domains) | 72 if (filter.domains) |
| 75 { | 73 { |
| 76 for (let domain in filter.domains) | 74 for (let domain in filter.domains) |
| 75 { |
| 77 if (domain != "") | 76 if (domain != "") |
| 78 domains.push(filter.domains[domain] ? domain : "~" + domain); | 77 domains.push(filter.domains[domain] ? domain : "~" + domain); |
| 78 } |
| 79 } | 79 } |
| 80 result.push("domains=" + domains.sort().join("|")); | 80 result.push("domains=" + domains.sort().join("|")); |
| 81 | 81 |
| 82 if (filter instanceof RegExpFilter) | 82 if (filter instanceof RegExpFilter) |
| 83 { | 83 { |
| 84 result.push("regexp=" + filter.regexp.source); | 84 result.push("regexp=" + filter.regexp.source); |
| 85 result.push("contentType=" + filter.contentType); | 85 result.push("contentType=" + filter.contentType); |
| 86 result.push("matchCase=" + filter.matchCase); | 86 result.push("matchCase=" + filter.matchCase); |
| 87 | 87 |
| 88 let sitekeys = filter.sitekeys || []; | 88 let sitekeys = filter.sitekeys || []; |
| 89 result.push("sitekeys=" + sitekeys.slice().sort().join("|")); | 89 result.push("sitekeys=" + sitekeys.slice().sort().join("|")); |
| 90 | 90 |
| 91 result.push("thirdParty=" + filter.thirdParty); | 91 result.push("thirdParty=" + filter.thirdParty); |
| 92 if (filter instanceof BlockingFilter) | 92 if (filter instanceof BlockingFilter) |
| 93 { | 93 { |
| 94 result.push("type=filterlist"); | 94 result.push("type=filterlist"); |
| 95 result.push("collapse=" + filter.collapse); | 95 result.push("collapse=" + filter.collapse); |
| 96 } | 96 } |
| 97 else if (filter instanceof WhitelistFilter) | 97 else if (filter instanceof WhitelistFilter) |
| 98 { | |
| 99 result.push("type=whitelist"); | 98 result.push("type=whitelist"); |
| 100 } | |
| 101 } | 99 } |
| 102 else if (filter instanceof ElemHideBase) | 100 else if (filter instanceof ElemHideBase) |
| 103 { | 101 { |
| 104 if (filter instanceof ElemHideFilter) | 102 if (filter instanceof ElemHideFilter) |
| 105 result.push("type=elemhide"); | 103 result.push("type=elemhide"); |
| 106 else if (filter instanceof ElemHideException) | 104 else if (filter instanceof ElemHideException) |
| 107 result.push("type=elemhideexception"); | 105 result.push("type=elemhideexception"); |
| 108 else if (filter instanceof ElemHideEmulationFilter) | 106 else if (filter instanceof ElemHideEmulationFilter) |
| 109 result.push("type=elemhideemulation"); | 107 result.push("type=elemhideemulation"); |
| 110 | 108 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE | | 144 RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE | |
| 147 RegExpFilter.typeMap.POPUP | RegExpFilter.typeMap.GENERICHIDE | | 145 RegExpFilter.typeMap.POPUP | RegExpFilter.typeMap.GENERICHIDE | |
| 148 RegExpFilter.typeMap.GENERICBLOCK | 146 RegExpFilter.typeMap.GENERICBLOCK |
| 149 )); | 147 )); |
| 150 addProperty("matchCase", "false"); | 148 addProperty("matchCase", "false"); |
| 151 addProperty("thirdParty", "null"); | 149 addProperty("thirdParty", "null"); |
| 152 addProperty("domains", ""); | 150 addProperty("domains", ""); |
| 153 addProperty("sitekeys", ""); | 151 addProperty("sitekeys", ""); |
| 154 } | 152 } |
| 155 if (type == "filterlist") | 153 if (type == "filterlist") |
| 156 { | |
| 157 addProperty("collapse", "null"); | 154 addProperty("collapse", "null"); |
| 158 } | |
| 159 if (type == "elemhide" || type == "elemhideexception" || | 155 if (type == "elemhide" || type == "elemhideexception" || |
| 160 type == "elemhideemulation") | 156 type == "elemhideemulation") |
| 161 { | 157 { |
| 162 addProperty("selectorDomain", ""); | 158 addProperty("selectorDomain", ""); |
| 163 addProperty("domains", ""); | 159 addProperty("domains", ""); |
| 164 } | 160 } |
| 165 } | 161 } |
| 166 | 162 |
| 167 function compareFilter(test, text, expected, postInit) | 163 function compareFilter(test, text, expected, postInit) |
| 168 { | 164 { |
| 169 addDefaults(expected); | 165 addDefaults(expected); |
| 170 | 166 |
| 171 let filter = Filter.fromText(text); | 167 let filter = Filter.fromText(text); |
| 172 if (postInit) | 168 if (postInit) |
| 173 postInit(filter) | 169 postInit(filter); |
| 174 let result = serializeFilter(filter); | 170 let result = serializeFilter(filter); |
| 175 test.equal(result.sort().join("\n"), expected.sort().join("\n"), text); | 171 test.equal(result.sort().join("\n"), expected.sort().join("\n"), text); |
| 176 | 172 |
| 177 // Test round-trip | 173 // Test round-trip |
| 178 let filter2; | 174 let filter2; |
| 179 let buffer = []; | 175 let buffer = []; |
| 180 filter.serialize(buffer); | 176 filter.serialize(buffer); |
| 181 if (buffer.length) | 177 if (buffer.length) |
| 182 { | 178 { |
| 183 let map = Object.create(null); | 179 let map = Object.create(null); |
| 184 for (let line of buffer.slice(1)) | 180 for (let line of buffer.slice(1)) |
| 185 { | 181 { |
| 186 if (/(.*?)=(.*)/.test(line)) | 182 if (/(.*?)=(.*)/.test(line)) |
| 187 map[RegExp.$1] = RegExp.$2; | 183 map[RegExp.$1] = RegExp.$2; |
| 188 } | 184 } |
| 189 filter2 = Filter.fromObject(map); | 185 filter2 = Filter.fromObject(map); |
| 190 } | 186 } |
| 191 else | 187 else |
| 192 { | |
| 193 filter2 = Filter.fromText(filter.text); | 188 filter2 = Filter.fromText(filter.text); |
| 194 } | |
| 195 | 189 |
| 196 test.equal(serializeFilter(filter).join("\n"), serializeFilter(filter2).join("
\n"), text + " deserialization"); | 190 test.equal(serializeFilter(filter).join("\n"), serializeFilter(filter2).join("
\n"), text + " deserialization"); |
| 197 } | 191 } |
| 198 | 192 |
| 199 exports.testFilterClassDefinitions = function(test) | 193 exports.testFilterClassDefinitions = function(test) |
| 200 { | 194 { |
| 201 test.equal(typeof Filter, "function", "typeof Filter"); | 195 test.equal(typeof Filter, "function", "typeof Filter"); |
| 202 test.equal(typeof InvalidFilter, "function", "typeof InvalidFilter"); | 196 test.equal(typeof InvalidFilter, "function", "typeof InvalidFilter"); |
| 203 test.equal(typeof CommentFilter, "function", "typeof CommentFilter"); | 197 test.equal(typeof CommentFilter, "function", "typeof CommentFilter"); |
| 204 test.equal(typeof ActiveFilter, "function", "typeof ActiveFilter"); | 198 test.equal(typeof ActiveFilter, "function", "typeof ActiveFilter"); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 226 exports.testInvalidFilters = function(test) | 220 exports.testInvalidFilters = function(test) |
| 227 { | 221 { |
| 228 compareFilter(test, "/??/", ["type=invalid", "text=/??/", "reason=filter_inval
id_regexp"]); | 222 compareFilter(test, "/??/", ["type=invalid", "text=/??/", "reason=filter_inval
id_regexp"]); |
| 229 compareFilter(test, "asd$foobar", ["type=invalid", "text=asd$foobar", "reason=
filter_unknown_option"]); | 223 compareFilter(test, "asd$foobar", ["type=invalid", "text=asd$foobar", "reason=
filter_unknown_option"]); |
| 230 compareFilter(test, "#dd(asd)(ddd)", ["type=invalid", "text=#dd(asd)(ddd)", "r
eason=filter_elemhide_duplicate_id"]); | 224 compareFilter(test, "#dd(asd)(ddd)", ["type=invalid", "text=#dd(asd)(ddd)", "r
eason=filter_elemhide_duplicate_id"]); |
| 231 compareFilter(test, "#*", ["type=invalid", "text=#*", "reason=filter_elemhide_
nocriteria"]); | 225 compareFilter(test, "#*", ["type=invalid", "text=#*", "reason=filter_elemhide_
nocriteria"]); |
| 232 | 226 |
| 233 function checkElemHideEmulationFilterInvalid(domains) | 227 function checkElemHideEmulationFilterInvalid(domains) |
| 234 { | 228 { |
| 235 let filterText = domains + "##[-abp-properties='abc']"; | 229 let filterText = domains + "##[-abp-properties='abc']"; |
| 236 compareFilter(test, filterText, | 230 compareFilter( |
| 237 ["type=invalid", "text=" + filterText, | 231 test, filterText, [ |
| 238 "reason=filter_elemhideemulation_nodomain"]); | 232 "type=invalid", "text=" + filterText, |
| 233 "reason=filter_elemhideemulation_nodomain" |
| 234 ] |
| 235 ); |
| 239 } | 236 } |
| 240 checkElemHideEmulationFilterInvalid(""); | 237 checkElemHideEmulationFilterInvalid(""); |
| 241 checkElemHideEmulationFilterInvalid("~foo.com"); | 238 checkElemHideEmulationFilterInvalid("~foo.com"); |
| 242 checkElemHideEmulationFilterInvalid("~foo.com,~bar.com"); | 239 checkElemHideEmulationFilterInvalid("~foo.com,~bar.com"); |
| 243 checkElemHideEmulationFilterInvalid("foo"); | 240 checkElemHideEmulationFilterInvalid("foo"); |
| 244 checkElemHideEmulationFilterInvalid("~foo.com,bar"); | 241 checkElemHideEmulationFilterInvalid("~foo.com,bar"); |
| 245 | 242 |
| 246 test.done(); | 243 test.done(); |
| 247 }; | 244 }; |
| 248 | 245 |
| 249 exports.testFiltersWithState = function(test) | 246 exports.testFiltersWithState = function(test) |
| 250 { | 247 { |
| 251 compareFilter(test, "blabla", ["type=filterlist", "text=blabla", "regexp=blabl
a"]); | 248 compareFilter(test, "blabla", ["type=filterlist", "text=blabla", "regexp=blabl
a"]); |
| 252 compareFilter(test, "blabla_default", ["type=filterlist", "text=blabla_default
", "regexp=blabla_default"], function(filter) | 249 compareFilter( |
| 253 { | 250 test, "blabla_default", ["type=filterlist", "text=blabla_default", "regexp=b
labla_default"], |
| 254 filter.disabled = false; | 251 filter => |
| 255 filter.hitCount = 0; | 252 { |
| 256 filter.lastHit = 0; | 253 filter.disabled = false; |
| 257 }); | 254 filter.hitCount = 0; |
| 258 compareFilter(test, "blabla_non_default", ["type=filterlist", "text=blabla_non
_default", "regexp=blabla_non_default", "disabled=true", "hitCount=12", "lastHit
=20"], function(filter) | 255 filter.lastHit = 0; |
| 259 { | 256 } |
| 260 filter.disabled = true; | 257 ); |
| 261 filter.hitCount = 12; | 258 compareFilter( |
| 262 filter.lastHit = 20; | 259 test, "blabla_non_default", |
| 263 }); | 260 ["type=filterlist", "text=blabla_non_default", "regexp=blabla_non_default",
"disabled=true", "hitCount=12", "lastHit=20"], |
| 261 filter => |
| 262 { |
| 263 filter.disabled = true; |
| 264 filter.hitCount = 12; |
| 265 filter.lastHit = 20; |
| 266 } |
| 267 ); |
| 264 | 268 |
| 265 test.done(); | 269 test.done(); |
| 266 }; | 270 }; |
| 267 | 271 |
| 268 exports.testSpecialCharacters = function(test) | 272 exports.testSpecialCharacters = function(test) |
| 269 { | 273 { |
| 270 compareFilter(test, "/ddd|f?a[s]d/", ["type=filterlist", "text=/ddd|f?a[s]d/",
"regexp=ddd|f?a[s]d"]); | 274 compareFilter(test, "/ddd|f?a[s]d/", ["type=filterlist", "text=/ddd|f?a[s]d/",
"regexp=ddd|f?a[s]d"]); |
| 271 compareFilter(test, "*asdf*d**dd*", ["type=filterlist", "text=*asdf*d**dd*", "
regexp=asdf.*d.*dd"]); | 275 compareFilter(test, "*asdf*d**dd*", ["type=filterlist", "text=*asdf*d**dd*", "
regexp=asdf.*d.*dd"]); |
| 272 compareFilter(test, "|*asd|f*d**dd*|", ["type=filterlist", "text=|*asd|f*d**dd
*|", "regexp=^.*asd\\|f.*d.*dd.*$"]); | 276 compareFilter(test, "|*asd|f*d**dd*|", ["type=filterlist", "text=|*asd|f*d**dd
*|", "regexp=^.*asd\\|f.*d.*dd.*$"]); |
| 273 compareFilter(test, "dd[]{}$%<>&()d", ["type=filterlist", "text=dd[]{}$%<>&()d
", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d"]); | 277 compareFilter(test, "dd[]{}$%<>&()d", ["type=filterlist", "text=dd[]{}$%<>&()d
", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d"]); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 288 | 292 |
| 289 // background and image should be the same for backwards compatibility | 293 // background and image should be the same for backwards compatibility |
| 290 compareFilter(test, "bla$image", ["type=filterlist", "text=bla$image", "regexp
=bla", "contentType=" + (t.IMAGE)]); | 294 compareFilter(test, "bla$image", ["type=filterlist", "text=bla$image", "regexp
=bla", "contentType=" + (t.IMAGE)]); |
| 291 compareFilter(test, "bla$background", ["type=filterlist", "text=bla$background
", "regexp=bla", "contentType=" + (t.IMAGE)]); | 295 compareFilter(test, "bla$background", ["type=filterlist", "text=bla$background
", "regexp=bla", "contentType=" + (t.IMAGE)]); |
| 292 compareFilter(test, "bla$~image", ["type=filterlist", "text=bla$~image", "rege
xp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); | 296 compareFilter(test, "bla$~image", ["type=filterlist", "text=bla$~image", "rege
xp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); |
| 293 compareFilter(test, "bla$~background", ["type=filterlist", "text=bla$~backgrou
nd", "regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); | 297 compareFilter(test, "bla$~background", ["type=filterlist", "text=bla$~backgrou
nd", "regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); |
| 294 | 298 |
| 295 compareFilter(test, "@@bla$~script,~other", ["type=whitelist", "text=@@bla$~sc
ript,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHE
R))]); | 299 compareFilter(test, "@@bla$~script,~other", ["type=whitelist", "text=@@bla$~sc
ript,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHE
R))]); |
| 296 compareFilter(test, "@@http://bla$~script,~other", ["type=whitelist", "text=@@
http://bla$~script,~other", "regexp=http\\:\\/\\/bla", "contentType=" + (default
Types & ~(t.SCRIPT | t.OTHER))]); | 300 compareFilter(test, "@@http://bla$~script,~other", ["type=whitelist", "text=@@
http://bla$~script,~other", "regexp=http\\:\\/\\/bla", "contentType=" + (default
Types & ~(t.SCRIPT | t.OTHER))]); |
| 297 compareFilter(test, "@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@
|ftp://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (default
Types & ~(t.SCRIPT | t.OTHER))]); | 301 compareFilter(test, "@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@
|ftp://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (default
Types & ~(t.SCRIPT | t.OTHER))]); |
| 298 compareFilter(test, "@@bla$~script,~other,document", ["type=whitelist", "text=
@@bla$~script,~other,document", "regexp=bla", "contentType=" + (defaultTypes &
~(t.SCRIPT | t.OTHER) | t.DOCUMENT)]); | 302 compareFilter(test, "@@bla$~script,~other,document", ["type=whitelist", "text=
@@bla$~script,~other,document", "regexp=bla", "contentType=" + (defaultTypes & ~
(t.SCRIPT | t.OTHER) | t.DOCUMENT)]); |
| 299 compareFilter(test, "@@bla$~script,~other,~document", ["type=whitelist", "text
=@@bla$~script,~other,~document", "regexp=bla", "contentType=" + (defaultTypes &
~(t.SCRIPT | t.OTHER))]); | 303 compareFilter(test, "@@bla$~script,~other,~document", ["type=whitelist", "text
=@@bla$~script,~other,~document", "regexp=bla", "contentType=" + (defaultTypes &
~(t.SCRIPT | t.OTHER))]); |
| 300 compareFilter(test, "@@bla$document", ["type=whitelist", "text=@@bla$document"
, "regexp=bla", "contentType=" + t.DOCUMENT]); | 304 compareFilter(test, "@@bla$document", ["type=whitelist", "text=@@bla$document"
, "regexp=bla", "contentType=" + t.DOCUMENT]); |
| 301 compareFilter(test, "@@bla$~script,~other,elemhide", ["type=whitelist", "text=
@@bla$~script,~other,elemhide", "regexp=bla", "contentType=" + (defaultTypes &
~(t.SCRIPT | t.OTHER) | t.ELEMHIDE)]); | 305 compareFilter(test, "@@bla$~script,~other,elemhide", ["type=whitelist", "text=
@@bla$~script,~other,elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~
(t.SCRIPT | t.OTHER) | t.ELEMHIDE)]); |
| 302 compareFilter(test, "@@bla$~script,~other,~elemhide", ["type=whitelist", "text
=@@bla$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes &
~(t.SCRIPT | t.OTHER))]); | 306 compareFilter(test, "@@bla$~script,~other,~elemhide", ["type=whitelist", "text
=@@bla$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes &
~(t.SCRIPT | t.OTHER))]); |
| 303 compareFilter(test, "@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide"
, "regexp=bla", "contentType=" + t.ELEMHIDE]); | 307 compareFilter(test, "@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide"
, "regexp=bla", "contentType=" + t.ELEMHIDE]); |
| 304 | 308 |
| 305 compareFilter(test, "@@bla$~script,~other,donottrack", ["type=invalid", "text=
@@bla$~script,~other,donottrack", "reason=filter_unknown_option"]); | 309 compareFilter(test, "@@bla$~script,~other,donottrack", ["type=invalid", "text=
@@bla$~script,~other,donottrack", "reason=filter_unknown_option"]); |
| 306 compareFilter(test, "@@bla$~script,~other,~donottrack", ["type=invalid", "text
=@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]); | 310 compareFilter(test, "@@bla$~script,~other,~donottrack", ["type=invalid", "text
=@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]); |
| 307 compareFilter(test, "@@bla$donottrack", ["type=invalid", "text=@@bla$donottrac
k", "reason=filter_unknown_option"]); | 311 compareFilter(test, "@@bla$donottrack", ["type=invalid", "text=@@bla$donottrac
k", "reason=filter_unknown_option"]); |
| 308 compareFilter(test, "@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "rea
son=filter_unknown_option"]); | 312 compareFilter(test, "@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "rea
son=filter_unknown_option"]); |
| 309 compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,f
oobar", "reason=filter_unknown_option"]); | 313 compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,f
oobar", "reason=filter_unknown_option"]); |
| 310 compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar,
image", "reason=filter_unknown_option"]); | 314 compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar,
image", "reason=filter_unknown_option"]); |
| 311 | 315 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 let filter = Filter.fromText(filterText); | 379 let filter = Filter.fromText(filterText); |
| 376 test.ok(filter instanceof InvalidFilter); | 380 test.ok(filter instanceof InvalidFilter); |
| 377 test.equal(filter.reason, "filter_invalid_domain"); | 381 test.equal(filter.reason, "filter_invalid_domain"); |
| 378 } | 382 } |
| 379 | 383 |
| 380 test.done(); | 384 test.done(); |
| 381 }; | 385 }; |
| 382 | 386 |
| 383 exports.testElemHideRulesWithBraces = function(test) | 387 exports.testElemHideRulesWithBraces = function(test) |
| 384 { | 388 { |
| 385 compareFilter(test, "###foo{color: red}", | 389 compareFilter( |
| 386 ["type=elemhide", | 390 test, "###foo{color: red}", [ |
| 387 "text=###foo{color: red}", | 391 "type=elemhide", |
| 388 "selectorDomain=", | 392 "text=###foo{color: red}", |
| 389 "selector=#foo\\x7B color: red\\x7D ", | 393 "selectorDomain=", |
| 390 "domains="]); | 394 "selector=#foo\\x7B color: red\\x7D ", |
| 391 compareFilter(test, "foo.com##[-abp-properties='/margin: [3-4]{2}/']", | 395 "domains=" |
| 392 ["type=elemhideemulation", | 396 ] |
| 393 "text=foo.com##[-abp-properties='/margin: [3-4]{2}/']", | 397 ); |
| 394 "selectorDomain=foo.com", | 398 compareFilter( |
| 395 "selector=[-abp-properties='/margin: [3-4]\\x7B 2\\x7D /']", | 399 test, "foo.com##[-abp-properties='/margin: [3-4]{2}/']", [ |
| 396 "domains=FOO.COM"]); | 400 "type=elemhideemulation", |
| 401 "text=foo.com##[-abp-properties='/margin: [3-4]{2}/']", |
| 402 "selectorDomain=foo.com", |
| 403 "selector=[-abp-properties='/margin: [3-4]\\x7B 2\\x7D /']", |
| 404 "domains=FOO.COM" |
| 405 ] |
| 406 ); |
| 397 test.done(); | 407 test.done(); |
| 398 }; | 408 }; |
| OLD | NEW |