| 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 }; | 481 }; |
| 482 | 482 |
| 483 insertStyleRule(".inside {}"); | 483 insertStyleRule(".inside {}"); |
| 484 | 484 |
| 485 if (await applyElemHideEmulation(test, [selector])) | 485 if (await applyElemHideEmulation(test, [selector])) |
| 486 compareExpectations(test, elems, expectations); | 486 compareExpectations(test, elems, expectations); |
| 487 | 487 |
| 488 test.done(); | 488 test.done(); |
| 489 } | 489 } |
| 490 | 490 |
| 491 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling = async function(t
est) | 491 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling = function(test) |
| 492 { | 492 { |
| 493 let expectations = { | 493 let expectations = { |
| 494 parent: true, | 494 parent: true, |
| 495 middile: true, | 495 middile: true, |
| 496 inside: true, | 496 inside: true, |
| 497 sibling: true, | 497 sibling: true, |
| 498 sibling2: true, | 498 sibling2: true, |
| 499 toHide: false | 499 toHide: false |
| 500 }; | 500 }; |
| 501 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( | 501 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( |
| 502 test, "div:-abp-has(:-abp-has(div.inside)) + div > div", expectations); | 502 test, "div:-abp-has(:-abp-has(div.inside)) + div > div", expectations); |
| 503 }; | 503 }; |
| 504 | 504 |
| 505 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling2 = async function(
test) | 505 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling2 = function(test) |
| 506 { | 506 { |
| 507 let expectations = { | 507 let expectations = { |
| 508 parent: true, | 508 parent: true, |
| 509 middile: true, | 509 middile: true, |
| 510 inside: true, | 510 inside: true, |
| 511 sibling: true, | 511 sibling: true, |
| 512 sibling2: true, | 512 sibling2: true, |
| 513 toHide: false | 513 toHide: false |
| 514 }; | 514 }; |
| 515 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( | 515 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( |
| 516 test, "div:-abp-has(:-abp-has(> div.inside)) + div > div", expectations); | 516 test, "div:-abp-has(:-abp-has(> div.inside)) + div > div", expectations); |
| 517 }; | 517 }; |
| 518 | 518 |
| 519 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling3 = async function(
test) | 519 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling3 = function(test) |
| 520 { | 520 { |
| 521 let expectations = { | 521 let expectations = { |
| 522 parent: true, | 522 parent: true, |
| 523 middile: true, | 523 middile: true, |
| 524 inside: true, | 524 inside: true, |
| 525 sibling: true, | 525 sibling: true, |
| 526 sibling2: true, | 526 sibling2: true, |
| 527 toHide: false | 527 toHide: false |
| 528 }; | 528 }; |
| 529 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( | 529 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( |
| 530 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); |
| 531 }; | 531 }; |
| 532 | 532 |
| 533 exports.testPseudoClassHasSelectorWithSuffixSiblingNoop = async function(test) | 533 exports.testPseudoClassHasSelectorWithSuffixSiblingNoop = function(test) |
| 534 { | 534 { |
| 535 let expectations = { | 535 let expectations = { |
| 536 parent: true, | 536 parent: true, |
| 537 middile: true, | 537 middile: true, |
| 538 inside: true, | 538 inside: true, |
| 539 sibling: true, | 539 sibling: true, |
| 540 sibling2: true, | 540 sibling2: true, |
| 541 toHide: true | 541 toHide: true |
| 542 }; | 542 }; |
| 543 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( | 543 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( |
| 544 test, "div:-abp-has(> body div.inside) + div > div", expectations); | 544 test, "div:-abp-has(> body div.inside) + div > div", expectations); |
| 545 }; | 545 }; |
| 546 | 546 |
| 547 exports.testPseudoClassHasSelectorWithSuffixSiblingContains = async function(tes
t) | 547 exports.testPseudoClassHasSelectorWithSuffixSiblingContains = function(test) |
| 548 { | 548 { |
| 549 let expectations = { | 549 let expectations = { |
| 550 parent: true, | 550 parent: true, |
| 551 middile: true, | 551 middile: true, |
| 552 inside: true, | 552 inside: true, |
| 553 sibling: true, | 553 sibling: true, |
| 554 sibling2: true, | 554 sibling2: true, |
| 555 toHide: true | 555 toHide: true |
| 556 }; | 556 }; |
| 557 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( | 557 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 579 sibling2: testDocument.getElementById("sibling2"), | 579 sibling2: testDocument.getElementById("sibling2"), |
| 580 toHide: testDocument.getElementById("tohide") | 580 toHide: testDocument.getElementById("tohide") |
| 581 }; | 581 }; |
| 582 | 582 |
| 583 if (await applyElemHideEmulation(test, [selector])) | 583 if (await applyElemHideEmulation(test, [selector])) |
| 584 compareExpectations(test, elems, expectations); | 584 compareExpectations(test, elems, expectations); |
| 585 | 585 |
| 586 test.done(); | 586 test.done(); |
| 587 } | 587 } |
| 588 | 588 |
| 589 exports.testPseudoClassContainsText = async function(test) | 589 exports.testPseudoClassContainsText = function(test) |
| 590 { | 590 { |
| 591 let expectations = { | 591 let expectations = { |
| 592 parent: true, | 592 parent: true, |
| 593 middle: true, | 593 middle: true, |
| 594 inside: true, | 594 inside: true, |
| 595 sibling: false, | 595 sibling: false, |
| 596 sibling2: true, | 596 sibling2: true, |
| 597 toHide: true | 597 toHide: true |
| 598 }; | 598 }; |
| 599 runTestPseudoClassContains( | 599 runTestPseudoClassContains( |
| 600 test, "#parent div:-abp-contains(to hide)", expectations); | 600 test, "#parent div:-abp-contains(to hide)", expectations); |
| 601 }; | 601 }; |
| 602 | 602 |
| 603 exports.testPseudoClassContainsRegexp = async function(test) | 603 exports.testPseudoClassContainsRegexp = function(test) |
| 604 { | 604 { |
| 605 let expectations = { | 605 let expectations = { |
| 606 parent: true, | 606 parent: true, |
| 607 middle: true, | 607 middle: true, |
| 608 inside: true, | 608 inside: true, |
| 609 sibling: false, | 609 sibling: false, |
| 610 sibling2: true, | 610 sibling2: true, |
| 611 toHide: true | 611 toHide: true |
| 612 }; | 612 }; |
| 613 runTestPseudoClassContains( | 613 runTestPseudoClassContains( |
| 614 test, "#parent div:-abp-contains(/to\\shide/)", expectations); | 614 test, "#parent div:-abp-contains(/to\\shide/)", expectations); |
| 615 }; | 615 }; |
| 616 | 616 |
| 617 exports.testPseudoClassContainsRegexpIFlag = async function(test) | 617 exports.testPseudoClassContainsRegexpIFlag = function(test) |
| 618 { | 618 { |
| 619 let expectations = { | 619 let expectations = { |
| 620 parent: true, | 620 parent: true, |
| 621 middle: true, | 621 middle: true, |
| 622 inside: true, | 622 inside: true, |
| 623 sibling: false, | 623 sibling: false, |
| 624 sibling2: true, | 624 sibling2: true, |
| 625 toHide: true | 625 toHide: true |
| 626 }; | 626 }; |
| 627 runTestPseudoClassContains( | 627 runTestPseudoClassContains( |
| 628 test, "#parent div:-abp-contains(/to\\sHide/i)", expectations); | 628 test, "#parent div:-abp-contains(/to\\sHide/i)", expectations); |
| 629 }; | 629 }; |
| 630 | 630 |
| 631 exports.testPseudoClassContainsRegexpUFlag = async function(test) | 631 exports.testPseudoClassContainsRegexpUFlag = function(test) |
| 632 { | 632 { |
| 633 let expectations = { | 633 let expectations = { |
| 634 parent: true, | 634 parent: true, |
| 635 middle: true, | 635 middle: true, |
| 636 inside: true, | 636 inside: true, |
| 637 sibling: false, | 637 sibling: false, |
| 638 sibling2: true, | 638 sibling2: true, |
| 639 toHide: true | 639 toHide: true |
| 640 }; | 640 }; |
| 641 runTestPseudoClassContains( | 641 runTestPseudoClassContains( |
| 642 test, "#parent div:-abp-contains(/to\\shide\\s.!/u)", expectations); | 642 test, "#parent div:-abp-contains(/to\\shide\\s.!/u)", expectations); |
| 643 }; | 643 }; |
| 644 | 644 |
| 645 exports.testPseudoClassContainsWildcardNoMatch = async function(test) | 645 exports.testPseudoClassContainsWildcardNoMatch = function(test) |
| 646 { | 646 { |
| 647 let expectations = { | 647 let expectations = { |
| 648 parent: true, | 648 parent: true, |
| 649 middle: true, | 649 middle: true, |
| 650 inside: true, | 650 inside: true, |
| 651 sibling: true, | 651 sibling: true, |
| 652 sibling2: true, | 652 sibling2: true, |
| 653 toHide: true | 653 toHide: true |
| 654 }; | 654 }; |
| 655 // this filter shouldn't match anything as "*" has no meaning. | 655 // this filter shouldn't match anything as "*" has no meaning. |
| 656 runTestPseudoClassContains( | 656 runTestPseudoClassContains( |
| 657 test, "#parent div:-abp-contains(to *hide)", expectations); | 657 test, "#parent div:-abp-contains(to *hide)", expectations); |
| 658 }; | 658 }; |
| 659 | 659 |
| 660 exports.testPseudoClassContainsWildcardMatch = async function(test) | 660 exports.testPseudoClassContainsWildcardMatch = function(test) |
| 661 { | 661 { |
| 662 let expectations = { | 662 let expectations = { |
| 663 parent: true, | 663 parent: true, |
| 664 middle: true, | 664 middle: true, |
| 665 inside: true, | 665 inside: true, |
| 666 sibling: true, | 666 sibling: true, |
| 667 sibling2: false, | 667 sibling2: false, |
| 668 toHide: true | 668 toHide: true |
| 669 }; | 669 }; |
| 670 runTestPseudoClassContains( | 670 runTestPseudoClassContains( |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 { | 1094 { |
| 1095 if (element.id == "n2" || element.id == "n2_3") | 1095 if (element.id == "n2" || element.id == "n2_3") |
| 1096 expectProcessed(test, element, element.id); | 1096 expectProcessed(test, element, element.id); |
| 1097 else | 1097 else |
| 1098 expectNotProcessed(test, element, element.id); | 1098 expectNotProcessed(test, element, element.id); |
| 1099 } | 1099 } |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 test.done(); | 1102 test.done(); |
| 1103 }; | 1103 }; |
| LEFT | RIGHT |