 Issue 29866577:
  Issue 6887 - add Chrome to "npm test"  (Closed)
    
  
    Issue 29866577:
  Issue 6887 - add Chrome to "npm test"  (Closed) 
  | Index: test/all.js | 
| diff --git a/test/all.js b/test/all.js | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..85e1fae2ddd2fd2c0eecbb3ff28d430e60ce3593 | 
| --- /dev/null | 
| +++ b/test/all.js | 
| @@ -0,0 +1,81 @@ | 
| +/* | 
| + * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| + * Copyright (C) 2006-present eyeo GmbH | 
| + * | 
| + * Adblock Plus is free software: you can redistribute it and/or modify | 
| + * it under the terms of the GNU General Public License version 3 as | 
| + * published by the Free Software Foundation. | 
| + * | 
| + * Adblock Plus is distributed in the hope that it will be useful, | 
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| + * GNU General Public License for more details. | 
| + * | 
| + * You should have received a copy of the GNU General Public License | 
| + * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 
| + */ | 
| + | 
| +"use strict"; | 
| + | 
| +const glob = require("glob"); | 
| +const path = require("path"); | 
| +const {exec} = require("child_process"); | 
| + | 
| +for (let browser of glob.sync("./test/browsers/*.js")) | 
| +{ | 
| + let module = require(path.resolve(browser)); | 
| + | 
| + describe(module.platform, function() | 
| + { | 
| + this.timeout(0); | 
| + | 
| + before(function() | 
| + { | 
| + return Promise.all([ | 
| + module.ensureBrowser(), | 
| + new Promise((resolve, reject) => | 
| + { | 
| + exec(`python build.py devenv -t ${module.platform}`, | 
| + (error, stdout, stderr) => | 
| + { | 
| + if (error) | 
| + { | 
| + console.error(stderr); | 
| + reject(error); | 
| + } | 
| + else resolve(stdout); | 
| + }); | 
| + }) | 
| + ]).then(data => | 
| + { | 
| + this.driver = module.getDriver( | 
| + data[0], | 
| + path.resolve(`./devenv.${module.platform}`) | 
| + ); | 
| + return this.driver.wait(() => | 
| + this.driver.getAllWindowHandles().then(handles => handles[1]) | 
| + ); | 
| + }).then(handle => | 
| + this.driver.switchTo().window(handle) | 
| + ).then(() => | 
| + this.driver.executeScript("return location.origin;") | 
| + ).then(origin => | 
| + { | 
| + this.origin = origin; | 
| + this.platform = module.platform; | 
| + }); | 
| + }); | 
| + | 
| + for (let file of glob.sync("./test/wrappers/*.js")) | 
| + { | 
| + // Reload the module(s) for every browser | 
| + delete require.cache[require.resolve(path.resolve(file))]; | 
| + require(path.resolve(file)); | 
| 
Sebastian Noack
2018/09/01 12:28:10
You call path.resolve() twice here. Perhaps use a
 
tlucas
2018/09/01 14:46:44
Done.
 | 
| + } | 
| + | 
| + after(function() | 
| + { | 
| + this.driver.quit(); | 
| + }); | 
| + }); | 
| +} |