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

Side by Side Diff: test/filterClasses.js

Issue 29746563: Noissue - Trim spaces around element hiding emulation selectors (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Add tests for incorrect syntax Created April 18, 2018, 12:41 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
« no previous file with comments | « lib/filterClasses.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 "ads"); 424 "ads");
425 425
426 // Comment filters 426 // Comment filters
427 test.equal(Filter.normalize(" ! fo o## bar "), 427 test.equal(Filter.normalize(" ! fo o## bar "),
428 "! fo o## bar"); 428 "! fo o## bar");
429 429
430 // Element hiding filters 430 // Element hiding filters
431 test.equal(Filter.normalize(" domain.c om## # sele ctor "), 431 test.equal(Filter.normalize(" domain.c om## # sele ctor "),
432 "domain.com### sele ctor"); 432 "domain.com### sele ctor");
433 433
434 // Element hiding emulation filters
435 test.equal(Filter.normalize(" domain.c om#?# # sele ctor "),
436 "domain.com#?## sele ctor");
437
438 // Incorrect syntax: the separator "#?#" cannot contain spaces; treated as a
439 // regular filter instead
440 test.equal(Filter.normalize(" domain.c om# ?#. sele ctor "),
441 "domain.com#?#.selector");
442 // Incorrect syntax: the separator "#?#" cannot contain spaces; treated as an
443 // element hiding filter instead, because the "##" following the "?" is taken
444 // to be the separator instead
445 test.equal(Filter.normalize(" domain.c om# ?##sele ctor "),
446 "domain.com#?##sele ctor");
447
448 // Element hiding exception filters
449 test.equal(Filter.normalize(" domain.c om#@# # sele ctor "),
450 "domain.com#@## sele ctor");
451
452 // Incorrect syntax: the separator "#@#" cannot contain spaces; treated as a
453 // regular filter instead (not an element hiding filter either!), because
454 // unlike the case with "# ?##" the "##" following the "@" is not considered
455 // to be a separator
456 test.equal(Filter.normalize(" domain.c om# @## sele ctor "),
457 "domain.com#@##selector");
458
434 // Regular filters 459 // Regular filters
435 let normalized = Filter.normalize( 460 let normalized = Filter.normalize(
436 " b$l a$sitekey= foo ,domain= do main.com |foo .com,c sp= c s p " 461 " b$l a$sitekey= foo ,domain= do main.com |foo .com,c sp= c s p "
437 ); 462 );
438 test.equal( 463 test.equal(
439 normalized, 464 normalized,
440 "b$la$sitekey=foo,domain=domain.com|foo.com,csp=c s p" 465 "b$la$sitekey=foo,domain=domain.com|foo.com,csp=c s p"
441 ); 466 );
442 compareFilter( 467 compareFilter(
443 test, normalized, [ 468 test, normalized, [
(...skipping 24 matching lines...) Expand all
468 "foo$csp=bar,$csp=c s p"); 493 "foo$csp=bar,$csp=c s p");
469 test.equal(Filter.normalize(" f o o $ bar $csp=ba r"), 494 test.equal(Filter.normalize(" f o o $ bar $csp=ba r"),
470 "foo$bar$csp=ba r"); 495 "foo$bar$csp=ba r");
471 test.equal(Filter.normalize("f $ o $ o $ csp=f o o "), 496 test.equal(Filter.normalize("f $ o $ o $ csp=f o o "),
472 "f$o$o$csp=f o o"); 497 "f$o$o$csp=f o o");
473 test.equal(Filter.normalize("/foo$/$ csp = script-src http://example.com/?$1= 1&$2=2&$3=3"), 498 test.equal(Filter.normalize("/foo$/$ csp = script-src http://example.com/?$1= 1&$2=2&$3=3"),
474 "/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");
475 500
476 test.done(); 501 test.done();
477 }; 502 };
OLDNEW
« no previous file with comments | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld