| 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 function runTestPseudoClassContains(test, selector, expectations) | 472 function runTestPseudoClassContains(test, selector, expectations) |
| 473 { | 473 { |
| 474 testDocument.body.innerHTML = `<div id="parent"> | 474 testDocument.body.innerHTML = `<div id="parent"> |
| 475 <div id="middle"> | 475 <div id="middle"> |
| 476 <div id="middle1"><div id="inside" class="inside"></div></div> | 476 <div id="middle1"><div id="inside" class="inside"></div></div> |
| 477 </div> | 477 </div> |
| 478 <div id="sibling"> | 478 <div id="sibling"> |
| 479 <div id="tohide">to hide</div> | 479 <div id="tohide">to hide</div> |
| 480 </div> | 480 </div> |
| 481 <div id="sibling2"> | 481 <div id="sibling2"> |
| 482 <div id="sibling21"><div id="sibling211" class="inside"></div></div> | 482 <div id="sibling21"><div id="sibling211" class="inside">Ad*</div></div> |
| 483 </div> | 483 </div> |
| 484 </div>`; | 484 </div>`; |
| 485 let elems = { | 485 let elems = { |
| 486 parent: testDocument.getElementById("parent"), | 486 parent: testDocument.getElementById("parent"), |
| 487 middle: testDocument.getElementById("middle"), | 487 middle: testDocument.getElementById("middle"), |
| 488 inside: testDocument.getElementById("inside"), | 488 inside: testDocument.getElementById("inside"), |
| 489 sibling: testDocument.getElementById("sibling"), | 489 sibling: testDocument.getElementById("sibling"), |
| 490 sibling2: testDocument.getElementById("sibling2"), | 490 sibling2: testDocument.getElementById("sibling2"), |
| 491 toHide: testDocument.getElementById("tohide") | 491 toHide: testDocument.getElementById("tohide") |
| 492 }; | 492 }; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 middle: true, | 533 middle: true, |
| 534 inside: true, | 534 inside: true, |
| 535 sibling: false, | 535 sibling: false, |
| 536 sibling2: true, | 536 sibling2: true, |
| 537 toHide: false | 537 toHide: false |
| 538 }; | 538 }; |
| 539 runTestPseudoClassContains( | 539 runTestPseudoClassContains( |
| 540 test, "#parent div:-abp-contains(/to\\sHide/i)", expectations); | 540 test, "#parent div:-abp-contains(/to\\sHide/i)", expectations); |
| 541 }; | 541 }; |
| 542 | 542 |
| 543 exports.testPseudoClassContainsWildcardNoMatch = function(test) |
| 544 { |
| 545 let expectations = { |
| 546 parent: true, |
| 547 middle: true, |
| 548 inside: true, |
| 549 sibling: true, |
| 550 sibling2: true, |
| 551 toHide: true |
| 552 }; |
| 553 // this filter shouldn't match anything as "*" has no meaning. |
| 554 runTestPseudoClassContains( |
| 555 test, "#parent div:-abp-contains(to *hide)", expectations); |
| 556 }; |
| 557 |
| 558 exports.testPseudoClassContainsWildcardMatch = function(test) |
| 559 { |
| 560 let expectations = { |
| 561 parent: true, |
| 562 middle: true, |
| 563 inside: true, |
| 564 sibling: true, |
| 565 sibling2: false, |
| 566 toHide: true |
| 567 }; |
| 568 runTestPseudoClassContains( |
| 569 test, "#parent div:-abp-contains(Ad*)", expectations); |
| 570 }; |
| 571 |
| 543 exports.testPseudoClassHasSelectorWithPropSelector = function(test) | 572 exports.testPseudoClassHasSelectorWithPropSelector = function(test) |
| 544 { | 573 { |
| 545 let parent = createElementWithStyle("{}"); | 574 let parent = createElementWithStyle("{}"); |
| 546 let child = createElementWithStyle("{background-color: #000}", parent); | 575 let child = createElementWithStyle("{background-color: #000}", parent); |
| 547 applyElemHideEmulation( | 576 applyElemHideEmulation( |
| 548 ["div:-abp-has(:-abp-properties(background-color: rgb(0, 0, 0)))"] | 577 ["div:-abp-has(:-abp-properties(background-color: rgb(0, 0, 0)))"] |
| 549 ).then(() => | 578 ).then(() => |
| 550 { | 579 { |
| 551 expectVisible(test, child); | 580 expectVisible(test, child); |
| 552 expectHidden(test, parent); | 581 expectHidden(test, parent); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 expectVisible(test, child2); | 682 expectVisible(test, child2); |
| 654 return timeout(REFRESH_INTERVAL); | 683 return timeout(REFRESH_INTERVAL); |
| 655 }).then(() => | 684 }).then(() => |
| 656 { | 685 { |
| 657 expectHidden(test, parent); | 686 expectHidden(test, parent); |
| 658 expectVisible(test, child); | 687 expectVisible(test, child); |
| 659 expectHidden(test, sibling); | 688 expectHidden(test, sibling); |
| 660 expectVisible(test, child2); | 689 expectVisible(test, child2); |
| 661 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 690 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
| 662 }; | 691 }; |
| LEFT | RIGHT |