| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 const {ElemHideEmulation, setTestMode, | 20 const {ElemHideEmulation, setTestMode, |
| 21 getTestInfo} = require("../../lib/content/elemHideEmulation"); | 21 getTestInfo} = require("../../lib/content/elemHideEmulation"); |
| 22 const {timeout} = require("./_utils"); | 22 const {timeout, expectHidden, expectVisible} = require("./_utils"); |
| 23 | 23 |
| 24 const REFRESH_INTERVAL = 200; | 24 const REFRESH_INTERVAL = 200; |
| 25 | 25 |
| 26 let testDocument = null; | 26 let testDocument = null; |
| 27 | 27 |
| 28 exports.setUp = function(callback) | 28 exports.setUp = function(callback) |
| 29 { | 29 { |
| 30 setTestMode(); | 30 setTestMode(); |
| 31 | 31 |
| 32 let iframe = document.createElement("iframe"); | 32 let iframe = document.createElement("iframe"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 44 | 44 |
| 45 callback(); | 45 callback(); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 function unexpectedError(test, error) | 48 function unexpectedError(test, error) |
| 49 { | 49 { |
| 50 console.error(error); | 50 console.error(error); |
| 51 test.ok(false, "Unexpected error: " + error); | 51 test.ok(false, "Unexpected error: " + error); |
| 52 } | 52 } |
| 53 | 53 |
| 54 function expectHidden(test, element, id) | |
| 55 { | |
| 56 let withId = ""; | |
| 57 if (typeof id != "undefined") | |
| 58 withId = ` with ID '${id}'`; | |
| 59 | |
| 60 test.equal( | |
| 61 window.getComputedStyle(element).display, "none", | |
| 62 `The element${withId}'s display property should be set to 'none'`); | |
| 63 } | |
| 64 | |
| 65 function expectVisible(test, element, id) | |
| 66 { | |
| 67 let withId = ""; | |
| 68 if (typeof id != "undefined") | |
| 69 withId = ` with ID '${id}'`; | |
| 70 | |
| 71 test.notEqual( | |
| 72 window.getComputedStyle(element).display, "none", | |
| 73 `The element${withId}'s display property should not be set to 'none'`); | |
| 74 } | |
| 75 | |
| 76 function expectProcessed(test, element, id = null) | 54 function expectProcessed(test, element, id = null) |
| 77 { | 55 { |
| 78 let withId = ""; | 56 let withId = ""; |
| 79 if (id) | 57 if (id) |
| 80 withId = ` with ID '${id}'`; | 58 withId = ` with ID '${id}'`; |
| 81 | 59 |
| 82 test.ok( | 60 test.ok( |
| 83 getTestInfo().lastProcessedElements.has(element), | 61 getTestInfo().lastProcessedElements.has(element), |
| 84 `The element${withId} should have been processed`); | 62 `The element${withId} should have been processed`); |
| 85 } | 63 } |
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 { | 1182 { |
| 1205 if (element.id == "n2" || element.id == "n2_3") | 1183 if (element.id == "n2" || element.id == "n2_3") |
| 1206 expectProcessed(test, element, element.id); | 1184 expectProcessed(test, element, element.id); |
| 1207 else | 1185 else |
| 1208 expectNotProcessed(test, element, element.id); | 1186 expectNotProcessed(test, element, element.id); |
| 1209 } | 1187 } |
| 1210 } | 1188 } |
| 1211 | 1189 |
| 1212 test.done(); | 1190 test.done(); |
| 1213 }; | 1191 }; |
| OLD | NEW |