Left: | ||
Right: |
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 let selector = newSelectors.join(", "); | 126 let selector = newSelectors.join(", "); |
127 insertStyleRule(selector + "{display: none !important;}"); | 127 insertStyleRule(selector + "{display: none !important;}"); |
128 }, | 128 }, |
129 elems => | 129 elems => |
130 { | 130 { |
131 for (let elem of elems) | 131 for (let elem of elems) |
132 elem.style.display = "none"; | 132 elem.style.display = "none"; |
133 } | 133 } |
134 ); | 134 ); |
135 | 135 |
136 elemHideEmulation._invocationInterval = 100; | 136 elemHideEmulation.MIN_INVOCATION_INTERVAL = REFRESH_INTERVAL / 2; |
Wladimir Palant
2017/08/25 07:44:59
REFRESH_INTERVAL / 2?
hub
2017/08/25 13:48:13
Done.
| |
137 elemHideEmulation.apply(); | 137 elemHideEmulation.apply(); |
138 return elemHideEmulation; | 138 return elemHideEmulation; |
139 }); | 139 }); |
140 } | 140 } |
141 | 141 |
142 exports.testVerbatimPropertySelector = function(test) | 142 exports.testVerbatimPropertySelector = function(test) |
143 { | 143 { |
144 let toHide = createElementWithStyle("{background-color: #000}"); | 144 let toHide = createElementWithStyle("{background-color: #000}"); |
145 applyElemHideEmulation( | 145 applyElemHideEmulation( |
146 [":-abp-properties(background-color: rgb(0, 0, 0))"] | 146 [":-abp-properties(background-color: rgb(0, 0, 0))"] |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 exports.testDynamicallyChangedProperty = function(test) | 251 exports.testDynamicallyChangedProperty = function(test) |
252 { | 252 { |
253 let toHide = createElementWithStyle("{}"); | 253 let toHide = createElementWithStyle("{}"); |
254 applyElemHideEmulation( | 254 applyElemHideEmulation( |
255 [":-abp-properties(background-color: rgb(0, 0, 0))"] | 255 [":-abp-properties(background-color: rgb(0, 0, 0))"] |
256 ).then(() => | 256 ).then(() => |
257 { | 257 { |
258 expectVisible(test, toHide); | 258 expectVisible(test, toHide); |
259 insertStyleRule("#" + toHide.id + " {background-color: #000}"); | 259 insertStyleRule("#" + toHide.id + " {background-color: #000}"); |
260 | 260 |
261 // Re-evaluation will only happen after a few seconds | 261 return timeout(0); |
Wladimir Palant
2017/08/25 07:44:59
"after hundred milliseconds" or just "after a dela
hub
2017/08/25 13:48:12
Done.
| |
262 }).then(() => | |
263 { | |
264 // Re-evaluation will only happen after a delay | |
262 expectVisible(test, toHide); | 265 expectVisible(test, toHide); |
Wladimir Palant
2017/08/25 07:44:59
Testing for synchronous changes here and below is
hub
2017/08/25 13:48:14
Done.
Wladimir Palant
2017/08/25 20:57:40
You only fixed one instance of this issue. I noted
| |
263 return timeout(REFRESH_INTERVAL); | 266 return timeout(REFRESH_INTERVAL); |
264 }).then(() => | 267 }).then(() => |
265 { | 268 { |
266 expectHidden(test, toHide); | 269 expectHidden(test, toHide); |
267 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 270 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
268 }; | 271 }; |
269 | 272 |
270 exports.testPseudoClassWithPropBeforeSelector = function(test) | 273 exports.testPseudoClassWithPropBeforeSelector = function(test) |
271 { | 274 { |
272 let parent = createElementWithStyle("{}"); | 275 let parent = createElementWithStyle("{}"); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
505 let parent = createElementWithStyle("{}"); | 508 let parent = createElementWithStyle("{}"); |
506 let child = createElementWithStyle("{}", parent); | 509 let child = createElementWithStyle("{}", parent); |
507 applyElemHideEmulation( | 510 applyElemHideEmulation( |
508 ["div:-abp-has(:-abp-properties(background-color: rgb(0, 0, 0)))"] | 511 ["div:-abp-has(:-abp-properties(background-color: rgb(0, 0, 0)))"] |
509 ).then(() => | 512 ).then(() => |
510 { | 513 { |
511 expectVisible(test, child); | 514 expectVisible(test, child); |
512 expectVisible(test, parent); | 515 expectVisible(test, parent); |
513 | 516 |
514 insertStyleRule("body #" + parent.id + " > div { background-color: #000}"); | 517 insertStyleRule("body #" + parent.id + " > div { background-color: #000}"); |
515 | 518 return timeout(0); |
519 }).then(() => | |
520 { | |
516 expectVisible(test, child); | 521 expectVisible(test, child); |
517 expectVisible(test, parent); | 522 expectVisible(test, parent); |
518 return timeout(REFRESH_INTERVAL); | 523 return timeout(REFRESH_INTERVAL); |
519 }).then(() => | 524 }).then(() => |
520 { | 525 { |
521 expectVisible(test, child); | 526 expectVisible(test, child); |
522 expectHidden(test, parent); | 527 expectHidden(test, parent); |
523 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 528 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
524 }; | 529 }; |
525 | 530 |
526 exports.testDomUpdatesContent = function(test) | 531 exports.testDomUpdatesContent = function(test) |
527 { | 532 { |
528 let parent = createElementWithStyle("{}"); | 533 let parent = createElementWithStyle("{}"); |
529 let child = createElementWithStyle("{}", parent); | 534 let child = createElementWithStyle("{}", parent); |
530 applyElemHideEmulation( | 535 applyElemHideEmulation( |
531 ["div > div:-abp-contains(hide me)"] | 536 ["div > div:-abp-contains(hide me)"] |
532 ).then(() => | 537 ).then(() => |
533 { | 538 { |
534 expectVisible(test, parent); | 539 expectVisible(test, parent); |
535 expectVisible(test, child); | 540 expectVisible(test, child); |
536 | 541 |
537 child.textContent = "hide me"; | 542 child.textContent = "hide me"; |
538 | 543 return timeout(0); |
544 }).then(() => | |
545 { | |
539 expectVisible(test, parent); | 546 expectVisible(test, parent); |
540 expectVisible(test, child); | 547 expectVisible(test, child); |
541 return timeout(REFRESH_INTERVAL); | 548 return timeout(REFRESH_INTERVAL); |
542 }).then(() => | 549 }).then(() => |
543 { | 550 { |
544 expectVisible(test, parent); | 551 expectVisible(test, parent); |
545 expectHidden(test, child); | 552 expectHidden(test, child); |
546 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 553 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
547 }; | 554 }; |
548 | 555 |
549 exports.testDomUpdatesNewElement = function(test) | 556 exports.testDomUpdatesNewElement = function(test) |
550 { | 557 { |
551 let parent = createElementWithStyle("{}"); | 558 let parent = createElementWithStyle("{}"); |
552 let child = createElementWithStyle("{ background-color: #000}", parent); | 559 let child = createElementWithStyle("{ background-color: #000}", parent); |
553 let sibling; | 560 let sibling; |
554 let child2; | 561 let child2; |
555 applyElemHideEmulation( | 562 applyElemHideEmulation( |
556 ["div:-abp-has(:-abp-properties(background-color: rgb(0, 0, 0)))"] | 563 ["div:-abp-has(:-abp-properties(background-color: rgb(0, 0, 0)))"] |
557 ).then(() => | 564 ).then(() => |
558 { | 565 { |
559 expectHidden(test, parent); | 566 expectHidden(test, parent); |
560 expectVisible(test, child); | 567 expectVisible(test, child); |
561 | 568 |
562 sibling = createElementWithStyle("{}"); | 569 sibling = createElementWithStyle("{}"); |
563 expectVisible(test, sibling); | 570 return timeout(0); |
564 | 571 }).then(() => |
Wladimir Palant
2017/08/25 07:44:59
I guess the two lines above should be removed? You
hub
2017/08/25 13:48:14
Done.
| |
572 { | |
565 expectHidden(test, parent); | 573 expectHidden(test, parent); |
566 expectVisible(test, child); | 574 expectVisible(test, child); |
567 expectVisible(test, sibling); | 575 expectVisible(test, sibling); |
568 | 576 |
569 return timeout(REFRESH_INTERVAL); | 577 return timeout(REFRESH_INTERVAL); |
570 }).then(() => | 578 }).then(() => |
571 { | 579 { |
572 expectHidden(test, parent); | 580 expectHidden(test, parent); |
573 expectVisible(test, child); | 581 expectVisible(test, child); |
574 expectVisible(test, sibling); | 582 expectVisible(test, sibling); |
575 | 583 |
576 child2 = createElementWithStyle("{ background-color: #000}", | 584 child2 = createElementWithStyle("{ background-color: #000}", |
577 sibling); | 585 sibling); |
586 return timeout(0); | |
587 }).then(() => | |
588 { | |
578 expectVisible(test, child2); | 589 expectVisible(test, child2); |
579 return timeout(REFRESH_INTERVAL); | 590 return timeout(REFRESH_INTERVAL); |
580 }).then(() => | 591 }).then(() => |
581 { | 592 { |
582 expectHidden(test, parent); | 593 expectHidden(test, parent); |
583 expectVisible(test, child); | 594 expectVisible(test, child); |
584 expectHidden(test, sibling); | 595 expectHidden(test, sibling); |
585 expectVisible(test, child2); | 596 expectVisible(test, child2); |
586 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 597 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
587 }; | 598 }; |
LEFT | RIGHT |