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: Move test.done() out of runTest Created April 2, 2019, 2:28 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)
Manish Jethani 2019/04/03 11:15:58 Shouldn't this be 7400?
hub 2019/04/03 16:30:07 The test is actually all based on issue #7359. It
Manish Jethani 2019/04/03 17:09:30 Sorry, isn't the second test here affected by 7400
Manish Jethani 2019/04/03 17:26:53 OK, I looked at 7359 again. The only thing it adds
Manish Jethani 2019/04/03 17:28:49 Misspoke, of course the `>span` case is valid only
533 // and issue https://issues.adblockplus.org/ticket/7428
534 async function runTestCombinatorQualifier(test, selector)
Manish Jethani 2019/04/03 11:15:58 I think what you mean is `runTestCompoundQualifier
hub 2019/04/03 16:30:07 Done.
535 { 533 {
536 testDocument.body.innerHTML = ` 534 testDocument.body.innerHTML = `
537 <style> 535 <style>
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>
Manish Jethani 2019/04/03 11:15:58 Nit: It is more natural if `<a>` occurs with the `
hub 2019/04/03 16:30:07 if everything was done in a "natural way", lot of
Manish Jethani 2019/04/03 16:40:02 Fair enough :)
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 {
Manish Jethani 2019/04/03 11:15:58 Nit: No need for the braces here.
hub 2019/04/03 16:30:07 Done.
552 expectHidden(test, testDocument.getElementById("toHide")); 549 expectHidden(test, testDocument.getElementById("toHide"));
553 } 550
554 } 551 test.done();
555 552 }
556 exports.testPropertySelectorCombinatorQualifier = async function(test) 553
557 { 554 // See issue https://issues.adblockplus.org/ticket/7428
558 await runTestCombinatorQualifier( 555 exports.testPropertySelectorCombinatorQualifier = function(test)
556 {
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 test.done(); 562
Manish Jethani 2019/04/03 11:15:58 My reason for asking to move `test.done()` here wa
hub 2019/04/03 16:30:07 Having actually separate test cases is important b
Manish Jethani 2019/04/03 16:40:02 Well in that case I think it's OK to just move `te
hub 2019/04/03 16:41:57 already done :-)
564 }; 563 // See issue https://issues.adblockplus.org/ticket/7359
565 564 exports.testPropertySelectorCombinatorQualifierNested = function(test)
566 exports.testPropertySelectorCombinatorQualifier2 = async function(test) 565 {
567 { 566 runTestQualifier(
568 await runTestCombinatorQualifier(
569 test, 567 test,
570 "div:-abp-has(> a p:-abp-has(> span:-abp-properties(content: \"any\")))" 568 "div:-abp-has(> a p:-abp-has(> :-abp-properties(content: \"any\")))"
571 ); 569 );
572 570 };
573 test.done(); 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 );
574 }; 588 };
575 589
576 async function runTestPseudoClassContains(test, selector, expectations) 590 async function runTestPseudoClassContains(test, selector, expectations)
577 { 591 {
578 testDocument.body.innerHTML = ` <style type="text/css"> 592 testDocument.body.innerHTML = `<div id="parent">
579 body {
580 margin: 0;
581 padding: 0;
582 }
583 .transparent {
584 opacity: 0;
585 position: absolute;
586 display: block;
587 }
588 .zerosize {
589 font-size: 0;
590 }
591 div {
592 display: block;
593 }
594 .a {
595 display: inline-block;
596 white-space: pre-wrap;
597 }
598 .disp_none {
599 display: none;
600 }
601 .vis_hid {
602 visibility: hidden;
603 }
604 .vis_collapse {
605 visibility: collapse;
606 }
607 .same_colour {
608 color: rgb(255,255,255);
609 background-color: rgb(255,255,255);
610 }
611 #label {
612 overflow-wrap: break-word;
613 }
614 </style>
615 <div id="parent">
616 <div id="middle"> 593 <div id="middle">
617 <div id="middle1"><div id="inside" class="inside"></div></div> 594 <div id="middle1"><div id="inside" class="inside"></div></div>
618 </div> 595 </div>
619 <div id="sibling"> 596 <div id="sibling">
620 <div id="tohide">to hide \ud83d\ude42!</div> 597 <div id="tohide">to hide \ud83d\ude42!</div>
621 </div> 598 </div>
622 <div id="sibling2"> 599 <div id="sibling2">
623 <div id="sibling21"><div id="sibling211" class="inside">Ad*</div></div> 600 <div id="sibling21"><div id="sibling211" class="inside">Ad*</div></div>
624 </div> 601 </div>
625 <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>
626 <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>
627 <article id="article"><div style="display: none"><div>Spon</div></div></ar ticle>
628 <article id="article2"><div><div>Spon</div></div></article>
629 </div>`; 602 </div>`;
630 let elems = { 603 let elems = {
631 parent: testDocument.getElementById("parent"), 604 parent: testDocument.getElementById("parent"),
632 middle: testDocument.getElementById("middle"), 605 middle: testDocument.getElementById("middle"),
633 inside: testDocument.getElementById("inside"), 606 inside: testDocument.getElementById("inside"),
634 sibling: testDocument.getElementById("sibling"), 607 sibling: testDocument.getElementById("sibling"),
635 sibling2: testDocument.getElementById("sibling2"), 608 sibling2: testDocument.getElementById("sibling2"),
636 toHide: testDocument.getElementById("tohide"), 609 toHide: testDocument.getElementById("tohide")
637 label: testDocument.getElementById("label"),
638 label2: testDocument.getElementById("label2"),
639 article: testDocument.getElementById("article"),
640 article2: testDocument.getElementById("article2")
641 }; 610 };
642 611
643 if (await applyElemHideEmulation(test, [selector])) 612 if (await applyElemHideEmulation(test, [selector]))
644 compareExpectations(test, elems, expectations); 613 compareExpectations(test, elems, expectations);
645 614
646 test.done(); 615 test.done();
647 } 616 }
648 617
649 exports.testPseudoClassContainsText = function(test) 618 exports.testPseudoClassContainsText = function(test)
650 { 619 {
(...skipping 14 matching lines...) Expand all
665 let expectations = { 634 let expectations = {
666 parent: true, 635 parent: true,
667 middle: true, 636 middle: true,
668 inside: true, 637 inside: true,
669 sibling: false, 638 sibling: false,
670 sibling2: true, 639 sibling2: true,
671 toHide: true 640 toHide: true
672 }; 641 };
673 runTestPseudoClassContains( 642 runTestPseudoClassContains(
674 test, "#parent div:-abp-contains(/to\\shide/)", expectations); 643 test, "#parent div:-abp-contains(/to\\shide/)", expectations);
675 };
676
677 exports.testPseudoClassContainsVisibleText = function(test)
678 {
679 let expectations = {
680 parent: true,
681 middle: true,
682 inside: true,
683 sibling: true,
684 sibling2: true,
685 toHide: true,
686 label: false,
687 label2: false,
688 article: true,
689 article2: true
690 };
691 runTestPseudoClassContains(
692 test, "#parent div:-abp-contains-visible(Spon)", expectations);
693 };
694
695 exports.testPseudoClassContainsVisibleTextParentVisibility = function(test)
696 {
697 let expectations = {
698 parent: true,
699 middle: true,
700 inside: true,
701 sibling: true,
702 sibling2: true,
703 toHide: true,
704 label: true,
705 label2: true,
706 article: true,
707 article2: false
708 };
709 runTestPseudoClassContains(
710 test, "article:-abp-contains-visible(Spon)", expectations);
711 }; 644 };
712 645
713 exports.testPseudoClassContainsRegexpIFlag = function(test) 646 exports.testPseudoClassContainsRegexpIFlag = function(test)
714 { 647 {
715 let expectations = { 648 let expectations = {
716 parent: true, 649 parent: true,
717 middle: true, 650 middle: true,
718 inside: true, 651 inside: true,
719 sibling: false, 652 sibling: false,
720 sibling2: true, 653 sibling2: true,
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 { 1123 {
1191 if (element.id == "n2" || element.id == "n2_3") 1124 if (element.id == "n2" || element.id == "n2_3")
1192 expectProcessed(test, element, element.id); 1125 expectProcessed(test, element, element.id);
1193 else 1126 else
1194 expectNotProcessed(test, element, element.id); 1127 expectNotProcessed(test, element, element.id);
1195 } 1128 }
1196 } 1129 }
1197 1130
1198 test.done(); 1131 test.done();
1199 }; 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