Left: | ||
Right: |
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-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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 window.setTimeout(resolve, delay); | 48 window.setTimeout(resolve, delay); |
49 }); | 49 }); |
50 } | 50 } |
51 | 51 |
52 function unexpectedError(error) | 52 function unexpectedError(error) |
53 { | 53 { |
54 console.error(error); | 54 console.error(error); |
55 this.ok(false, "Unexpected error: " + error); | 55 this.ok(false, "Unexpected error: " + error); |
56 } | 56 } |
57 | 57 |
58 function expectHidden(test, element) | 58 function expectHidden(test, element, id) |
59 { | 59 { |
60 test.equal(window.getComputedStyle(element).display, "none", | 60 let elementId = id ? `: ${id}` : ""; |
61 "The element's display property should be set to 'none'"); | 61 test.equal( |
62 window.getComputedStyle(element).display, "none", | |
63 `The element's display property should be set to 'none' ${elementId}`); | |
kzar
2018/03/19 16:55:20
Please can you improve the message, like "The elem
hub
2018/03/20 14:40:26
Done.
| |
62 } | 64 } |
63 | 65 |
64 function expectVisible(test, element) | 66 function expectVisible(test, element, id) |
65 { | 67 { |
66 test.notEqual(window.getComputedStyle(element).display, "none", | 68 let elementId = id ? `: ${id}` : ""; |
67 "The element's display property should not be set to 'none'"); | 69 test.notEqual( |
70 window.getComputedStyle(element).display, "none", | |
71 `The element's display property should not be set to 'none' ${elementId}`); | |
68 } | 72 } |
69 | 73 |
70 function findUniqueId() | 74 function findUniqueId() |
71 { | 75 { |
72 let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000); | 76 let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000); |
73 if (!testDocument.getElementById(id)) | 77 if (!testDocument.getElementById(id)) |
74 return id; | 78 return id; |
75 return findUniqueId(); | 79 return findUniqueId(); |
76 } | 80 } |
77 | 81 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 357 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
354 }; | 358 }; |
355 | 359 |
356 function compareExpectations(test, elems, expectations) | 360 function compareExpectations(test, elems, expectations) |
357 { | 361 { |
358 for (let elem in expectations) | 362 for (let elem in expectations) |
359 { | 363 { |
360 if (elems[elem]) | 364 if (elems[elem]) |
361 { | 365 { |
362 if (expectations[elem]) | 366 if (expectations[elem]) |
363 expectVisible(test, elems[elem]); | 367 expectVisible(test, elems[elem], elem); |
364 else | 368 else |
365 expectHidden(test, elems[elem]); | 369 expectHidden(test, elems[elem], elem); |
366 } | 370 } |
367 } | 371 } |
368 } | 372 } |
369 | 373 |
370 function runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(test, selector , expectations) | 374 function runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(test, selector , expectations) |
371 { | 375 { |
372 testDocument.body.innerHTML = `<div id="parent"> | 376 testDocument.body.innerHTML = `<div id="parent"> |
373 <div id="middle"> | 377 <div id="middle"> |
374 <div id="middle1"><div id="inside" class="inside"></div></div> | 378 <div id="middle1"><div id="inside" class="inside"></div></div> |
375 </div> | 379 </div> |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
682 expectVisible(test, child2); | 686 expectVisible(test, child2); |
683 return timeout(REFRESH_INTERVAL); | 687 return timeout(REFRESH_INTERVAL); |
684 }).then(() => | 688 }).then(() => |
685 { | 689 { |
686 expectHidden(test, parent); | 690 expectHidden(test, parent); |
687 expectVisible(test, child); | 691 expectVisible(test, child); |
688 expectHidden(test, sibling); | 692 expectHidden(test, sibling); |
689 expectVisible(test, child2); | 693 expectVisible(test, child2); |
690 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 694 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
691 }; | 695 }; |
OLD | NEW |