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

Delta Between Two Patch Sets: test/browser/elemHideEmulation.js

Issue 30035555: Issue 7428, 7400 - Add test case for nested :-abp-properties() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created April 1, 2019, 8:46 p.m.
Right Patch Set: Moved comments Created April 3, 2019, 7:57 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 532 async function runTestQualifier(test, selector)
533 async function runTestCombinatorQualifier(test, selector)
534 { 533 {
535 testDocument.body.innerHTML = ` 534 testDocument.body.innerHTML = `
536 <style> 535 <style>
537 span::before { 536 span::before {
538 content: "any"; 537 content: "any";
539 } 538 }
540 </style> 539 </style>
541 <div id="toHide"> 540 <div id="toHide">
542 <a> 541 <a>
543 <p> 542 <p>
544 <span></span> 543 <span></span>
545 </p> 544 </p>
546 </a> 545 </a>
547 </div> 546 </div>`;
548 `; 547
549 if (await applyElemHideEmulation(test, [selector])) 548 if (await applyElemHideEmulation(test, [selector]))
550 {
551 expectHidden(test, testDocument.getElementById("toHide")); 549 expectHidden(test, testDocument.getElementById("toHide"));
552 } 550
553 551 test.done();
554 test.done(); 552 }
555 } 553
556 554 // See issue https://issues.adblockplus.org/ticket/7428
557 exports.testPropertySelectorCombinatorQualifier = function(test) 555 exports.testPropertySelectorCombinatorQualifier = function(test)
558 { 556 {
559 runTestCombinatorQualifier( 557 runTestQualifier(
560 test, 558 test,
561 "div:-abp-has(> a p > :-abp-properties(content: \"any\"))" 559 "div:-abp-has(> a p > :-abp-properties(content: \"any\"))"
562 ); 560 );
563 }; 561 };
564 562
565 exports.testPropertySelectorCombinatorQualifier2 = function(test) 563 // See issue https://issues.adblockplus.org/ticket/7359
566 { 564 exports.testPropertySelectorCombinatorQualifierNested = function(test)
567 runTestCombinatorQualifier( 565 {
Manish Jethani 2019/04/02 06:29:10 Can this (and possibly more tests in the future) b
hub 2019/04/02 14:29:11 Done
566 runTestQualifier(
568 test, 567 test,
569 "div:-abp-has(> a p:-abp-has(> span:-abp-properties(content: \"any\")))" 568 "div:-abp-has(> a p:-abp-has(> :-abp-properties(content: \"any\")))"
570 ); 569 );
571 }; 570 };
572 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
573 async function runTestPseudoClassContains(test, selector, expectations) 590 async function runTestPseudoClassContains(test, selector, expectations)
574 { 591 {
575 testDocument.body.innerHTML = ` <style type="text/css"> 592 testDocument.body.innerHTML = `<div id="parent">
576 body {
577 margin: 0;
578 padding: 0;
579 }
580 .transparent {
581 opacity: 0;
582 position: absolute;
583 display: block;
584 }
585 .zerosize {
586 font-size: 0;
587 }
588 div {
589 display: block;
590 }
591 .a {
592 display: inline-block;
593 white-space: pre-wrap;
594 }
595 .disp_none {
596 display: none;
597 }
598 .vis_hid {
599 visibility: hidden;
600 }
601 .vis_collapse {
602 visibility: collapse;
603 }
604 .same_colour {
605 color: rgb(255,255,255);
606 background-color: rgb(255,255,255);
607 }
608 #label {
609 overflow-wrap: break-word;
610 }
611 </style>
612 <div id="parent">
613 <div id="middle"> 593 <div id="middle">
614 <div id="middle1"><div id="inside" class="inside"></div></div> 594 <div id="middle1"><div id="inside" class="inside"></div></div>
615 </div> 595 </div>
616 <div id="sibling"> 596 <div id="sibling">
617 <div id="tohide">to hide \ud83d\ude42!</div> 597 <div id="tohide">to hide \ud83d\ude42!</div>
618 </div> 598 </div>
619 <div id="sibling2"> 599 <div id="sibling2">
620 <div id="sibling21"><div id="sibling211" class="inside">Ad*</div></div> 600 <div id="sibling21"><div id="sibling211" class="inside">Ad*</div></div>
621 </div> 601 </div>
622 <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>
623 <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>
624 <article id="article"><div style="display: none"><div>Spon</div></div></ar ticle>
625 <article id="article2"><div><div>Spon</div></div></article>
626 </div>`; 602 </div>`;
627 let elems = { 603 let elems = {
628 parent: testDocument.getElementById("parent"), 604 parent: testDocument.getElementById("parent"),
629 middle: testDocument.getElementById("middle"), 605 middle: testDocument.getElementById("middle"),
630 inside: testDocument.getElementById("inside"), 606 inside: testDocument.getElementById("inside"),
631 sibling: testDocument.getElementById("sibling"), 607 sibling: testDocument.getElementById("sibling"),
632 sibling2: testDocument.getElementById("sibling2"), 608 sibling2: testDocument.getElementById("sibling2"),
633 toHide: testDocument.getElementById("tohide"), 609 toHide: testDocument.getElementById("tohide")
634 label: testDocument.getElementById("label"),
635 label2: testDocument.getElementById("label2"),
636 article: testDocument.getElementById("article"),
637 article2: testDocument.getElementById("article2")
638 }; 610 };
639 611
640 if (await applyElemHideEmulation(test, [selector])) 612 if (await applyElemHideEmulation(test, [selector]))
641 compareExpectations(test, elems, expectations); 613 compareExpectations(test, elems, expectations);
642 614
643 test.done(); 615 test.done();
644 } 616 }
645 617
646 exports.testPseudoClassContainsText = function(test) 618 exports.testPseudoClassContainsText = function(test)
647 { 619 {
(...skipping 14 matching lines...) Expand all
662 let expectations = { 634 let expectations = {
663 parent: true, 635 parent: true,
664 middle: true, 636 middle: true,
665 inside: true, 637 inside: true,
666 sibling: false, 638 sibling: false,
667 sibling2: true, 639 sibling2: true,
668 toHide: true 640 toHide: true
669 }; 641 };
670 runTestPseudoClassContains( 642 runTestPseudoClassContains(
671 test, "#parent div:-abp-contains(/to\\shide/)", expectations); 643 test, "#parent div:-abp-contains(/to\\shide/)", expectations);
672 };
673
674 exports.testPseudoClassContainsVisibleText = function(test)
675 {
676 let expectations = {
677 parent: true,
678 middle: true,
679 inside: true,
680 sibling: true,
681 sibling2: true,
682 toHide: true,
683 label: false,
684 label2: false,
685 article: true,
686 article2: true
687 };
688 runTestPseudoClassContains(
689 test, "#parent div:-abp-contains-visible(Spon)", expectations);
690 };
691
692 exports.testPseudoClassContainsVisibleTextParentVisibility = function(test)
693 {
694 let expectations = {
695 parent: true,
696 middle: true,
697 inside: true,
698 sibling: true,
699 sibling2: true,
700 toHide: true,
701 label: true,
702 label2: true,
703 article: true,
704 article2: false
705 };
706 runTestPseudoClassContains(
707 test, "article:-abp-contains-visible(Spon)", expectations);
708 }; 644 };
709 645
710 exports.testPseudoClassContainsRegexpIFlag = function(test) 646 exports.testPseudoClassContainsRegexpIFlag = function(test)
711 { 647 {
712 let expectations = { 648 let expectations = {
713 parent: true, 649 parent: true,
714 middle: true, 650 middle: true,
715 inside: true, 651 inside: true,
716 sibling: false, 652 sibling: false,
717 sibling2: true, 653 sibling2: true,
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 { 1123 {
1188 if (element.id == "n2" || element.id == "n2_3") 1124 if (element.id == "n2" || element.id == "n2_3")
1189 expectProcessed(test, element, element.id); 1125 expectProcessed(test, element, element.id);
1190 else 1126 else
1191 expectNotProcessed(test, element, element.id); 1127 expectNotProcessed(test, element, element.id);
1192 } 1128 }
1193 } 1129 }
1194 1130
1195 test.done(); 1131 test.done();
1196 }; 1132 };
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld