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 TEST_PAGES_URL = "https://testpages.adblockplus.org/"; | 20 const TEST_PAGES_URL = "https://testpages.adblockplus.org/"; |
21 | 21 |
22 const assert = require("assert"); | 22 const assert = require("assert"); |
23 const Jimp = require("jimp"); | 23 const Jimp = require("jimp"); |
24 const {By} = require("selenium-webdriver"); | 24 const {By} = require("selenium-webdriver"); |
25 | 25 |
26 // Once we require Node.js >= 10 this should be replaced with | 26 // Once we require Node.js >= 10 this should be replaced with |
27 // the built-in finally() method of the Promise object. | 27 // the built-in finally() method of the Promise object. |
28 function promiseFinally(p, callback) | 28 function promiseFinally(p, callback) |
29 { | 29 { |
30 return p.then(callback, callback); | 30 return p.then( |
| 31 callback, |
| 32 err => Promise.resolve(callback()).then(() => |
| 33 Promise.reject(err) |
| 34 ) |
| 35 ); |
31 } | 36 } |
32 | 37 |
33 function closeWindow(driver, goTo, returnTo, callback) | 38 function closeWindow(driver, goTo, returnTo, callback) |
34 { | 39 { |
35 return promiseFinally( | 40 return promiseFinally( |
36 driver.switchTo().window(goTo).then(() => | 41 driver.switchTo().window(goTo).then(() => |
37 promiseFinally( | 42 promiseFinally( |
38 new Promise(resolve => resolve(callback && callback())), | 43 new Promise(resolve => resolve(callback && callback())), |
39 () => driver.close() | 44 () => driver.close() |
40 ) | 45 ) |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 title | 245 title |
241 ) | 246 ) |
242 ); | 247 ); |
243 }); | 248 }); |
244 } | 249 } |
245 return p2; | 250 return p2; |
246 }); | 251 }); |
247 return p1; | 252 return p1; |
248 }); | 253 }); |
249 }); | 254 }); |
OLD | NEW |