 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..ecb33b0b27f705312d9809fc931b10c54163fa30 | 
| --- /dev/null | 
| +++ b/test/all.js | 
| @@ -0,0 +1,78 @@ | 
| +/* | 
| + * 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/>. | 
| + */ | 
| + | 
| +/* eslint-env mocha */ | 
| + | 
| +"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 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(() => module.getDriver( | 
| + path.resolve(`./devenv.${module.platform}`)).then(d => | 
| + { | 
| + this.driver = d; | 
| 
Sebastian Noack
2018/09/01 10:42:47
Nit: The reason we called the argument "d" (rather
 
tlucas
2018/09/01 11:54:23
Done.
 | 
| + 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(o => | 
| + { | 
| + this.origin = o; | 
| + 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))]; | 
| 
Sebastian Noack
2018/09/01 10:42:47
Why would they already be in cache? Isn't this the
 
tlucas
2018/09/01 11:54:24
We (want to) require them 2 times currently, once
 
Sebastian Noack
2018/09/01 12:26:33
Acknowledged.
 | 
| + require(path.resolve(file)); | 
| + } | 
| + | 
| + after(function() | 
| + { | 
| + this.driver.quit(); | 
| + }); | 
| + }); | 
| +} |