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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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, id) | 58 function expectHidden(test, element, id) |
59 { | 59 { |
60 let message = id ? | 60 let withId = ""; |
kzar
2018/03/21 18:11:59
This seems kind of messy, also I guess the ID migh
hub
2018/03/21 19:05:04
Done.
hub
2018/03/21 19:05:04
Hence my original approach, since these are just t
kzar
2018/03/22 09:40:04
Sorry I was talking nonsense here, the ID is a str
kzar
2018/03/22 09:40:04
Yea fair enough.
| |
61 `The element with ID '${id}' display property should be set to 'none'` : | 61 if (typeof id != "undefined") |
62 "The element's display property should be set to 'none'"; | 62 withId = ` with ID '${id}'`; |
63 | |
63 test.equal( | 64 test.equal( |
64 window.getComputedStyle(element).display, "none", message); | 65 window.getComputedStyle(element).display, "none", |
66 `The element${withId}'s display property should be set to 'none'`); | |
65 } | 67 } |
66 | 68 |
67 function expectVisible(test, element, id) | 69 function expectVisible(test, element, id) |
68 { | 70 { |
69 let message = id ? | 71 let withId = ""; |
70 `The element with ID '${id}' display property should not be set to 'none'` : | 72 if (typeof id != "undefined") |
71 "The element's display property should not be set to 'none'"; | 73 withId = ` with ID '${id}'`; |
74 | |
72 test.notEqual( | 75 test.notEqual( |
73 window.getComputedStyle(element).display, "none", message); | 76 window.getComputedStyle(element).display, "none", |
77 `The element${withId}'s display property should not be set to 'none'`); | |
74 } | 78 } |
75 | 79 |
76 function findUniqueId() | 80 function findUniqueId() |
77 { | 81 { |
78 let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000); | 82 let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000); |
79 if (!testDocument.getElementById(id)) | 83 if (!testDocument.getElementById(id)) |
80 return id; | 84 return id; |
81 return findUniqueId(); | 85 return findUniqueId(); |
82 } | 86 } |
83 | 87 |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 expectVisible(test, child2); | 692 expectVisible(test, child2); |
689 return timeout(REFRESH_INTERVAL); | 693 return timeout(REFRESH_INTERVAL); |
690 }).then(() => | 694 }).then(() => |
691 { | 695 { |
692 expectHidden(test, parent); | 696 expectHidden(test, parent); |
693 expectVisible(test, child); | 697 expectVisible(test, child); |
694 expectHidden(test, sibling); | 698 expectHidden(test, sibling); |
695 expectVisible(test, child2); | 699 expectVisible(test, child2); |
696 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 700 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
697 }; | 701 }; |
LEFT | RIGHT |