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

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

Issue 29984555: Issue 6959 - Use async/await in test/browser/elemHideEmulation.js (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Define separate selectors variable Created Jan. 17, 2019, 7:54 a.m.
Right Patch Set: Remove unnecessary async qualifiers Created Jan. 17, 2019, 8 a.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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 let element = createElement(parent); 145 let element = createElement(parent);
146 insertStyleRule("#" + element.id + " " + styleBlock); 146 insertStyleRule("#" + element.id + " " + styleBlock);
147 return element; 147 return element;
148 } 148 }
149 149
150 // Create a new ElemHideEmulation instance with @selectors. 150 // Create a new ElemHideEmulation instance with @selectors.
151 async function applyElemHideEmulation(test, selectors) 151 async function applyElemHideEmulation(test, selectors)
152 { 152 {
153 await Promise.resolve(); 153 await Promise.resolve();
154 154
155 let elemHideEmulation = null;
156
157 try 155 try
158 { 156 {
159 elemHideEmulation = new ElemHideEmulation( 157 let elemHideEmulation = new ElemHideEmulation(
160 elems => 158 elems =>
161 { 159 {
162 for (let elem of elems) 160 for (let elem of elems)
163 elem.style.display = "none"; 161 elem.style.display = "none";
164 } 162 }
165 ); 163 );
166 164
167 elemHideEmulation.document = testDocument; 165 elemHideEmulation.document = testDocument;
168 elemHideEmulation.MIN_INVOCATION_INTERVAL = REFRESH_INTERVAL / 2; 166 elemHideEmulation.MIN_INVOCATION_INTERVAL = REFRESH_INTERVAL / 2;
169 elemHideEmulation.apply(selectors.map( 167 elemHideEmulation.apply(selectors.map(
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 }; 481 };
484 482
485 insertStyleRule(".inside {}"); 483 insertStyleRule(".inside {}");
486 484
487 if (await applyElemHideEmulation(test, [selector])) 485 if (await applyElemHideEmulation(test, [selector]))
488 compareExpectations(test, elems, expectations); 486 compareExpectations(test, elems, expectations);
489 487
490 test.done(); 488 test.done();
491 } 489 }
492 490
493 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling = async function(t est) 491 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling = function(test)
494 { 492 {
495 let expectations = { 493 let expectations = {
496 parent: true, 494 parent: true,
497 middile: true, 495 middile: true,
498 inside: true, 496 inside: true,
499 sibling: true, 497 sibling: true,
500 sibling2: true, 498 sibling2: true,
501 toHide: false 499 toHide: false
502 }; 500 };
503 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( 501 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(
504 test, "div:-abp-has(:-abp-has(div.inside)) + div > div", expectations); 502 test, "div:-abp-has(:-abp-has(div.inside)) + div > div", expectations);
505 }; 503 };
506 504
507 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling2 = async function( test) 505 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling2 = function(test)
508 { 506 {
509 let expectations = { 507 let expectations = {
510 parent: true, 508 parent: true,
511 middile: true, 509 middile: true,
512 inside: true, 510 inside: true,
513 sibling: true, 511 sibling: true,
514 sibling2: true, 512 sibling2: true,
515 toHide: false 513 toHide: false
516 }; 514 };
517 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( 515 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(
518 test, "div:-abp-has(:-abp-has(> div.inside)) + div > div", expectations); 516 test, "div:-abp-has(:-abp-has(> div.inside)) + div > div", expectations);
519 }; 517 };
520 518
521 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling3 = async function( test) 519 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling3 = function(test)
522 { 520 {
523 let expectations = { 521 let expectations = {
524 parent: true, 522 parent: true,
525 middile: true, 523 middile: true,
526 inside: true, 524 inside: true,
527 sibling: true, 525 sibling: true,
528 sibling2: true, 526 sibling2: true,
529 toHide: false 527 toHide: false
530 }; 528 };
531 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( 529 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(
532 test, "div:-abp-has(> div:-abp-has(div.inside)) + div > div", expectations); 530 test, "div:-abp-has(> div:-abp-has(div.inside)) + div > div", expectations);
533 }; 531 };
534 532
535 exports.testPseudoClassHasSelectorWithSuffixSiblingNoop = async function(test) 533 exports.testPseudoClassHasSelectorWithSuffixSiblingNoop = function(test)
536 { 534 {
537 let expectations = { 535 let expectations = {
538 parent: true, 536 parent: true,
539 middile: true, 537 middile: true,
540 inside: true, 538 inside: true,
541 sibling: true, 539 sibling: true,
542 sibling2: true, 540 sibling2: true,
543 toHide: true 541 toHide: true
544 }; 542 };
545 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( 543 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(
546 test, "div:-abp-has(> body div.inside) + div > div", expectations); 544 test, "div:-abp-has(> body div.inside) + div > div", expectations);
547 }; 545 };
548 546
549 exports.testPseudoClassHasSelectorWithSuffixSiblingContains = async function(tes t) 547 exports.testPseudoClassHasSelectorWithSuffixSiblingContains = function(test)
550 { 548 {
551 let expectations = { 549 let expectations = {
552 parent: true, 550 parent: true,
553 middile: true, 551 middile: true,
554 inside: true, 552 inside: true,
555 sibling: true, 553 sibling: true,
556 sibling2: true, 554 sibling2: true,
557 toHide: true 555 toHide: true
558 }; 556 };
559 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( 557 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(
(...skipping 21 matching lines...) Expand all
581 sibling2: testDocument.getElementById("sibling2"), 579 sibling2: testDocument.getElementById("sibling2"),
582 toHide: testDocument.getElementById("tohide") 580 toHide: testDocument.getElementById("tohide")
583 }; 581 };
584 582
585 if (await applyElemHideEmulation(test, [selector])) 583 if (await applyElemHideEmulation(test, [selector]))
586 compareExpectations(test, elems, expectations); 584 compareExpectations(test, elems, expectations);
587 585
588 test.done(); 586 test.done();
589 } 587 }
590 588
591 exports.testPseudoClassContainsText = async function(test) 589 exports.testPseudoClassContainsText = function(test)
592 { 590 {
593 let expectations = { 591 let expectations = {
594 parent: true, 592 parent: true,
595 middle: true, 593 middle: true,
596 inside: true, 594 inside: true,
597 sibling: false, 595 sibling: false,
598 sibling2: true, 596 sibling2: true,
599 toHide: true 597 toHide: true
600 }; 598 };
601 runTestPseudoClassContains( 599 runTestPseudoClassContains(
602 test, "#parent div:-abp-contains(to hide)", expectations); 600 test, "#parent div:-abp-contains(to hide)", expectations);
603 }; 601 };
604 602
605 exports.testPseudoClassContainsRegexp = async function(test) 603 exports.testPseudoClassContainsRegexp = function(test)
606 { 604 {
607 let expectations = { 605 let expectations = {
608 parent: true, 606 parent: true,
609 middle: true, 607 middle: true,
610 inside: true, 608 inside: true,
611 sibling: false, 609 sibling: false,
612 sibling2: true, 610 sibling2: true,
613 toHide: true 611 toHide: true
614 }; 612 };
615 runTestPseudoClassContains( 613 runTestPseudoClassContains(
616 test, "#parent div:-abp-contains(/to\\shide/)", expectations); 614 test, "#parent div:-abp-contains(/to\\shide/)", expectations);
617 }; 615 };
618 616
619 exports.testPseudoClassContainsRegexpIFlag = async function(test) 617 exports.testPseudoClassContainsRegexpIFlag = function(test)
620 { 618 {
621 let expectations = { 619 let expectations = {
622 parent: true, 620 parent: true,
623 middle: true, 621 middle: true,
624 inside: true, 622 inside: true,
625 sibling: false, 623 sibling: false,
626 sibling2: true, 624 sibling2: true,
627 toHide: true 625 toHide: true
628 }; 626 };
629 runTestPseudoClassContains( 627 runTestPseudoClassContains(
630 test, "#parent div:-abp-contains(/to\\sHide/i)", expectations); 628 test, "#parent div:-abp-contains(/to\\sHide/i)", expectations);
631 }; 629 };
632 630
633 exports.testPseudoClassContainsRegexpUFlag = async function(test) 631 exports.testPseudoClassContainsRegexpUFlag = function(test)
634 { 632 {
635 let expectations = { 633 let expectations = {
636 parent: true, 634 parent: true,
637 middle: true, 635 middle: true,
638 inside: true, 636 inside: true,
639 sibling: false, 637 sibling: false,
640 sibling2: true, 638 sibling2: true,
641 toHide: true 639 toHide: true
642 }; 640 };
643 runTestPseudoClassContains( 641 runTestPseudoClassContains(
644 test, "#parent div:-abp-contains(/to\\shide\\s.!/u)", expectations); 642 test, "#parent div:-abp-contains(/to\\shide\\s.!/u)", expectations);
645 }; 643 };
646 644
647 exports.testPseudoClassContainsWildcardNoMatch = async function(test) 645 exports.testPseudoClassContainsWildcardNoMatch = function(test)
648 { 646 {
649 let expectations = { 647 let expectations = {
650 parent: true, 648 parent: true,
651 middle: true, 649 middle: true,
652 inside: true, 650 inside: true,
653 sibling: true, 651 sibling: true,
654 sibling2: true, 652 sibling2: true,
655 toHide: true 653 toHide: true
656 }; 654 };
657 // this filter shouldn't match anything as "*" has no meaning. 655 // this filter shouldn't match anything as "*" has no meaning.
658 runTestPseudoClassContains( 656 runTestPseudoClassContains(
659 test, "#parent div:-abp-contains(to *hide)", expectations); 657 test, "#parent div:-abp-contains(to *hide)", expectations);
660 }; 658 };
661 659
662 exports.testPseudoClassContainsWildcardMatch = async function(test) 660 exports.testPseudoClassContainsWildcardMatch = function(test)
663 { 661 {
664 let expectations = { 662 let expectations = {
665 parent: true, 663 parent: true,
666 middle: true, 664 middle: true,
667 inside: true, 665 inside: true,
668 sibling: true, 666 sibling: true,
669 sibling2: false, 667 sibling2: false,
670 toHide: true 668 toHide: true
671 }; 669 };
672 runTestPseudoClassContains( 670 runTestPseudoClassContains(
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 { 1094 {
1097 if (element.id == "n2" || element.id == "n2_3") 1095 if (element.id == "n2" || element.id == "n2_3")
1098 expectProcessed(test, element, element.id); 1096 expectProcessed(test, element, element.id);
1099 else 1097 else
1100 expectNotProcessed(test, element, element.id); 1098 expectNotProcessed(test, element, element.id);
1101 } 1099 }
1102 } 1100 }
1103 1101
1104 test.done(); 1102 test.done();
1105 }; 1103 };
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