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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 const {executeScript} = require("./webdriver"); | 24 const {executeScript} = require("./webdriver"); |
25 const {ensureFirefox} = require("./firefox_download"); | 25 const {ensureFirefox} = require("./firefox_download"); |
26 | 26 |
27 // Firefox 57 seems to be the minimum to reliably run with WebDriver | 27 // Firefox 57 seems to be the minimum to reliably run with WebDriver |
28 // on certain system configurations like Debian 9, TravisCI. | 28 // on certain system configurations like Debian 9, TravisCI. |
29 const FIREFOX_VERSION = "57.0"; | 29 const FIREFOX_VERSION = "57.0"; |
30 | 30 |
31 function runScript(firefoxPath, script, scriptName, scriptArgs) | 31 function runScript(firefoxPath, script, scriptName, scriptArgs) |
32 { | 32 { |
33 let binary = new firefox.Binary(firefoxPath); | 33 const options = new firefox.Options().setBinary(firefoxPath).headless(); |
34 binary.addArguments("-headless"); | |
35 | |
36 const options = new firefox.Options() | |
37 .setBinary(binary); | |
38 | |
39 const driver = new Builder() | 34 const driver = new Builder() |
40 .forBrowser("firefox") | 35 .forBrowser("firefox") |
41 .setFirefoxOptions(options) | 36 .setFirefoxOptions(options) |
42 .build(); | 37 .build(); |
43 | 38 |
44 return executeScript(driver, "Firefox", script, scriptName, scriptArgs); | 39 return executeScript(driver, "Firefox", script, scriptName, scriptArgs); |
45 } | 40 } |
46 | 41 |
47 module.exports = function(script, scriptName, ...scriptArgs) | 42 module.exports = function(script, scriptName, ...scriptArgs) |
48 { | 43 { |
49 return ensureFirefox(FIREFOX_VERSION) | 44 return ensureFirefox(FIREFOX_VERSION) |
50 .then(firefoxPath => | 45 .then(firefoxPath => |
51 runScript(firefoxPath, script, scriptName, scriptArgs)); | 46 runScript(firefoxPath, script, scriptName, scriptArgs)); |
52 }; | 47 }; |
OLD | NEW |