Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/filterClasses.js

Issue 29737558: Issue 6538, 6781 - Implement support for snippet filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Make snippet filters similar to element hiding filters Created April 25, 2018, 5:15 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 26 matching lines...) Expand all
37 exports.setUp = function(callback) 37 exports.setUp = function(callback)
38 { 38 {
39 let sandboxedRequire = createSandbox(); 39 let sandboxedRequire = createSandbox();
40 ( 40 (
41 {Filter, InvalidFilter, CommentFilter, ActiveFilter, RegExpFilter, 41 {Filter, InvalidFilter, CommentFilter, ActiveFilter, RegExpFilter,
42 BlockingFilter, WhitelistFilter, ElemHideBase, ElemHideFilter, 42 BlockingFilter, WhitelistFilter, ElemHideBase, ElemHideFilter,
43 ElemHideException, 43 ElemHideException,
44 ElemHideEmulationFilter} = sandboxedRequire("../lib/filterClasses") 44 ElemHideEmulationFilter} = sandboxedRequire("../lib/filterClasses")
45 ); 45 );
46 t = RegExpFilter.typeMap; 46 t = RegExpFilter.typeMap;
47 defaultTypes = 0x7FFFFFFF & ~(t.CSP | t.ELEMHIDE | t.DOCUMENT | t.POPUP | 47 defaultTypes = 0x7FFFFFFF & ~(t.CSP | t.ELEMHIDE | t.SNIPPET | t.DOCUMENT |
48 t.GENERICHIDE | t.GENERICBLOCK); 48 t.POPUP | t.GENERICHIDE | t.GENERICBLOCK);
49 49
50 callback(); 50 callback();
51 }; 51 };
52 52
53 function serializeFilter(filter) 53 function serializeFilter(filter)
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)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 else if (filter instanceof ElemHideBase) 101 else if (filter instanceof ElemHideBase)
102 { 102 {
103 if (filter instanceof ElemHideFilter) 103 if (filter instanceof ElemHideFilter)
104 result.push("type=elemhide"); 104 result.push("type=elemhide");
105 else if (filter instanceof ElemHideException) 105 else if (filter instanceof ElemHideException)
106 result.push("type=elemhideexception"); 106 result.push("type=elemhideexception");
107 else if (filter instanceof ElemHideEmulationFilter) 107 else if (filter instanceof ElemHideEmulationFilter)
108 result.push("type=elemhideemulation"); 108 result.push("type=elemhideemulation");
109 109
110 result.push("selectorDomain=" + (filter.selectorDomain || "")); 110 result.push("injectionDomain=" + (filter.injectionDomain || ""));
111 result.push("selector=" + filter.selector); 111 result.push("code=" + filter.code);
112 } 112 }
113 } 113 }
114 return result; 114 return result;
115 } 115 }
116 116
117 function addDefaults(expected) 117 function addDefaults(expected)
118 { 118 {
119 let type = null; 119 let type = null;
120 let hasProperty = {}; 120 let hasProperty = {};
121 for (let entry of expected) 121 for (let entry of expected)
(...skipping 13 matching lines...) Expand all
135 if (type == "whitelist" || type == "filterlist" || type == "elemhide" || 135 if (type == "whitelist" || type == "filterlist" || type == "elemhide" ||
136 type == "elemhideexception" || type == "elemhideemulation") 136 type == "elemhideexception" || type == "elemhideemulation")
137 { 137 {
138 addProperty("disabled", "false"); 138 addProperty("disabled", "false");
139 addProperty("lastHit", "0"); 139 addProperty("lastHit", "0");
140 addProperty("hitCount", "0"); 140 addProperty("hitCount", "0");
141 } 141 }
142 if (type == "whitelist" || type == "filterlist") 142 if (type == "whitelist" || type == "filterlist")
143 { 143 {
144 addProperty("contentType", 0x7FFFFFFF & ~( 144 addProperty("contentType", 0x7FFFFFFF & ~(
145 t.CSP | t.DOCUMENT | t.ELEMHIDE | t.POPUP | t.GENERICHIDE | t.GENERICBLOCK 145 t.CSP | t.DOCUMENT | t.ELEMHIDE | t.SNIPPET | t.POPUP | t.GENERICHIDE |
146 t.GENERICBLOCK
146 )); 147 ));
147 addProperty("matchCase", "false"); 148 addProperty("matchCase", "false");
148 addProperty("thirdParty", "null"); 149 addProperty("thirdParty", "null");
149 addProperty("domains", ""); 150 addProperty("domains", "");
150 addProperty("sitekeys", ""); 151 addProperty("sitekeys", "");
151 } 152 }
152 if (type == "filterlist") 153 if (type == "filterlist")
153 { 154 {
154 addProperty("collapse", "null"); 155 addProperty("collapse", "null");
155 addProperty("csp", "null"); 156 addProperty("csp", "null");
156 } 157 }
157 if (type == "elemhide" || type == "elemhideexception" || 158 if (type == "elemhide" || type == "elemhideexception" ||
158 type == "elemhideemulation") 159 type == "elemhideemulation")
159 { 160 {
160 addProperty("selectorDomain", ""); 161 addProperty("injectionDomain", "");
161 addProperty("domains", ""); 162 addProperty("domains", "");
162 } 163 }
163 } 164 }
164 165
165 function compareFilter(test, text, expected, postInit) 166 function compareFilter(test, text, expected, postInit)
166 { 167 {
167 addDefaults(expected); 168 addDefaults(expected);
168 169
169 let filter = Filter.fromText(text); 170 let filter = Filter.fromText(text);
170 if (postInit) 171 if (postInit)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 compareFilter(test, "bla$csp=foo,csp=referrer foo", ["type=invalid", "text=bla $csp=foo,csp=referrer foo", "reason=filter_invalid_csp"]); 320 compareFilter(test, "bla$csp=foo,csp=referrer foo", ["type=invalid", "text=bla $csp=foo,csp=referrer foo", "reason=filter_invalid_csp"]);
320 compareFilter(test, "bla$csp=foo,csp=base-uri", ["type=invalid", "text=bla$csp =foo,csp=base-uri", "reason=filter_invalid_csp"]); 321 compareFilter(test, "bla$csp=foo,csp=base-uri", ["type=invalid", "text=bla$csp =foo,csp=base-uri", "reason=filter_invalid_csp"]);
321 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp "]); 322 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp "]);
322 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp =foo,csp=ReFeRReR", "reason=filter_invalid_csp"]); 323 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp =foo,csp=ReFeRReR", "reason=filter_invalid_csp"]);
323 324
324 test.done(); 325 test.done();
325 }; 326 };
326 327
327 exports.testElementHidingRules = function(test) 328 exports.testElementHidingRules = function(test)
328 { 329 {
329 compareFilter(test, "##ddd", ["type=elemhide", "text=##ddd", "selector=ddd"]); 330 compareFilter(test, "##ddd", ["type=elemhide", "text=##ddd", "code=ddd"]);
330 compareFilter(test, "##body > div:first-child", ["type=elemhide", "text=##body > div:first-child", "selector=body > div:first-child"]); 331 compareFilter(test, "##body > div:first-child", ["type=elemhide", "text=##body > div:first-child", "code=body > div:first-child"]);
331 compareFilter(test, "foo##ddd", ["type=elemhide", "text=foo##ddd", "selectorDo main=foo", "selector=ddd", "domains=FOO"]); 332 compareFilter(test, "foo##ddd", ["type=elemhide", "text=foo##ddd", "injectionD omain=foo", "code=ddd", "domains=FOO"]);
332 compareFilter(test, "foo,bar##ddd", ["type=elemhide", "text=foo,bar##ddd", "se lectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO"]); 333 compareFilter(test, "foo,bar##ddd", ["type=elemhide", "text=foo,bar##ddd", "in jectionDomain=foo,bar", "code=ddd", "domains=BAR|FOO"]);
333 compareFilter(test, "foo,~bar##ddd", ["type=elemhide", "text=foo,~bar##ddd", " selectorDomain=foo", "selector=ddd", "domains=FOO|~BAR"]); 334 compareFilter(test, "foo,~bar##ddd", ["type=elemhide", "text=foo,~bar##ddd", " injectionDomain=foo", "code=ddd", "domains=FOO|~BAR"]);
334 compareFilter(test, "foo,~baz,bar##ddd", ["type=elemhide", "text=foo,~baz,bar# #ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ"]); 335 compareFilter(test, "foo,~baz,bar##ddd", ["type=elemhide", "text=foo,~baz,bar# #ddd", "injectionDomain=foo,bar", "code=ddd", "domains=BAR|FOO|~BAZ"]);
335 336
336 test.done(); 337 test.done();
337 }; 338 };
338 339
339 exports.testElementHidingExceptions = function(test) 340 exports.testElementHidingExceptions = function(test)
340 { 341 {
341 compareFilter(test, "#@#ddd", ["type=elemhideexception", "text=#@#ddd", "selec tor=ddd"]); 342 compareFilter(test, "#@#ddd", ["type=elemhideexception", "text=#@#ddd", "code= ddd"]);
342 compareFilter(test, "#@#body > div:first-child", ["type=elemhideexception", "t ext=#@#body > div:first-child", "selector=body > div:first-child"]); 343 compareFilter(test, "#@#body > div:first-child", ["type=elemhideexception", "t ext=#@#body > div:first-child", "code=body > div:first-child"]);
343 compareFilter(test, "foo#@#ddd", ["type=elemhideexception", "text=foo#@#ddd", "selectorDomain=foo", "selector=ddd", "domains=FOO"]); 344 compareFilter(test, "foo#@#ddd", ["type=elemhideexception", "text=foo#@#ddd", "injectionDomain=foo", "code=ddd", "domains=FOO"]);
344 compareFilter(test, "foo,bar#@#ddd", ["type=elemhideexception", "text=foo,bar# @#ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO"]); 345 compareFilter(test, "foo,bar#@#ddd", ["type=elemhideexception", "text=foo,bar# @#ddd", "injectionDomain=foo,bar", "code=ddd", "domains=BAR|FOO"]);
345 compareFilter(test, "foo,~bar#@#ddd", ["type=elemhideexception", "text=foo,~ba r#@#ddd", "selectorDomain=foo", "selector=ddd", "domains=FOO|~BAR"]); 346 compareFilter(test, "foo,~bar#@#ddd", ["type=elemhideexception", "text=foo,~ba r#@#ddd", "injectionDomain=foo", "code=ddd", "domains=FOO|~BAR"]);
346 compareFilter(test, "foo,~baz,bar#@#ddd", ["type=elemhideexception", "text=foo ,~baz,bar#@#ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BA Z"]); 347 compareFilter(test, "foo,~baz,bar#@#ddd", ["type=elemhideexception", "text=foo ,~baz,bar#@#ddd", "injectionDomain=foo,bar", "code=ddd", "domains=BAR|FOO|~BAZ"] );
347 348
348 test.done(); 349 test.done();
349 }; 350 };
350 351
351 exports.testElemHideEmulationFilters = function(test) 352 exports.testElemHideEmulationFilters = function(test)
352 { 353 {
353 // Check valid domain combinations 354 // Check valid domain combinations
354 compareFilter(test, "foo.com#?#:-abp-properties(abc)", ["type=elemhideemulatio n", "text=foo.com#?#:-abp-properties(abc)", "selectorDomain=foo.com", "selector= :-abp-properties(abc)", "domains=FOO.COM"]); 355 compareFilter(test, "foo.com#?#:-abp-properties(abc)", ["type=elemhideemulatio n", "text=foo.com#?#:-abp-properties(abc)", "injectionDomain=foo.com", "code=:-a bp-properties(abc)", "domains=FOO.COM"]);
355 compareFilter(test, "foo.com,~bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=foo.com,~bar.com#?#:-abp-properties(abc)", "selectorDomain=fo o.com", "selector=:-abp-properties(abc)", "domains=FOO.COM|~BAR.COM"]); 356 compareFilter(test, "foo.com,~bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=foo.com,~bar.com#?#:-abp-properties(abc)", "injectionDomain=f oo.com", "code=:-abp-properties(abc)", "domains=FOO.COM|~BAR.COM"]);
356 compareFilter(test, "foo.com,~bar#?#:-abp-properties(abc)", ["type=elemhideemu lation", "text=foo.com,~bar#?#:-abp-properties(abc)", "selectorDomain=foo.com", "selector=:-abp-properties(abc)", "domains=FOO.COM|~BAR"]); 357 compareFilter(test, "foo.com,~bar#?#:-abp-properties(abc)", ["type=elemhideemu lation", "text=foo.com,~bar#?#:-abp-properties(abc)", "injectionDomain=foo.com", "code=:-abp-properties(abc)", "domains=FOO.COM|~BAR"]);
357 compareFilter(test, "~foo.com,bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=~foo.com,bar.com#?#:-abp-properties(abc)", "selectorDomain=ba r.com", "selector=:-abp-properties(abc)", "domains=BAR.COM|~FOO.COM"]); 358 compareFilter(test, "~foo.com,bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=~foo.com,bar.com#?#:-abp-properties(abc)", "injectionDomain=b ar.com", "code=:-abp-properties(abc)", "domains=BAR.COM|~FOO.COM"]);
358 359
359 // Check some special cases 360 // Check some special cases
360 compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-ab p-properties(abc)", "reason=filter_elemhideemulation_nodomain"]); 361 compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-ab p-properties(abc)", "reason=filter_elemhideemulation_nodomain"]);
361 compareFilter(test, "foo.com#?#abc", ["type=elemhideemulation", "text=foo.com# ?#abc", "selectorDomain=foo.com", "selector=abc", "domains=FOO.COM"]); 362 compareFilter(test, "foo.com#?#abc", ["type=elemhideemulation", "text=foo.com# ?#abc", "injectionDomain=foo.com", "code=abc", "domains=FOO.COM"]);
362 compareFilter(test, "foo.com#?#:-abp-foobar(abc)", ["type=elemhideemulation", "text=foo.com#?#:-abp-foobar(abc)", "selectorDomain=foo.com", "selector=:-abp-fo obar(abc)", "domains=FOO.COM"]); 363 compareFilter(test, "foo.com#?#:-abp-foobar(abc)", ["type=elemhideemulation", "text=foo.com#?#:-abp-foobar(abc)", "injectionDomain=foo.com", "code=:-abp-fooba r(abc)", "domains=FOO.COM"]);
363 compareFilter(test, "foo.com#?#aaa :-abp-properties(abc) bbb", ["type=elemhide emulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomain=foo. com", "selector=aaa :-abp-properties(abc) bbb", "domains=FOO.COM"]); 364 compareFilter(test, "foo.com#?#aaa :-abp-properties(abc) bbb", ["type=elemhide emulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "injectionDomain=foo .com", "code=aaa :-abp-properties(abc) bbb", "domains=FOO.COM"]);
364 compareFilter(test, "foo.com#?#:-abp-properties(|background-image: url(data:*) )", ["type=elemhideemulation", "text=foo.com#?#:-abp-properties(|background-imag e: url(data:*))", "selectorDomain=foo.com", "selector=:-abp-properties(|backgrou nd-image: url(data:*))", "domains=FOO.COM"]); 365 compareFilter(test, "foo.com#?#:-abp-properties(|background-image: url(data:*) )", ["type=elemhideemulation", "text=foo.com#?#:-abp-properties(|background-imag e: url(data:*))", "injectionDomain=foo.com", "code=:-abp-properties(|background- image: url(data:*))", "domains=FOO.COM"]);
365 366
366 // Check conversion of legacy filters 367 // Check conversion of legacy filters
367 compareFilter(test, "foo.com##[-abp-properties='abc']", ["type=elemhideemulati on", "text=foo.com#?#:-abp-properties(abc)", "selectorDomain=foo.com", "selector =:-abp-properties(abc)", "domains=FOO.COM"]); 368 compareFilter(test, "foo.com##[-abp-properties='abc']", ["type=elemhideemulati on", "text=foo.com#?#:-abp-properties(abc)", "injectionDomain=foo.com", "code=:- abp-properties(abc)", "domains=FOO.COM"]);
368 test.equal(Filter.fromText("foo.com##[-abp-properties='abc']"), Filter.fromTex t("foo.com#?#:-abp-properties(abc)")); 369 test.equal(Filter.fromText("foo.com##[-abp-properties='abc']"), Filter.fromTex t("foo.com#?#:-abp-properties(abc)"));
369 compareFilter(test, "foo.com#@#[-abp-properties='abc']", ["type=elemhideexcept ion", "text=foo.com#@#[-abp-properties='abc']", "selectorDomain=foo.com", "selec tor=[-abp-properties='abc']", "domains=FOO.COM"]); 370 compareFilter(test, "foo.com#@#[-abp-properties='abc']", ["type=elemhideexcept ion", "text=foo.com#@#[-abp-properties='abc']", "injectionDomain=foo.com", "code =[-abp-properties='abc']", "domains=FOO.COM"]);
370 compareFilter(test, "foo.com#?#[-abp-properties='abc']", ["type=elemhideemulat ion", "text=foo.com#?#[-abp-properties='abc']", "selectorDomain=foo.com", "selec tor=[-abp-properties='abc']", "domains=FOO.COM"]); 371 compareFilter(test, "foo.com#?#[-abp-properties='abc']", ["type=elemhideemulat ion", "text=foo.com#?#[-abp-properties='abc']", "injectionDomain=foo.com", "code =[-abp-properties='abc']", "domains=FOO.COM"]);
371 compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=elemhid eemulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomain=foo .com", "selector=aaa :-abp-properties(abc) bbb", "domains=FOO.COM"]); 372 compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=elemhid eemulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "injectionDomain=fo o.com", "code=aaa :-abp-properties(abc) bbb", "domains=FOO.COM"]);
372 373
373 // test matching -abp-properties= (https://issues.adblockplus.org/ticket/5037) . 374 // test matching -abp-properties= (https://issues.adblockplus.org/ticket/5037) .
374 compareFilter(test, "foo.com##[-abp-properties-bogus='abc']", ["type=elemhide" , "text=foo.com##[-abp-properties-bogus='abc']", "selectorDomain=foo.com", "sele ctor=[-abp-properties-bogus='abc']", "domains=FOO.COM"]); 375 compareFilter(test, "foo.com##[-abp-properties-bogus='abc']", ["type=elemhide" , "text=foo.com##[-abp-properties-bogus='abc']", "injectionDomain=foo.com", "cod e=[-abp-properties-bogus='abc']", "domains=FOO.COM"]);
375 376
376 test.done(); 377 test.done();
377 }; 378 };
378 379
379 exports.testEmptyElemHideDomains = function(test) 380 exports.testEmptyElemHideDomains = function(test)
380 { 381 {
381 let emptyDomainFilters = [ 382 let emptyDomainFilters = [
382 ",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector", 383 ",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector",
383 ",foo.com##selector", "foo.com,~##selector", 384 ",foo.com##selector", "foo.com,~##selector",
384 "foo.com,,bar.com##selector", "foo.com,~,bar.com##selector" 385 "foo.com,,bar.com##selector", "foo.com,~,bar.com##selector"
385 ]; 386 ];
386 387
387 for (let filterText of emptyDomainFilters) 388 for (let filterText of emptyDomainFilters)
388 { 389 {
389 let filter = Filter.fromText(filterText); 390 let filter = Filter.fromText(filterText);
390 test.ok(filter instanceof InvalidFilter); 391 test.ok(filter instanceof InvalidFilter);
391 test.equal(filter.reason, "filter_invalid_domain"); 392 test.equal(filter.reason, "filter_invalid_domain");
392 } 393 }
393 394
394 test.done(); 395 test.done();
395 }; 396 };
396 397
397 exports.testElemHideRulesWithBraces = function(test) 398 exports.testElemHideRulesWithBraces = function(test)
398 { 399 {
399 compareFilter( 400 compareFilter(
400 test, "###foo{color: red}", [ 401 test, "###foo{color: red}", [
401 "type=elemhide", 402 "type=elemhide",
402 "text=###foo{color: red}", 403 "text=###foo{color: red}",
403 "selectorDomain=", 404 "injectionDomain=",
404 "selector=#foo\\7B color: red\\7D ", 405 "code=#foo\\7B color: red\\7D ",
405 "domains=" 406 "domains="
406 ] 407 ]
407 ); 408 );
408 compareFilter( 409 compareFilter(
409 test, "foo.com#?#:-abp-properties(/margin: [3-4]{2}/)", [ 410 test, "foo.com#?#:-abp-properties(/margin: [3-4]{2}/)", [
410 "type=elemhideemulation", 411 "type=elemhideemulation",
411 "text=foo.com#?#:-abp-properties(/margin: [3-4]{2}/)", 412 "text=foo.com#?#:-abp-properties(/margin: [3-4]{2}/)",
412 "selectorDomain=foo.com", 413 "injectionDomain=foo.com",
413 "selector=:-abp-properties(/margin: [3-4]\\7B 2\\7D /)", 414 "code=:-abp-properties(/margin: [3-4]\\7B 2\\7D /)",
414 "domains=FOO.COM" 415 "domains=FOO.COM"
415 ] 416 ]
416 ); 417 );
417 test.done(); 418 test.done();
418 }; 419 };
419 420
420 exports.testFilterNormalization = function(test) 421 exports.testFilterNormalization = function(test)
421 { 422 {
422 // Line breaks etc 423 // Line breaks etc
423 test.equal(Filter.normalize("\n\t\nad\ns"), 424 test.equal(Filter.normalize("\n\t\nad\ns"),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 "foo$csp=bar,$csp=c s p"); 494 "foo$csp=bar,$csp=c s p");
494 test.equal(Filter.normalize(" f o o $ bar $csp=ba r"), 495 test.equal(Filter.normalize(" f o o $ bar $csp=ba r"),
495 "foo$bar$csp=ba r"); 496 "foo$bar$csp=ba r");
496 test.equal(Filter.normalize("f $ o $ o $ csp=f o o "), 497 test.equal(Filter.normalize("f $ o $ o $ csp=f o o "),
497 "f$o$o$csp=f o o"); 498 "f$o$o$csp=f o o");
498 test.equal(Filter.normalize("/foo$/$ csp = script-src http://example.com/?$1= 1&$2=2&$3=3"), 499 test.equal(Filter.normalize("/foo$/$ csp = script-src http://example.com/?$1= 1&$2=2&$3=3"),
499 "/foo$/$csp=script-src http://example.com/?$1=1&$2=2&$3=3"); 500 "/foo$/$csp=script-src http://example.com/?$1=1&$2=2&$3=3");
500 501
501 test.done(); 502 test.done();
502 }; 503 };
OLDNEW

Powered by Google App Engine
This is Rietveld