Left: | ||
Right: |
OLD | NEW |
---|---|
1 (function() | 1 (function() |
2 { | 2 { |
3 module("Filter matcher", {setup: prepareFilterComponents, teardown: restoreFil terComponents}); | 3 module("Filter matcher", {setup: prepareFilterComponents, teardown: restoreFil terComponents}); |
4 | 4 |
5 function compareKeywords(text, expected) | 5 function compareKeywords(text, expected) |
6 { | 6 { |
7 for (let filter of [Filter.fromText(text), Filter.fromText("@@" + text)]) | 7 for (let filter of [Filter.fromText(text), Filter.fromText("@@" + text)]) |
8 { | 8 { |
9 let matcher = new Matcher(); | 9 let matcher = new Matcher(); |
10 let result = []; | 10 let result = []; |
11 for (let dummy of expected) | 11 for (let dummy of expected) |
12 { | 12 { |
13 let keyword = matcher.findKeyword(filter); | 13 let keyword = matcher.findKeyword(filter); |
14 result.push(keyword); | 14 result.push(keyword); |
15 if (keyword) | 15 if (keyword) |
16 { | 16 { |
17 let dummyFilter = Filter.fromText('^' + keyword + '^'); | 17 let dummyFilter = Filter.fromText('^' + keyword + '^'); |
18 dummyFilter.filterCount = Infinity; | 18 dummyFilter.filterCount = Infinity; |
19 matcher.add(dummyFilter); | 19 matcher.add(dummyFilter); |
20 } | 20 } |
21 } | 21 } |
22 | 22 |
23 equal(result.join(", "), expected.join(", "), "Keyword candidates for " + filter.text); | 23 equal(result.join(", "), expected.join(", "), "Keyword candidates for " + filter.text); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 function checkMatch(filters, location, contentType, docDomain, thirdParty, sit ekey, expected) | 27 function checkMatch(filters, location, contentType, docDomain, thirdParty, sit ekey, specificOnly, expected) |
28 { | 28 { |
29 let matcher = new Matcher(); | 29 let matcher = new Matcher(); |
30 for (let filter of filters) | 30 for (let filter of filters) |
31 matcher.add(Filter.fromText(filter)); | 31 matcher.add(Filter.fromText(filter)); |
32 | 32 |
33 let result = matcher.matchesAny(location, RegExpFilter.typeMap[contentType], docDomain, thirdParty, sitekey); | 33 let result = matcher.matchesAny(location, RegExpFilter.typeMap[contentType], docDomain, thirdParty, sitekey, specificOnly); |
34 if (result) | 34 if (result) |
35 result = result.text; | 35 result = result.text; |
36 | 36 |
37 equal(result, expected, "match(" + location + ", " + contentType + ", " + do cDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey || "no-sitekey") + ") with:\n" + filters.join("\n")); | 37 equal(result, expected, "match(" + location + ", " + contentType + ", " + do cDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey || "no-sitekey") + ", " + (specificOnly ? "specificOnly" : "not-specificOnly") + ") with:\n" + filters.join("\n")); |
38 | 38 |
39 let combinedMatcher = new CombinedMatcher(); | 39 let combinedMatcher = new CombinedMatcher(); |
40 for (let i = 0; i < 2; i++) | 40 for (let i = 0; i < 2; i++) |
41 { | 41 { |
42 for (let filter of filters) | 42 for (let filter of filters) |
43 combinedMatcher.add(Filter.fromText(filter)); | 43 combinedMatcher.add(Filter.fromText(filter)); |
44 | 44 |
45 let result = combinedMatcher.matchesAny(location, RegExpFilter.typeMap[con tentType], docDomain, thirdParty, sitekey); | 45 let result = combinedMatcher.matchesAny(location, RegExpFilter.typeMap[con tentType], docDomain, thirdParty, sitekey, specificOnly); |
46 if (result) | 46 if (result) |
47 result = result.text; | 47 result = result.text; |
48 | 48 |
49 equal(result, expected, "combinedMatch(" + location + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey || "no-sitekey") + ") with:\n" + filters.join("\n")); | 49 equal(result, expected, "combinedMatch(" + location + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey || "no-sitekey") + ", " + (specificOnly ? "specificOnly" : "not-specif icOnly") + ") with:\n" + filters.join("\n")); |
50 | 50 |
51 // For next run: add whitelisting filters | 51 // For next run: add whitelisting filters for filters that aren't already |
52 filters = filters.map((text) => "@@" + text); | 52 if (expected && expected.substr(0, 2) != "@@") |
53 if (expected) | 53 { |
54 expected = "@@" + expected; | 54 filters = filters.filter((text) => text.substr(0, 2) != "@@").map((text) => "@@" + text); |
Thomas Greiner
2015/10/01 16:12:04
This line is now only run under the condition that
kzar
2015/10/02 10:19:29
Yes, well spotted, I don't like this logic at all.
| |
55 if (expected) | |
Thomas Greiner
2015/10/01 16:12:05
Detail: This if-statement is redundant.
kzar
2015/10/02 10:19:29
Done.
| |
56 expected = "@@" + expected; | |
57 } | |
55 } | 58 } |
56 } | 59 } |
57 | 60 |
58 function cacheCheck(matcher, location, contentType, docDomain, thirdParty, exp ected) | 61 function cacheCheck(matcher, location, contentType, docDomain, thirdParty, exp ected) |
59 { | 62 { |
60 let result = matcher.matchesAny(location, RegExpFilter.typeMap[contentType], docDomain, thirdParty); | 63 let result = matcher.matchesAny(location, RegExpFilter.typeMap[contentType], docDomain, thirdParty); |
61 if (result) | 64 if (result) |
62 result = result.text; | 65 result = result.text; |
63 | 66 |
64 equal(result, expected, "match(" + location + ", " + contentType + ", " + do cDomain + ", " + (thirdParty ? "third-party" : "first-party") + ") with static f ilters"); | 67 equal(result, expected, "match(" + location + ", " + contentType + ", " + do cDomain + ", " + (thirdParty ? "third-party" : "first-party") + ") with static f ilters"); |
(...skipping 24 matching lines...) Expand all Loading... | |
89 compareKeywords("^foo%2Ebar^", ["foo%2ebar"]); | 92 compareKeywords("^foo%2Ebar^", ["foo%2ebar"]); |
90 compareKeywords("^aSdF^1234", ["asdf"]); | 93 compareKeywords("^aSdF^1234", ["asdf"]); |
91 compareKeywords("_asdf_1234_", ["asdf", "1234"]); | 94 compareKeywords("_asdf_1234_", ["asdf", "1234"]); |
92 compareKeywords("+asdf-1234=", ["asdf", "1234"]); | 95 compareKeywords("+asdf-1234=", ["asdf", "1234"]); |
93 compareKeywords("/123^ad2&ad&", ["123", "ad2"]); | 96 compareKeywords("/123^ad2&ad&", ["123", "ad2"]); |
94 compareKeywords("/123^ad2&ad$script,domain=example.com", ["123", "ad2"]); | 97 compareKeywords("/123^ad2&ad$script,domain=example.com", ["123", "ad2"]); |
95 }); | 98 }); |
96 | 99 |
97 test("Filter matching", function() | 100 test("Filter matching", function() |
98 { | 101 { |
99 checkMatch([], "http://abc/def", "IMAGE", null, false, null, null); | 102 checkMatch([], "http://abc/def", "IMAGE", null, false, null, false, null); |
100 checkMatch(["abc"], "http://abc/def", "IMAGE", null, false, null, "abc"); | 103 checkMatch(["abc"], "http://abc/def", "IMAGE", null, false, null, false, "ab c"); |
101 checkMatch(["abc", "ddd"], "http://abc/def", "IMAGE", null, false, null, "ab c"); | 104 checkMatch(["abc", "ddd"], "http://abc/def", "IMAGE", null, false, null, fal se, "abc"); |
102 checkMatch(["ddd", "abc"], "http://abc/def", "IMAGE", null, false, null, "ab c"); | 105 checkMatch(["ddd", "abc"], "http://abc/def", "IMAGE", null, false, null, fal se, "abc"); |
103 checkMatch(["ddd", "abd"], "http://abc/def", "IMAGE", null, false, null, nul l); | 106 checkMatch(["ddd", "abd"], "http://abc/def", "IMAGE", null, false, null, fal se, null); |
104 checkMatch(["abc", "://abc/d"], "http://abc/def", "IMAGE", null, false, null , "://abc/d"); | 107 checkMatch(["abc", "://abc/d"], "http://abc/def", "IMAGE", null, false, null , false, "://abc/d"); |
105 checkMatch(["://abc/d", "abc"], "http://abc/def", "IMAGE", null, false, null , "://abc/d"); | 108 checkMatch(["://abc/d", "abc"], "http://abc/def", "IMAGE", null, false, null , false, "://abc/d"); |
106 checkMatch(["|http://"], "http://abc/def", "IMAGE", null, false, null, "|htt p://"); | 109 checkMatch(["|http://"], "http://abc/def", "IMAGE", null, false, null, false , "|http://"); |
107 checkMatch(["|http://abc"], "http://abc/def", "IMAGE", null, false, null, "| http://abc"); | 110 checkMatch(["|http://abc"], "http://abc/def", "IMAGE", null, false, null, fa lse, "|http://abc"); |
108 checkMatch(["|abc"], "http://abc/def", "IMAGE", null, false, null, null); | 111 checkMatch(["|abc"], "http://abc/def", "IMAGE", null, false, null, false, nu ll); |
109 checkMatch(["|/abc/def"], "http://abc/def", "IMAGE", null, false, null, null ); | 112 checkMatch(["|/abc/def"], "http://abc/def", "IMAGE", null, false, null, fals e, null); |
110 checkMatch(["/def|"], "http://abc/def", "IMAGE", null, false, null, "/def|") ; | 113 checkMatch(["/def|"], "http://abc/def", "IMAGE", null, false, null, false, " /def|"); |
111 checkMatch(["/abc/def|"], "http://abc/def", "IMAGE", null, false, null, "/ab c/def|"); | 114 checkMatch(["/abc/def|"], "http://abc/def", "IMAGE", null, false, null, fals e, "/abc/def|"); |
112 checkMatch(["/abc/|"], "http://abc/def", "IMAGE", null, false, null, null); | 115 checkMatch(["/abc/|"], "http://abc/def", "IMAGE", null, false, null, false, null); |
113 checkMatch(["http://abc/|"], "http://abc/def", "IMAGE", null, false, null, n ull); | 116 checkMatch(["http://abc/|"], "http://abc/def", "IMAGE", null, false, null, f alse, null); |
114 checkMatch(["|http://abc/def|"], "http://abc/def", "IMAGE", null, false, nul l, "|http://abc/def|"); | 117 checkMatch(["|http://abc/def|"], "http://abc/def", "IMAGE", null, false, nul l, false, "|http://abc/def|"); |
115 checkMatch(["|/abc/def|"], "http://abc/def", "IMAGE", null, false, null, nul l); | 118 checkMatch(["|/abc/def|"], "http://abc/def", "IMAGE", null, false, null, fal se, null); |
116 checkMatch(["|http://abc/|"], "http://abc/def", "IMAGE", null, false, null, null); | 119 checkMatch(["|http://abc/|"], "http://abc/def", "IMAGE", null, false, null, false, null); |
117 checkMatch(["|/abc/|"], "http://abc/def", "IMAGE", null, false, null, null); | 120 checkMatch(["|/abc/|"], "http://abc/def", "IMAGE", null, false, null, false, null); |
118 checkMatch(["||example.com/abc"], "http://example.com/abc/def", "IMAGE", nul l, false, null, "||example.com/abc"); | 121 checkMatch(["||example.com/abc"], "http://example.com/abc/def", "IMAGE", nul l, false, null, false, "||example.com/abc"); |
119 checkMatch(["||com/abc/def"], "http://example.com/abc/def", "IMAGE", null, f alse, null, "||com/abc/def"); | 122 checkMatch(["||com/abc/def"], "http://example.com/abc/def", "IMAGE", null, f alse, null, false, "||com/abc/def"); |
120 checkMatch(["||com/abc"], "http://example.com/abc/def", "IMAGE", null, false , null, "||com/abc"); | 123 checkMatch(["||com/abc"], "http://example.com/abc/def", "IMAGE", null, false , null, false, "||com/abc"); |
121 checkMatch(["||mple.com/abc"], "http://example.com/abc/def", "IMAGE", null, false, null, null); | 124 checkMatch(["||mple.com/abc"], "http://example.com/abc/def", "IMAGE", null, false, null, false, null); |
122 checkMatch(["||.com/abc/def"], "http://example.com/abc/def", "IMAGE", null, false, null, null); | 125 checkMatch(["||.com/abc/def"], "http://example.com/abc/def", "IMAGE", null, false, null, false, null); |
123 checkMatch(["||http://example.com/"], "http://example.com/abc/def", "IMAGE", null, false, null, null); | 126 checkMatch(["||http://example.com/"], "http://example.com/abc/def", "IMAGE", null, false, null, false, null); |
124 checkMatch(["||example.com/abc/def|"], "http://example.com/abc/def", "IMAGE" , null, false, null, "||example.com/abc/def|"); | 127 checkMatch(["||example.com/abc/def|"], "http://example.com/abc/def", "IMAGE" , null, false, null, false, "||example.com/abc/def|"); |
125 checkMatch(["||com/abc/def|"], "http://example.com/abc/def", "IMAGE", null, false, null, "||com/abc/def|"); | 128 checkMatch(["||com/abc/def|"], "http://example.com/abc/def", "IMAGE", null, false, null, false, "||com/abc/def|"); |
126 checkMatch(["||example.com/abc|"], "http://example.com/abc/def", "IMAGE", nu ll, false, null, null); | 129 checkMatch(["||example.com/abc|"], "http://example.com/abc/def", "IMAGE", nu ll, false, null, false, null); |
127 checkMatch(["abc", "://abc/d", "asdf1234"], "http://abc/def", "IMAGE", null, false, null, "://abc/d"); | 130 checkMatch(["abc", "://abc/d", "asdf1234"], "http://abc/def", "IMAGE", null, false, null, false, "://abc/d"); |
128 checkMatch(["foo*://abc/d", "foo*//abc/de", "://abc/de", "asdf1234"], "http: //abc/def", "IMAGE", null, false, null, "://abc/de"); | 131 checkMatch(["foo*://abc/d", "foo*//abc/de", "://abc/de", "asdf1234"], "http: //abc/def", "IMAGE", null, false, null, false, "://abc/de"); |
129 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def", "IMAGE", null, false, null, "abc$~third-party"); | 132 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def", "IMAGE", null, false, null, false, "abc$~third-party"); |
130 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def", "IMAGE", null, true, null, "abc$third-party"); | 133 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def", "IMAGE", null, true, null, false, "abc$third-party"); |
131 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"], "http://abc/def", "IMAGE", null, false, null, "//abc/def$~third-party"); | 134 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"], "http://abc/def", "IMAGE", null, false, null, false, "//abc/def$~third-party"); |
132 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"], "http://abc/def", "IMAGE", null, true, null, "//abc/def$third-party"); | 135 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"], "http://abc/def", "IMAGE", null, true, null, false, "//abc/def$third-party"); |
133 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def"], "http://abc /def", "IMAGE", null, true, null, "//abc/def"); | 136 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def"], "http://abc /def", "IMAGE", null, true, null, false, "//abc/def"); |
134 checkMatch(["//abc/def", "abc$third-party", "abc$~third-party"], "http://abc /def", "IMAGE", null, true, null, "//abc/def"); | 137 checkMatch(["//abc/def", "abc$third-party", "abc$~third-party"], "http://abc /def", "IMAGE", null, true, null, false, "//abc/def"); |
135 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"], "http://abc/def", "IMAGE", null, true, null, "//abc/def$third-party"); | 138 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"], "http://abc/def", "IMAGE", null, true, null, false, "//abc/def$third-party"); |
136 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"], "http://abc/def", "IMAGE", null, false, null, "abc$~third-party"); | 139 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"], "http://abc/def", "IMAGE", null, false, null, false, "abc$~third-party"); |
137 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$~third-party"] , "http://abc/def", "IMAGE", null, true, null, "abc$third-party"); | 140 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$~third-party"] , "http://abc/def", "IMAGE", null, true, null, false, "abc$third-party"); |
138 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "IMA GE", null, false, null, "abc$image"); | 141 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "IMA GE", null, false, null, false, "abc$image"); |
139 checkMatch(["abc$image", "abc$script", "abc$~script"], "http://abc/def", "SC RIPT", null, false, null, "abc$script"); | 142 checkMatch(["abc$image", "abc$script", "abc$~script"], "http://abc/def", "SC RIPT", null, false, null, false, "abc$script"); |
140 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "OTH ER", null, false, null, "abc$~image"); | 143 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "OTH ER", null, false, null, false, "abc$~image"); |
141 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt p://abc/def", "IMAGE", null, false, null, "//abc/def$image"); | 144 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt p://abc/def", "IMAGE", null, false, null, false, "//abc/def$image"); |
142 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~script"], "ht tp://abc/def", "SCRIPT", null, false, null, "//abc/def$script"); | 145 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~script"], "ht tp://abc/def", "SCRIPT", null, false, null, false, "//abc/def$script"); |
143 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt p://abc/def", "OTHER", null, false, null, "//abc/def$~image"); | 146 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt p://abc/def", "OTHER", null, false, null, false, "//abc/def$~image"); |
144 checkMatch(["abc$image", "abc$~image", "//abc/def"], "http://abc/def", "IMAG E", null, false, null, "//abc/def"); | 147 checkMatch(["abc$image", "abc$~image", "//abc/def"], "http://abc/def", "IMAG E", null, false, null, false, "//abc/def"); |
145 checkMatch(["//abc/def", "abc$image", "abc$~image"], "http://abc/def", "IMAG E", null, false, null, "//abc/def"); | 148 checkMatch(["//abc/def", "abc$image", "abc$~image"], "http://abc/def", "IMAG E", null, false, null, false, "//abc/def"); |
146 checkMatch(["abc$image", "abc$~image", "//abc/def$image"], "http://abc/def", "IMAGE", null, false, null, "//abc/def$image"); | 149 checkMatch(["abc$image", "abc$~image", "//abc/def$image"], "http://abc/def", "IMAGE", null, false, null, false, "//abc/def$image"); |
147 checkMatch(["abc$image", "abc$~image", "//abc/def$script"], "http://abc/def" , "IMAGE", null, false, null, "abc$image"); | 150 checkMatch(["abc$image", "abc$~image", "//abc/def$script"], "http://abc/def" , "IMAGE", null, false, null, false, "abc$image"); |
148 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, null, "abc$domain=foo. com"); | 151 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, null, false, "abc$doma in=foo.com"); |
149 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null, "abc$domain=bar. com"); | 152 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null, false, "abc$doma in=bar.com"); |
150 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, "abc$domain=~foo .com|~bar.com"); | 153 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, false, "abc$doma in=~foo.com|~bar.com"); |
151 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, null, "abc$domain=foo. com"); | 154 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, null, false, "abc$doma in=foo.com"); |
152 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null, null); | 155 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null, false, null); |
153 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, null); | 156 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, false, null); |
154 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://ccc/def", "IMAGE", "baz.com", false, null, "ccc$domain=~foo .com|~bar.com"); | 157 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://ccc/def", "IMAGE", "baz.com", false, null, false, "ccc$doma in=~foo.com|~bar.com"); |
155 checkMatch(["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], "http ://abc/def", "IMAGE", "foo.com", false, "foo-publickey", "abc$sitekey=foo-public key"); | 158 checkMatch(["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], "http ://abc/def", "IMAGE", "foo.com", false, "foo-publickey", false, "abc$sitekey=foo -publickey"); |
156 checkMatch(["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], "http ://abc/def", "IMAGE", "bar.com", false, "bar-publickey", "abc$sitekey=bar-public key"); | 159 checkMatch(["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], "http ://abc/def", "IMAGE", "bar.com", false, "bar-publickey", false, "abc$sitekey=bar -publickey"); |
157 checkMatch(["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], "http ://abc/def", "IMAGE", "bar.com", false, "bar-publickey", null); | 160 checkMatch(["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], "http ://abc/def", "IMAGE", "bar.com", false, "bar-publickey", false, null); |
158 checkMatch(["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], "http ://abc/def", "IMAGE", "baz.com", false, null, null); | 161 checkMatch(["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], "http ://abc/def", "IMAGE", "baz.com", false, null, false, null); |
159 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub lickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "foo-publi ckey", "abc$sitekey=foo-publickey,domain=foo.com"); | 162 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub lickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "foo-publi ckey", false, "abc$sitekey=foo-publickey,domain=foo.com"); |
160 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub lickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "bar-publi ckey", null); | 163 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub lickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "bar-publi ckey", false, null); |
161 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub lickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "foo-publi ckey", null); | 164 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub lickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "foo-publi ckey", false, null); |
162 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub lickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "bar-publi ckey", "abc$sitekey=bar-publickey,domain=bar.com"); | 165 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub lickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "bar-publi ckey", false, "abc$sitekey=bar-publickey,domain=bar.com"); |
166 checkMatch(["@@foo.com$generichide"], "http://foo.com/bar", "GENERICHIDE", " foo.com", false, null, false, "@@foo.com$generichide"); | |
167 checkMatch(["@@foo.com$genericblock"], "http://foo.com/bar", "GENERICBLOCK", "foo.com", false, null, false, "@@foo.com$genericblock"); | |
168 checkMatch(["@@bar.com$generichide"], "http://foo.com/bar", "GENERICHIDE", " foo.com", false, null, false, null); | |
169 checkMatch(["@@bar.com$genericblock"], "http://foo.com/bar", "GENERICBLOCK", "foo.com", false, null, false, null); | |
170 checkMatch(["###bar"], "http://foo.com/bar", "IMAGE", "foo.com", false, null , true, null); | |
Thomas Greiner
2015/10/01 16:12:04
Shouldn't this be "ELEMHIDE" instead of "IMAGE"?
| |
171 checkMatch(["foo.com###bar"], "http://foo.com/bar", "IMAGE", "foo.com", fals e, null, true, null); | |
Thomas Greiner
2015/10/01 16:12:05
From what I understand this should return a filter
kzar
2015/10/02 10:19:29
I don't think these tests _can_ work for element h
| |
172 checkMatch(["/bar$domain=foo.com"], "http://foo.com/bar", "IMAGE", "foo.com" , false, null, true, "/bar$domain=foo.com"); | |
173 checkMatch(["/bar"], "http://foo.com/bar", "IMAGE", "foo.com", false, null, true, null); | |
163 }); | 174 }); |
164 | 175 |
165 test("Result cache checks", function() | 176 test("Result cache checks", function() |
166 { | 177 { |
167 let matcher = new CombinedMatcher(); | 178 let matcher = new CombinedMatcher(); |
168 matcher.add(Filter.fromText("abc$image")); | 179 matcher.add(Filter.fromText("abc$image")); |
169 matcher.add(Filter.fromText("abc$script")); | 180 matcher.add(Filter.fromText("abc$script")); |
170 matcher.add(Filter.fromText("abc$~image,~script,~media")); | 181 matcher.add(Filter.fromText("abc$~image,~script,~media")); |
171 matcher.add(Filter.fromText("cba$third-party")); | 182 matcher.add(Filter.fromText("cba$third-party")); |
172 matcher.add(Filter.fromText("cba$~third-party,~script")); | 183 matcher.add(Filter.fromText("cba$~third-party,~script")); |
(...skipping 14 matching lines...) Expand all Loading... | |
187 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p arty,~script"); | 198 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p arty,~script"); |
188 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par ty"); | 199 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par ty"); |
189 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third-part y,~script"); | 200 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third-part y,~script"); |
190 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-party" ); | 201 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-party" ); |
191 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script"); | 202 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script"); |
192 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, false, "http://f ed$~third-party,~script"); | 203 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, false, "http://f ed$~third-party,~script"); |
193 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, true, "http://fe d$third-party"); | 204 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, true, "http://fe d$third-party"); |
194 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http:// def$script"); | 205 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http:// def$script"); |
195 }); | 206 }); |
196 })(); | 207 })(); |
OLD | NEW |