| 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/en/"; | 20 const TEST_PAGES_URL = "https://testpages.adblockplus.org/en/"; |
| 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, until} = 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( | 30 return p.then( |
| 31 callback, | 31 callback, |
| 32 err => Promise.resolve(callback()).then(() => | 32 err => Promise.resolve(callback()).then(() => |
| 33 Promise.reject(err) | 33 Promise.reject(err) |
| 34 ) | 34 ) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 47 () => driver.switchTo().window(returnTo) | 47 () => driver.switchTo().window(returnTo) |
| 48 ); | 48 ); |
| 49 } | 49 } |
| 50 | 50 |
| 51 function testSubscribeLink(driver) | 51 function testSubscribeLink(driver) |
| 52 { | 52 { |
| 53 return driver.findElement(By.id("subscribe-button")).click().then(() => | 53 return driver.findElement(By.id("subscribe-button")).click().then(() => |
| 54 driver.wait(() => | 54 driver.wait(() => |
| 55 driver.getAllWindowHandles().then(handles => | 55 driver.getAllWindowHandles().then(handles => |
| 56 handles.length > 2 ? handles : null | 56 handles.length > 2 ? handles : null |
| 57 ), 1000 | 57 ), 3000 |
| 58 ) | 58 ) |
| 59 ).then(handles => | 59 ).then(handles => |
| 60 closeWindow(driver, handles[2], handles[1], () => | 60 closeWindow(driver, handles[2], handles[1], () => |
| 61 driver.switchTo().frame(0).then(() => | 61 driver.wait(until.ableToSwitchToFrame(0), 1000).then(() => |
| 62 driver.findElement(By.id("dialog-content-predefined")) | 62 driver.wait(until.elementLocated(By.id("dialog-content-predefined")), |
| 63 1000) |
| 63 ).then(dialog => | 64 ).then(dialog => |
| 64 Promise.all([ | 65 Promise.all([ |
| 65 dialog.isDisplayed(), | 66 dialog.isDisplayed(), |
| 66 dialog.findElement(By.css("h3")).getText() | 67 dialog.findElement(By.css("h3")).getText() |
| 67 ]).then(([displayed, title]) => | 68 ]).then(([displayed, title]) => |
| 68 { | 69 { |
| 69 assert.ok(displayed, "subscribe link: dialog shown"); | 70 assert.ok(displayed, "subscribe link: dialog shown"); |
| 70 assert.equal(title, "ABP Testcase Subscription", | 71 assert.equal(title, "ABP Testcase Subscription", |
| 71 "subscribe link: title shown in dialog"); | 72 "subscribe link: title shown in dialog"); |
| 72 | 73 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 title | 245 title |
| 245 ) | 246 ) |
| 246 ); | 247 ); |
| 247 }); | 248 }); |
| 248 } | 249 } |
| 249 return p2; | 250 return p2; |
| 250 }); | 251 }); |
| 251 return p1; | 252 return p1; |
| 252 }); | 253 }); |
| 253 }); | 254 }); |
| OLD | NEW |