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

Side by Side Diff: test/filterClasses.js

Issue 29580558: Issue 5174 - Allow '{' and '}' in selectors (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Fix a bug. Elememulation test case. Created Oct. 16, 2017, 6:38 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ["@@/asdf??+/", InvalidFilter, "invalid"], 60 ["@@/asdf??+/", InvalidFilter, "invalid"],
61 ["##asdf", ElemHideFilter, "elemhide"], 61 ["##asdf", ElemHideFilter, "elemhide"],
62 ["#@#asdf", ElemHideException, "elemhideexception"], 62 ["#@#asdf", ElemHideException, "elemhideexception"],
63 ["foobar##asdf", ElemHideFilter, "elemhide"], 63 ["foobar##asdf", ElemHideFilter, "elemhide"],
64 ["foobar#@#asdf", ElemHideException, "elemhideexception"], 64 ["foobar#@#asdf", ElemHideException, "elemhideexception"],
65 ["foobar##a", ElemHideFilter, "elemhide"], 65 ["foobar##a", ElemHideFilter, "elemhide"],
66 ["foobar#@#a", ElemHideException, "elemhideexception"], 66 ["foobar#@#a", ElemHideException, "elemhideexception"],
67 67
68 ["foobar#asdf", BlockingFilter, "blocking"], 68 ["foobar#asdf", BlockingFilter, "blocking"],
69 ["foobar|foobas##asdf", BlockingFilter, "blocking"], 69 ["foobar|foobas##asdf", BlockingFilter, "blocking"],
70 ["foobar##asdf{asdf}", BlockingFilter, "blocking"], 70 ["foobar##asdf{asdf}", ElemHideFilter, "elemhide"],
71 ["foobar##", BlockingFilter, "blocking"], 71 ["foobar##", BlockingFilter, "blocking"],
72 ["foobar#@#", BlockingFilter, "blocking"], 72 ["foobar#@#", BlockingFilter, "blocking"],
73 ["asdf$foobar", InvalidFilter, "invalid"], 73 ["asdf$foobar", InvalidFilter, "invalid"],
74 ["asdf$image,foobar", InvalidFilter, "invalid"], 74 ["asdf$image,foobar", InvalidFilter, "invalid"],
75 ["asdf$image=foobar", BlockingFilter, "blocking"], 75 ["asdf$image=foobar", BlockingFilter, "blocking"],
76 ["asdf$image=foobar=xyz,~collapse", BlockingFilter, "blocking"], 76 ["asdf$image=foobar=xyz,~collapse", BlockingFilter, "blocking"],
77 77
78 ["##foo[-abp-properties='something']bar", InvalidFilter, "invalid"], 78 ["##foo[-abp-properties='something']bar", InvalidFilter, "invalid"],
79 ["#@#foo[-abp-properties='something']bar", ElemHideException, "elemhideexcep tion"], 79 ["#@#foo[-abp-properties='something']bar", ElemHideException, "elemhideexcep tion"],
80 ["example.com##foo[-abp-properties='something']bar", ElemHideEmulationFilter , "elemhideemulation"], 80 ["example.com##foo[-abp-properties='something']bar", ElemHideEmulationFilter , "elemhideemulation"],
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 for (let [text, selector, selectorDomain] of tests) 375 for (let [text, selector, selectorDomain] of tests)
376 { 376 {
377 doTest(text, selector, selectorDomain); 377 doTest(text, selector, selectorDomain);
378 doTest(text.replace("##", "#@#"), selector, selectorDomain); 378 doTest(text.replace("##", "#@#"), selector, selectorDomain);
379 } 379 }
380 380
381 test.done(); 381 test.done();
382 }; 382 };
383 383
384 exports.testElemHideRulesWithBraces = function(test)
385 {
386 let filter = Filter.fromText("###foo{color: red}");
387 test.equal(filter.type, "elemhide");
388 test.equal(filter.selector, "#foo\\x7B color: red\\x7D ");
389 filter.delete();
390
391 filter = Filter.fromText("foo.com##[-abp-properties='/margin: [3-4]{2}/']");
hub 2017/10/16 18:39:43 we don't handle the new syntax yet.
Wladimir Palant 2017/10/17 10:24:33 Feel free to file an issue for that.
hub 2017/10/17 19:22:18 Filed https://issues.adblockplus.org/ticket/5870
392 test.equal(filter.type, "elemhideemulation");
393 test.equal(filter.selector, "[-abp-properties='/margin: [3-4]\\x7B 2\\x7D /']" );
394 filter.delete();
395
396 test.done();
397 };
398
384 exports.testNotifications = function(test) 399 exports.testNotifications = function(test)
385 { 400 {
386 function checkNotifications(action, expected, message) 401 function checkNotifications(action, expected, message)
387 { 402 {
388 let result = null; 403 let result = null;
389 let listener = (topic, filter) => 404 let listener = (topic, filter) =>
390 { 405 {
391 if (result) 406 if (result)
392 test.ok(false, "Got more that one notification - " + message); 407 test.ok(false, "Got more that one notification - " + message);
393 else 408 else
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 filter.hitCount++; 446 filter.hitCount++;
432 }, ["filter.hitCount", "foobar"], "Increasing filter hit counts"); 447 }, ["filter.hitCount", "foobar"], "Increasing filter hit counts");
433 checkNotifications(() => 448 checkNotifications(() =>
434 { 449 {
435 filter.hitCount = 0; 450 filter.hitCount = 0;
436 }, ["filter.hitCount", "foobar"], "Resetting filter hit counts"); 451 }, ["filter.hitCount", "foobar"], "Resetting filter hit counts");
437 452
438 filter.delete(); 453 filter.delete();
439 test.done(); 454 test.done();
440 }; 455 };
OLDNEW
« compiled/filter/ElemHideBase.cpp ('K') | « compiled/filter/ElemHideBase.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld