Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 middile: true, | 522 middile: true, |
523 inside: true, | 523 inside: true, |
524 sibling: true, | 524 sibling: true, |
525 sibling2: true, | 525 sibling2: true, |
526 toHide: true | 526 toHide: true |
527 }; | 527 }; |
528 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( | 528 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( |
529 test, "div:-abp-has(> span:-abp-contains(Advertisment))", expectations); | 529 test, "div:-abp-has(> span:-abp-contains(Advertisment))", expectations); |
530 }; | 530 }; |
531 | 531 |
532 // See issue https://issues.adblockplus.org/ticket/7359 | |
533 // and issue https://issues.adblockplus.org/ticket/7428 | |
534 async function runTestQualifier(test, selector) | 532 async function runTestQualifier(test, selector) |
535 { | 533 { |
536 testDocument.body.innerHTML = ` | 534 testDocument.body.innerHTML = ` |
537 <style> | 535 <style> |
Manish Jethani
2019/04/03 17:09:30
Nit: We could just indent the HTML here for readab
hub
2019/04/03 17:59:59
Done.
| |
538 span::before { | 536 span::before { |
539 content: "any"; | 537 content: "any"; |
540 } | 538 } |
541 </style> | 539 </style> |
542 <div id="toHide"> | 540 <div id="toHide"> |
543 <a> | 541 <a> |
544 <p> | 542 <p> |
545 <span></span> | 543 <span></span> |
546 </p> | 544 </p> |
547 </a> | 545 </a> |
548 </div> | 546 </div>`; |
549 `; | 547 |
550 if (await applyElemHideEmulation(test, [selector])) | 548 if (await applyElemHideEmulation(test, [selector])) |
551 expectHidden(test, testDocument.getElementById("toHide")); | 549 expectHidden(test, testDocument.getElementById("toHide")); |
552 | 550 |
553 test.done(); | 551 test.done(); |
554 } | 552 } |
555 | 553 |
554 // See issue https://issues.adblockplus.org/ticket/7428 | |
556 exports.testPropertySelectorCombinatorQualifier = function(test) | 555 exports.testPropertySelectorCombinatorQualifier = function(test) |
557 { | 556 { |
558 runTestQualifier( | 557 runTestQualifier( |
559 test, | 558 test, |
560 "div:-abp-has(> a p > :-abp-properties(content: \"any\"))" | 559 "div:-abp-has(> a p > :-abp-properties(content: \"any\"))" |
561 ); | 560 ); |
562 }; | 561 }; |
563 | 562 |
563 // See issue https://issues.adblockplus.org/ticket/7359 | |
564 exports.testPropertySelectorCombinatorQualifierNested = function(test) | 564 exports.testPropertySelectorCombinatorQualifierNested = function(test) |
565 { | 565 { |
566 runTestQualifier( | 566 runTestQualifier( |
567 test, | 567 test, |
568 "div:-abp-has(> a p:-abp-has(> span:-abp-properties(content: \"any\")))" | 568 "div:-abp-has(> a p:-abp-has(> :-abp-properties(content: \"any\")))" |
569 ); | 569 ); |
570 }; | 570 }; |
571 | 571 |
572 // See issue https://issues.adblockplus.org/ticket/7400 | |
573 exports.testPropertySelectorIdenticalTypeQualifier = function(test) | |
574 { | |
575 runTestQualifier( | |
576 test, | |
577 "div:-abp-has(span:-abp-properties(content: \"any\"))" | |
578 ); | |
579 }; | |
580 | |
581 // See issue https://issues.adblockplus.org/ticket/7400 | |
582 exports.testPropertySelectorIdenticalTypeQualifierNested = function(test) | |
583 { | |
584 runTestQualifier( | |
585 test, | |
586 "div:-abp-has(p:-abp-has(span:-abp-properties(content: \"any\")))" | |
587 ); | |
588 }; | |
589 | |
572 async function runTestPseudoClassContains(test, selector, expectations) | 590 async function runTestPseudoClassContains(test, selector, expectations) |
573 { | 591 { |
574 testDocument.body.innerHTML = ` <style type="text/css"> | 592 testDocument.body.innerHTML = `<div id="parent"> |
575 body { | |
576 margin: 0; | |
577 padding: 0; | |
578 } | |
579 .transparent { | |
580 opacity: 0; | |
581 position: absolute; | |
582 display: block; | |
583 } | |
584 .zerosize { | |
585 font-size: 0; | |
586 } | |
587 div { | |
588 display: block; | |
589 } | |
590 .a { | |
591 display: inline-block; | |
592 white-space: pre-wrap; | |
593 } | |
594 .disp_none { | |
595 display: none; | |
596 } | |
597 .vis_hid { | |
598 visibility: hidden; | |
599 } | |
600 .vis_collapse { | |
601 visibility: collapse; | |
602 } | |
603 .same_colour { | |
604 color: rgb(255,255,255); | |
605 background-color: rgb(255,255,255); | |
606 } | |
607 #label { | |
608 overflow-wrap: break-word; | |
609 } | |
610 </style> | |
611 <div id="parent"> | |
612 <div id="middle"> | 593 <div id="middle"> |
613 <div id="middle1"><div id="inside" class="inside"></div></div> | 594 <div id="middle1"><div id="inside" class="inside"></div></div> |
614 </div> | 595 </div> |
615 <div id="sibling"> | 596 <div id="sibling"> |
616 <div id="tohide">to hide \ud83d\ude42!</div> | 597 <div id="tohide">to hide \ud83d\ude42!</div> |
617 </div> | 598 </div> |
618 <div id="sibling2"> | 599 <div id="sibling2"> |
619 <div id="sibling21"><div id="sibling211" class="inside">Ad*</div></div> | 600 <div id="sibling21"><div id="sibling211" class="inside">Ad*</div></div> |
620 </div> | 601 </div> |
621 <div id="label"><div id="content"><div class="a transparent">Sp</div><div class="a">Sp</div><div class="a zerosize">S</div><div class="a transparent">on</ div><div class="a">on</div><div class="a zerosize">S</div></div></div> | |
622 <div id="label2"><div class="a vis_hid">Visibility: hidden</div><div class ="a">S</div><div class="a vis_collapse">Visibility: collapse</div><div class="a" >p</div><div class="a disp_none">Display: none</div><div class="a">o</div><div c lass="a same_colour">Same colour</div><div class="a">n</div></div> | |
623 <article id="article"><div style="display: none"><div>Spon</div></div></ar ticle> | |
624 <article id="article2"><div><div>Spon</div></div></article> | |
625 </div>`; | 602 </div>`; |
626 let elems = { | 603 let elems = { |
627 parent: testDocument.getElementById("parent"), | 604 parent: testDocument.getElementById("parent"), |
628 middle: testDocument.getElementById("middle"), | 605 middle: testDocument.getElementById("middle"), |
629 inside: testDocument.getElementById("inside"), | 606 inside: testDocument.getElementById("inside"), |
630 sibling: testDocument.getElementById("sibling"), | 607 sibling: testDocument.getElementById("sibling"), |
631 sibling2: testDocument.getElementById("sibling2"), | 608 sibling2: testDocument.getElementById("sibling2"), |
632 toHide: testDocument.getElementById("tohide"), | 609 toHide: testDocument.getElementById("tohide") |
633 label: testDocument.getElementById("label"), | |
634 label2: testDocument.getElementById("label2"), | |
635 article: testDocument.getElementById("article"), | |
636 article2: testDocument.getElementById("article2") | |
637 }; | 610 }; |
638 | 611 |
639 if (await applyElemHideEmulation(test, [selector])) | 612 if (await applyElemHideEmulation(test, [selector])) |
640 compareExpectations(test, elems, expectations); | 613 compareExpectations(test, elems, expectations); |
641 | 614 |
642 test.done(); | 615 test.done(); |
643 } | 616 } |
644 | 617 |
645 exports.testPseudoClassContainsText = function(test) | 618 exports.testPseudoClassContainsText = function(test) |
646 { | 619 { |
(...skipping 14 matching lines...) Expand all Loading... | |
661 let expectations = { | 634 let expectations = { |
662 parent: true, | 635 parent: true, |
663 middle: true, | 636 middle: true, |
664 inside: true, | 637 inside: true, |
665 sibling: false, | 638 sibling: false, |
666 sibling2: true, | 639 sibling2: true, |
667 toHide: true | 640 toHide: true |
668 }; | 641 }; |
669 runTestPseudoClassContains( | 642 runTestPseudoClassContains( |
670 test, "#parent div:-abp-contains(/to\\shide/)", expectations); | 643 test, "#parent div:-abp-contains(/to\\shide/)", expectations); |
671 }; | |
672 | |
673 exports.testPseudoClassContainsVisibleText = function(test) | |
674 { | |
675 let expectations = { | |
676 parent: true, | |
677 middle: true, | |
678 inside: true, | |
679 sibling: true, | |
680 sibling2: true, | |
681 toHide: true, | |
682 label: false, | |
683 label2: false, | |
684 article: true, | |
685 article2: true | |
686 }; | |
687 runTestPseudoClassContains( | |
688 test, "#parent div:-abp-contains-visible(Spon)", expectations); | |
689 }; | |
690 | |
691 exports.testPseudoClassContainsVisibleTextParentVisibility = function(test) | |
692 { | |
693 let expectations = { | |
694 parent: true, | |
695 middle: true, | |
696 inside: true, | |
697 sibling: true, | |
698 sibling2: true, | |
699 toHide: true, | |
700 label: true, | |
701 label2: true, | |
702 article: true, | |
703 article2: false | |
704 }; | |
705 runTestPseudoClassContains( | |
706 test, "article:-abp-contains-visible(Spon)", expectations); | |
707 }; | 644 }; |
708 | 645 |
709 exports.testPseudoClassContainsRegexpIFlag = function(test) | 646 exports.testPseudoClassContainsRegexpIFlag = function(test) |
710 { | 647 { |
711 let expectations = { | 648 let expectations = { |
712 parent: true, | 649 parent: true, |
713 middle: true, | 650 middle: true, |
714 inside: true, | 651 inside: true, |
715 sibling: false, | 652 sibling: false, |
716 sibling2: true, | 653 sibling2: true, |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1186 { | 1123 { |
1187 if (element.id == "n2" || element.id == "n2_3") | 1124 if (element.id == "n2" || element.id == "n2_3") |
1188 expectProcessed(test, element, element.id); | 1125 expectProcessed(test, element, element.id); |
1189 else | 1126 else |
1190 expectNotProcessed(test, element, element.id); | 1127 expectNotProcessed(test, element, element.id); |
1191 } | 1128 } |
1192 } | 1129 } |
1193 | 1130 |
1194 test.done(); | 1131 test.done(); |
1195 }; | 1132 }; |
LEFT | RIGHT |