LEFT | RIGHT |
1 (function() | 1 (function() |
2 { | 2 { |
3 module("Filter classes", {setup: prepareFilterComponents, teardown: restoreFil
terComponents}); | 3 module("Filter classes", {setup: prepareFilterComponents, teardown: restoreFil
terComponents}); |
4 | 4 |
5 function serializeFilter(filter) | 5 function serializeFilter(filter) |
6 { | 6 { |
7 // Filter serialization only writes out essential properties, need to do a f
ull serialization here | 7 // Filter serialization only writes out essential properties, need to do a f
ull serialization here |
8 let result = []; | 8 let result = []; |
9 result.push("text=" + filter.text); | 9 result.push("text=" + filter.text); |
10 if (filter instanceof InvalidFilter) | 10 if (filter instanceof InvalidFilter) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 if (type == "whitelist" || type == "filterlist" || type == "elemhide" || typ
e == "elemhideexception") | 87 if (type == "whitelist" || type == "filterlist" || type == "elemhide" || typ
e == "elemhideexception") |
88 { | 88 { |
89 addProperty("disabled", "false"); | 89 addProperty("disabled", "false"); |
90 addProperty("lastHit", "0"); | 90 addProperty("lastHit", "0"); |
91 addProperty("hitCount", "0"); | 91 addProperty("hitCount", "0"); |
92 } | 92 } |
93 if (type == "whitelist" || type == "filterlist") | 93 if (type == "whitelist" || type == "filterlist") |
94 { | 94 { |
95 addProperty("contentType", 0x7FFFFFFF & ~(RegExpFilter.typeMap.ELEMHIDE |
RegExpFilter.typeMap.POPUP | | 95 addProperty("contentType", 0x7FFFFFFF & ~( |
96 RegExpFilter.typeMap.GENERICHIDE
| RegExpFilter.typeMap.GENERICBLOCK)); | 96 RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE | |
| 97 RegExpFilter.typeMap.POPUP | RegExpFilter.typeMap.GENERICHIDE | |
| 98 RegExpFilter.typeMap.GENERICBLOCK |
| 99 )); |
97 addProperty("matchCase", "false"); | 100 addProperty("matchCase", "false"); |
98 addProperty("thirdParty", "null"); | 101 addProperty("thirdParty", "null"); |
99 addProperty("domains", ""); | 102 addProperty("domains", ""); |
100 addProperty("sitekeys", ""); | 103 addProperty("sitekeys", ""); |
101 } | 104 } |
102 if (type == "filterlist") | 105 if (type == "filterlist") |
103 { | 106 { |
104 addProperty("collapse", "null"); | 107 addProperty("collapse", "null"); |
105 } | 108 } |
106 if (type == "elemhide" || type == "elemhideexception") | 109 if (type == "elemhide" || type == "elemhideexception") |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 212 |
210 compareFilter("@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d/",
"regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]); | 213 compareFilter("@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d/",
"regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]); |
211 compareFilter("@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*", "r
egexp=asdf.*d.*dd", "contentType=" + defaultTypes]); | 214 compareFilter("@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*", "r
egexp=asdf.*d.*dd", "contentType=" + defaultTypes]); |
212 compareFilter("@@|*asd|f*d**dd*|", ["type=whitelist", "text=@@|*asd|f*d**dd*
|", "regexp=^.*asd\\|f.*d.*dd.*$", "contentType=" + defaultTypes]); | 215 compareFilter("@@|*asd|f*d**dd*|", ["type=whitelist", "text=@@|*asd|f*d**dd*
|", "regexp=^.*asd\\|f.*d.*dd.*$", "contentType=" + defaultTypes]); |
213 compareFilter("@@dd[]{}$%<>&()d", ["type=whitelist", "text=@@dd[]{}$%<>&()d"
, "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d", "contentType=" + defaultTypes])
; | 216 compareFilter("@@dd[]{}$%<>&()d", ["type=whitelist", "text=@@dd[]{}$%<>&()d"
, "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d", "contentType=" + defaultTypes])
; |
214 }); | 217 }); |
215 | 218 |
216 test("Filter options", function() | 219 test("Filter options", function() |
217 { | 220 { |
218 compareFilter("bla$match-case,script,other,third-party,domain=foo.com,siteke
y=foo", ["type=filterlist", "text=bla$match-case,script,other,third-party,domain
=foo.com,sitekey=foo", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIP
T | t.OTHER), "thirdParty=true", "domains=FOO.COM", "sitekeys=FOO"]); | 221 compareFilter("bla$match-case,script,other,third-party,domain=foo.com,siteke
y=foo", ["type=filterlist", "text=bla$match-case,script,other,third-party,domain
=foo.com,sitekey=foo", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIP
T | t.OTHER), "thirdParty=true", "domains=FOO.COM", "sitekeys=FOO"]); |
219 compareFilter("bla$~match-case,~script,~other,~third-party,domain=~bar.com",
["type=filterlist", "text=bla$~match-case,~script,~other,~third-party,domain=~b
ar.com", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER) |
t.DOCUMENT), "thirdParty=false", "domains=~BAR.COM"]); | 222 compareFilter("bla$~match-case,~script,~other,~third-party,domain=~bar.com",
["type=filterlist", "text=bla$~match-case,~script,~other,~third-party,domain=~b
ar.com", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER)),
"thirdParty=false", "domains=~BAR.COM"]); |
220 compareFilter("@@bla$match-case,script,other,third-party,domain=foo.com|bar.
com|~bar.foo.com|~foo.bar.com,sitekey=foo|bar", ["type=whitelist", "text=@@bla$m
atch-case,script,other,third-party,domain=foo.com|bar.com|~bar.foo.com|~foo.bar.
com,sitekey=foo|bar", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIPT
| t.OTHER), "thirdParty=true", "domains=BAR.COM|FOO.COM|~BAR.FOO.COM|~FOO.BAR.C
OM", "sitekeys=BAR|FOO"]); | 223 compareFilter("@@bla$match-case,script,other,third-party,domain=foo.com|bar.
com|~bar.foo.com|~foo.bar.com,sitekey=foo|bar", ["type=whitelist", "text=@@bla$m
atch-case,script,other,third-party,domain=foo.com|bar.com|~bar.foo.com|~foo.bar.
com,sitekey=foo|bar", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIPT
| t.OTHER), "thirdParty=true", "domains=BAR.COM|FOO.COM|~BAR.FOO.COM|~FOO.BAR.C
OM", "sitekeys=BAR|FOO"]); |
221 | 224 |
222 // background and image should be the same for backwards compatibility | 225 // background and image should be the same for backwards compatibility |
223 compareFilter("bla$image", ["type=filterlist", "text=bla$image", "regexp=bla
", "contentType=" + (t.IMAGE)]); | 226 compareFilter("bla$image", ["type=filterlist", "text=bla$image", "regexp=bla
", "contentType=" + (t.IMAGE)]); |
224 compareFilter("bla$background", ["type=filterlist", "text=bla$background", "
regexp=bla", "contentType=" + (t.IMAGE)]); | 227 compareFilter("bla$background", ["type=filterlist", "text=bla$background", "
regexp=bla", "contentType=" + (t.IMAGE)]); |
225 compareFilter("bla$~image", ["type=filterlist", "text=bla$~image", "regexp=b
la", "contentType=" + (defaultTypes & ~t.IMAGE | t.DOCUMENT)]); | 228 compareFilter("bla$~image", ["type=filterlist", "text=bla$~image", "regexp=b
la", "contentType=" + (defaultTypes & ~t.IMAGE)]); |
226 compareFilter("bla$~background", ["type=filterlist", "text=bla$~background",
"regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE | t.DOCUMENT)]); | 229 compareFilter("bla$~background", ["type=filterlist", "text=bla$~background",
"regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); |
227 | 230 |
228 compareFilter("@@bla$~script,~other", ["type=whitelist", "text=@@bla$~script
,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]
); | 231 compareFilter("@@bla$~script,~other", ["type=whitelist", "text=@@bla$~script
,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]
); |
229 compareFilter("@@http://bla$~script,~other", ["type=whitelist", "text=@@http
://bla$~script,~other", "regexp=http\\:\\/\\/bla", "contentType=" + (defaultType
s & ~(t.SCRIPT | t.OTHER) | t.DOCUMENT)]); | 232 compareFilter("@@http://bla$~script,~other", ["type=whitelist", "text=@@http
://bla$~script,~other", "regexp=http\\:\\/\\/bla", "contentType=" + (defaultType
s & ~(t.SCRIPT | t.OTHER))]); |
230 compareFilter("@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@|ftp
://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (defaultType
s & ~(t.SCRIPT | t.OTHER) | t.DOCUMENT)]); | 233 compareFilter("@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@|ftp
://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (defaultType
s & ~(t.SCRIPT | t.OTHER))]); |
231 compareFilter("@@bla$~script,~other,document", ["type=whitelist", "text=@@bl
a$~script,~other,document", "regexp=bla", "contentType=" + (defaultTypes & ~(t.
SCRIPT | t.OTHER) | t.DOCUMENT)]); | 234 compareFilter("@@bla$~script,~other,document", ["type=whitelist", "text=@@bl
a$~script,~other,document", "regexp=bla", "contentType=" + (defaultTypes & ~(t.
SCRIPT | t.OTHER) | t.DOCUMENT)]); |
232 compareFilter("@@bla$~script,~other,~document", ["type=whitelist", "text=@@b
la$~script,~other,~document", "regexp=bla", "contentType=" + (defaultTypes & ~(t
.SCRIPT | t.OTHER))]); | 235 compareFilter("@@bla$~script,~other,~document", ["type=whitelist", "text=@@b
la$~script,~other,~document", "regexp=bla", "contentType=" + (defaultTypes & ~(t
.SCRIPT | t.OTHER))]); |
233 compareFilter("@@bla$document", ["type=whitelist", "text=@@bla$document", "r
egexp=bla", "contentType=" + t.DOCUMENT]); | 236 compareFilter("@@bla$document", ["type=whitelist", "text=@@bla$document", "r
egexp=bla", "contentType=" + t.DOCUMENT]); |
234 compareFilter("@@bla$~script,~other,elemhide", ["type=whitelist", "text=@@bl
a$~script,~other,elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t.
SCRIPT | t.OTHER) | t.ELEMHIDE)]); | 237 compareFilter("@@bla$~script,~other,elemhide", ["type=whitelist", "text=@@bl
a$~script,~other,elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t.
SCRIPT | t.OTHER) | t.ELEMHIDE)]); |
235 compareFilter("@@bla$~script,~other,~elemhide", ["type=whitelist", "text=@@b
la$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t
.SCRIPT | t.OTHER))]); | 238 compareFilter("@@bla$~script,~other,~elemhide", ["type=whitelist", "text=@@b
la$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t
.SCRIPT | t.OTHER))]); |
236 compareFilter("@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide", "r
egexp=bla", "contentType=" + t.ELEMHIDE]); | 239 compareFilter("@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide", "r
egexp=bla", "contentType=" + t.ELEMHIDE]); |
237 | 240 |
238 compareFilter("@@bla$~script,~other,donottrack", ["type=invalid", "text=@@bl
a$~script,~other,donottrack", "hasReason"]); | 241 compareFilter("@@bla$~script,~other,donottrack", ["type=invalid", "text=@@bl
a$~script,~other,donottrack", "hasReason"]); |
239 compareFilter("@@bla$~script,~other,~donottrack", ["type=invalid", "text=@@b
la$~script,~other,~donottrack", "hasReason"]); | 242 compareFilter("@@bla$~script,~other,~donottrack", ["type=invalid", "text=@@b
la$~script,~other,~donottrack", "hasReason"]); |
240 compareFilter("@@bla$donottrack", ["type=invalid", "text=@@bla$donottrack",
"hasReason"]); | 243 compareFilter("@@bla$donottrack", ["type=invalid", "text=@@bla$donottrack",
"hasReason"]); |
(...skipping 25 matching lines...) Expand all Loading... |
266 compareFilter("#@ddd(fff)(foo=bar)", ["type=elemhideexception", "text=#@ddd(
fff)(foo=bar)", 'selector=ddd.fff[foo="bar"],ddd#fff[foo="bar"]']); | 269 compareFilter("#@ddd(fff)(foo=bar)", ["type=elemhideexception", "text=#@ddd(
fff)(foo=bar)", 'selector=ddd.fff[foo="bar"],ddd#fff[foo="bar"]']); |
267 compareFilter("#@*(fff)", ["type=elemhideexception", "text=#@*(fff)", "selec
tor=.fff,#fff"]); | 270 compareFilter("#@*(fff)", ["type=elemhideexception", "text=#@*(fff)", "selec
tor=.fff,#fff"]); |
268 compareFilter("#@*(foo=bar)", ["type=elemhideexception", "text=#@*(foo=bar)"
, 'selector=[foo="bar"]']); | 271 compareFilter("#@*(foo=bar)", ["type=elemhideexception", "text=#@*(foo=bar)"
, 'selector=[foo="bar"]']); |
269 compareFilter("#@#body > div:first-child", ["type=elemhideexception", "text=
#@#body > div:first-child", "selector=body > div:first-child"]); | 272 compareFilter("#@#body > div:first-child", ["type=elemhideexception", "text=
#@#body > div:first-child", "selector=body > div:first-child"]); |
270 compareFilter("foo#@ddd", ["type=elemhideexception", "text=foo#@ddd", "selec
torDomain=foo", "selector=ddd", "domains=FOO"]); | 273 compareFilter("foo#@ddd", ["type=elemhideexception", "text=foo#@ddd", "selec
torDomain=foo", "selector=ddd", "domains=FOO"]); |
271 compareFilter("foo,bar#@ddd", ["type=elemhideexception", "text=foo,bar#@ddd"
, "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO"]); | 274 compareFilter("foo,bar#@ddd", ["type=elemhideexception", "text=foo,bar#@ddd"
, "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO"]); |
272 compareFilter("foo,~bar#@ddd", ["type=elemhideexception", "text=foo,~bar#@dd
d", "selectorDomain=foo", "selector=ddd", "domains=FOO|~BAR"]); | 275 compareFilter("foo,~bar#@ddd", ["type=elemhideexception", "text=foo,~bar#@dd
d", "selectorDomain=foo", "selector=ddd", "domains=FOO|~BAR"]); |
273 compareFilter("foo,~baz,bar#@ddd", ["type=elemhideexception", "text=foo,~baz
,bar#@ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ"]); | 276 compareFilter("foo,~baz,bar#@ddd", ["type=elemhideexception", "text=foo,~baz
,bar#@ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ"]); |
274 }); | 277 }); |
275 })(); | 278 })(); |
LEFT | RIGHT |