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 |
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 FIREFOX_VERSION = "57.0"; | 20 const FIREFOX_VERSION = "57.0"; |
21 | 21 |
22 const path = require("path"); | 22 const path = require("path"); |
23 const webdriver = require("selenium-webdriver"); | 23 const webdriver = require("selenium-webdriver"); |
24 const {By, until} = webdriver; | 24 const {By, until} = webdriver; |
25 const firefox = require("selenium-webdriver/firefox"); | 25 const firefox = require("selenium-webdriver/firefox"); |
26 const {Command} = require("selenium-webdriver/lib/command"); | 26 const {Command} = require("selenium-webdriver/lib/command"); |
27 const {ensureFirefox} = require("../adblockpluscore/test/runners/" + | 27 const {ensureFirefox} = require("../adblockpluscore/test/runners/" + |
28 "firefox_download"); | 28 "firefox_download"); |
29 | 29 |
Sebastian Noack
2018/08/24 13:27:59
Nit: We usually only put one blank line after the
tlucas
2018/08/24 15:26:00
Done.
| |
30 | |
31 function reportElements(test, driver, success) | 30 function reportElements(test, driver, success) |
32 { | 31 { |
33 return driver.findElements( | 32 return driver.findElements( |
34 By.css(`#qunit-tests ${success ? ".pass" : ".fail"} .test-name`) | 33 By.css(`#qunit-tests ${success ? ".pass" : ".fail"} .test-name`) |
35 ).then(elements => Promise.all(elements.map(elem => | 34 ).then(elements => Promise.all(elements.map(elem => |
36 elem.getAttribute("innerHTML").then(data => test.ok(success, data)) | 35 elem.getAttribute("innerHTML").then(data => test.ok(success, data)) |
37 ))); | 36 ))); |
38 } | 37 } |
39 | 38 |
40 exports.runFirefox = function(test) | 39 exports.runFirefox = function(test) |
41 { | 40 { |
42 // https://stackoverflow.com/a/45045036 | 41 // https://stackoverflow.com/a/45045036 |
43 function installWebExt(driver, extension) | 42 function installWebExt(driver, extension) |
44 { | 43 { |
45 let cmd = new Command("moz-install-web-ext") | 44 let cmd = new Command("moz-install-web-ext") |
46 .setParameter("path", path.resolve(extension)) | 45 .setParameter("path", path.resolve(extension)) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 driver.findElement(By.id("qunit-testresult")) | 91 driver.findElement(By.id("qunit-testresult")) |
93 .getAttribute("innerHTML").then(data => | 92 .getAttribute("innerHTML").then(data => |
94 data.includes("Tests completed"))) | 93 data.includes("Tests completed"))) |
95 ).then(() => Promise.all([ | 94 ).then(() => Promise.all([ |
96 reportElements(test, driver, true), | 95 reportElements(test, driver, true), |
97 reportElements(test, driver, false) | 96 reportElements(test, driver, false) |
98 ])).then(() => | 97 ])).then(() => |
99 { | 98 { |
100 driver.quit(); | 99 driver.quit(); |
101 test.done(); | 100 test.done(); |
102 }).catch((err) => | 101 }, err => |
Sebastian Noack
2018/08/24 13:27:59
I'd suggest to change the error handling like that
tlucas
2018/08/24 15:26:00
Done. (Still waiting for driver.quit() to finish b
| |
103 { | |
104 driver.quit().then(() => | 102 driver.quit().then(() => |
105 { | 103 { |
106 throw err; | 104 throw err; |
107 }); | 105 }) |
108 }); | 106 ); |
109 }); | 107 }); |
110 }; | 108 }; |
LEFT | RIGHT |