| OLD | NEW |
| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 ["div:-abp-has(div) + div > div"] | 360 ["div:-abp-has(div) + div > div"] |
| 361 ).then(() => | 361 ).then(() => |
| 362 { | 362 { |
| 363 expectVisible(test, parent); | 363 expectVisible(test, parent); |
| 364 expectVisible(test, middle); | 364 expectVisible(test, middle); |
| 365 expectVisible(test, sibling); | 365 expectVisible(test, sibling); |
| 366 expectHidden(test, toHide); | 366 expectHidden(test, toHide); |
| 367 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 367 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
| 368 }; | 368 }; |
| 369 | 369 |
| 370 function runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(test, selector
) | 370 function runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(test, selector
, expectation) |
| 371 { | 371 { |
| 372 document.body.innerHTML = `<div id="parent"> | 372 document.body.innerHTML = `<div id="parent"> |
| 373 <div id="middle"> | 373 <div id="middle"> |
| 374 <div id="middle1"><div id="inside" class="inside"></div></div> | 374 <div id="middle1"><div id="inside" class="inside"></div></div> |
| 375 </div> | 375 </div> |
| 376 <div id="sibling"> | 376 <div id="sibling"> |
| 377 <div id="tohide">to hide</div> | 377 <div id="tohide">to hide</div> |
| 378 </div> | 378 </div> |
| 379 <div id="sibling2"> | 379 <div id="sibling2"> |
| 380 <div id="sibling21"><div id="sibling211" class="inside"></div></div> | 380 <div id="sibling21"><div id="sibling211" class="inside"></div></div> |
| 381 </div> | 381 </div> |
| 382 </div>`; | 382 </div>`; |
| 383 let parent = document.getElementById("parent"); | 383 let elems = {}; |
| 384 let middle = document.getElementById("middle"); | 384 elems.parent = document.getElementById("parent"); |
| 385 let inside = document.getElementById("inside"); | 385 elems.middle = document.getElementById("middle"); |
| 386 let sibling = document.getElementById("sibling"); | 386 elems.inside = document.getElementById("inside"); |
| 387 let sibling2 = document.getElementById("sibling2"); | 387 elems.sibling = document.getElementById("sibling"); |
| 388 let toHide = document.getElementById("tohide"); | 388 elems.sibling2 = document.getElementById("sibling2"); |
| 389 elems.toHide = document.getElementById("tohide"); |
| 389 | 390 |
| 390 insertStyleRule(".inside {}"); | 391 insertStyleRule(".inside {}"); |
| 391 | 392 |
| 392 applyElemHideEmulation( | 393 applyElemHideEmulation( |
| 393 [selector] | 394 [selector] |
| 394 ).then(() => | 395 ).then(() => |
| 395 { | 396 { |
| 396 expectVisible(test, parent); | 397 if (typeof expectation == "function") |
| 397 expectVisible(test, middle); | 398 return expectation(elems); |
| 398 expectVisible(test, inside); | 399 |
| 399 expectVisible(test, sibling); | 400 expectVisible(test, elems.parent); |
| 400 expectVisible(test, sibling2); | 401 expectVisible(test, elems.middle); |
| 401 expectHidden(test, toHide); | 402 expectVisible(test, elems.inside); |
| 403 expectVisible(test, elems.sibling); |
| 404 expectVisible(test, elems.sibling2); |
| 405 expectHidden(test, elems.toHide); |
| 402 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 406 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
| 403 } | 407 } |
| 404 | 408 |
| 405 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling = function(test) | 409 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling = function(test) |
| 406 { | 410 { |
| 407 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(test, "div:-abp-has(:
-abp-has(div.inside)) + div > div"); | 411 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(test, "div:-abp-has(:
-abp-has(div.inside)) + div > div"); |
| 408 }; | 412 }; |
| 409 | 413 |
| 414 exports.testPseudoClassHasSelectorWithHasAndWithSuffixSibling2 = function(test) |
| 415 { |
| 416 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( |
| 417 test, "div:-abp-has(:-abp-has(> div.inside)) + div > div"); |
| 418 }; |
| 419 |
| 420 exports.testPseudoClassHasSelectorWithSuffixSiblingNoop = function(test) |
| 421 { |
| 422 runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling( |
| 423 test, "div:-abp-has(> body div.inside) + div > div", (elems) => |
| 424 { |
| 425 expectVisible(test, elems.parent); |
| 426 expectVisible(test, elems.middle); |
| 427 expectVisible(test, elems.inside); |
| 428 expectVisible(test, elems.sibling); |
| 429 expectVisible(test, elems.sibling2); |
| 430 expectVisible(test, elems.toHide); |
| 431 }); |
| 432 }; |
| 433 |
| 410 exports.testPseudoClassContains = function(test) | 434 exports.testPseudoClassContains = function(test) |
| 411 { | 435 { |
| 412 document.body.innerHTML = `<div id="parent"> | 436 document.body.innerHTML = `<div id="parent"> |
| 413 <div id="middle"> | 437 <div id="middle"> |
| 414 <div id="middle1"><div id="inside" class="inside"></div></div> | 438 <div id="middle1"><div id="inside" class="inside"></div></div> |
| 415 </div> | 439 </div> |
| 416 <div id="sibling"> | 440 <div id="sibling"> |
| 417 <div id="tohide">to hide</div> | 441 <div id="tohide">to hide</div> |
| 418 </div> | 442 </div> |
| 419 <div id="sibling2"> | 443 <div id="sibling2"> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 let child = createElementWithStyle("{}", parent); | 483 let child = createElementWithStyle("{}", parent); |
| 460 insertStyleRule("body #" + parent.id + " > div { background-color: #000}"); | 484 insertStyleRule("body #" + parent.id + " > div { background-color: #000}"); |
| 461 applyElemHideEmulation( | 485 applyElemHideEmulation( |
| 462 ["div:-abp-has(:-abp-properties(background-color: rgb(0, 0, 0)))"] | 486 ["div:-abp-has(:-abp-properties(background-color: rgb(0, 0, 0)))"] |
| 463 ).then(() => | 487 ).then(() => |
| 464 { | 488 { |
| 465 expectVisible(test, child); | 489 expectVisible(test, child); |
| 466 expectHidden(test, parent); | 490 expectHidden(test, parent); |
| 467 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 491 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
| 468 }; | 492 }; |
| OLD | NEW |