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

Side by Side Diff: test/browser/elemHideEmulation.js

Issue 30024560: Issue 7450 - Implement hide-if-contains-visible-text snippet (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created March 6, 2019, 3:21 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 sibling: true, 531 sibling: true,
532 sibling2: true, 532 sibling2: true,
533 toHide: true 533 toHide: true
534 }; 534 };
535 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( 535 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(
536 test, "div:-abp-has(> span:-abp-contains(Advertisment))", expectations); 536 test, "div:-abp-has(> span:-abp-contains(Advertisment))", expectations);
537 }; 537 };
538 538
539 async function runTestPseudoClassContains(test, selector, expectations) 539 async function runTestPseudoClassContains(test, selector, expectations)
540 { 540 {
541 testDocument.body.innerHTML = `<div id="parent"> 541 testDocument.body.innerHTML = ` <style type="text/css">
542 body {
543 margin: 0;
544 padding: 0;
545 }
546 .transparent {
547 opacity: 0;
548 position: absolute;
549 display: block;
550 }
551 .zerosize {
552 font-size: 0;
553 }
554 div {
555 display: block;
556 }
557 .a {
558 display: inline-block;
559 white-space: pre-wrap;
560 }
561 .disp_none {
562 display: none;
563 }
564 .vis_hid {
565 visibility: hidden;
566 }
567 .vis_collapse {
568 visibility: collapse;
569 }
570 .same_colour {
571 color: rgb(255,255,255);
572 background-color: rgb(255,255,255);
573 }
574 #label {
575 overflow-wrap: break-word;
576 }
577 </style>
578 <div id="parent">
542 <div id="middle"> 579 <div id="middle">
543 <div id="middle1"><div id="inside" class="inside"></div></div> 580 <div id="middle1"><div id="inside" class="inside"></div></div>
544 </div> 581 </div>
545 <div id="sibling"> 582 <div id="sibling">
546 <div id="tohide">to hide \ud83d\ude42!</div> 583 <div id="tohide">to hide \ud83d\ude42!</div>
547 </div> 584 </div>
548 <div id="sibling2"> 585 <div id="sibling2">
549 <div id="sibling21"><div id="sibling211" class="inside">Ad*</div></div> 586 <div id="sibling21"><div id="sibling211" class="inside">Ad*</div></div>
550 </div> 587 </div>
588 <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>
589 <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>
551 </div>`; 590 </div>`;
552 let elems = { 591 let elems = {
553 parent: testDocument.getElementById("parent"), 592 parent: testDocument.getElementById("parent"),
554 middle: testDocument.getElementById("middle"), 593 middle: testDocument.getElementById("middle"),
555 inside: testDocument.getElementById("inside"), 594 inside: testDocument.getElementById("inside"),
556 sibling: testDocument.getElementById("sibling"), 595 sibling: testDocument.getElementById("sibling"),
557 sibling2: testDocument.getElementById("sibling2"), 596 sibling2: testDocument.getElementById("sibling2"),
558 toHide: testDocument.getElementById("tohide") 597 toHide: testDocument.getElementById("tohide"),
598 label: testDocument.getElementById("label"),
599 label2: testDocument.getElementById("label2")
559 }; 600 };
560 601
561 if (await applyElemHideEmulation(test, [selector])) 602 if (await applyElemHideEmulation(test, [selector]))
562 compareExpectations(test, elems, expectations); 603 compareExpectations(test, elems, expectations);
563 604
564 test.done(); 605 test.done();
565 } 606 }
566 607
567 exports.testPseudoClassContainsText = function(test) 608 exports.testPseudoClassContainsText = function(test)
568 { 609 {
(...skipping 16 matching lines...) Expand all
585 middle: true, 626 middle: true,
586 inside: true, 627 inside: true,
587 sibling: false, 628 sibling: false,
588 sibling2: true, 629 sibling2: true,
589 toHide: true 630 toHide: true
590 }; 631 };
591 runTestPseudoClassContains( 632 runTestPseudoClassContains(
592 test, "#parent div:-abp-contains(/to\\shide/)", expectations); 633 test, "#parent div:-abp-contains(/to\\shide/)", expectations);
593 }; 634 };
594 635
636 exports.testPseudoClassContainsVisibleText = function(test)
637 {
638 let expectations = {
639 parent: true,
640 middle: true,
641 inside: true,
642 sibling: true,
643 sibling2: true,
644 toHide: true,
645 label: false,
646 label2: false
647 };
648 runTestPseudoClassContains(
649 test, "#parent div:-abp-contains-visible(Spon)", expectations);
650 };
651
595 exports.testPseudoClassContainsRegexpIFlag = function(test) 652 exports.testPseudoClassContainsRegexpIFlag = function(test)
596 { 653 {
597 let expectations = { 654 let expectations = {
598 parent: true, 655 parent: true,
599 middle: true, 656 middle: true,
600 inside: true, 657 inside: true,
601 sibling: false, 658 sibling: false,
602 sibling2: true, 659 sibling2: true,
603 toHide: true 660 toHide: true
604 }; 661 };
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 { 1129 {
1073 if (element.id == "n2" || element.id == "n2_3") 1130 if (element.id == "n2" || element.id == "n2_3")
1074 expectProcessed(test, element, element.id); 1131 expectProcessed(test, element, element.id);
1075 else 1132 else
1076 expectNotProcessed(test, element, element.id); 1133 expectNotProcessed(test, element, element.id);
1077 } 1134 }
1078 } 1135 }
1079 1136
1080 test.done(); 1137 test.done();
1081 }; 1138 };
OLDNEW
« lib/content/elemHideEmulation.js ('K') | « lib/content/elemHideEmulation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld