Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: test/all.js

Issue 29866577: Issue 6887 - add Chrome to "npm test" (Closed)
Left Patch Set: Created Aug. 28, 2018, 8:17 a.m.
Right Patch Set: Removed unused this.platform Created Sept. 1, 2018, 3:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/.eslintrc.json ('k') | test/browsers/chromium.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 /* eslint-env mocha */
19
20 "use strict"; 18 "use strict";
21 19
22 const glob = require("glob"); 20 const glob = require("glob");
23 const path = require("path"); 21 const path = require("path");
24 const {exec} = require("child_process"); 22 const {exec} = require("child_process");
25 23
26 for (let browser of glob.sync("./test/browsers/*.js")) 24 for (let browser of glob.sync("./test/browsers/*.js"))
27 { 25 {
28 let module = require(path.resolve(browser)); 26 let module = require(path.resolve(browser));
29 27
30 describe(module.platform, function() 28 describe(module.platform, function()
31 { 29 {
32 this.timeout(0); 30 this.timeout(0);
33 31
34 let driver; 32 before(function()
35 let origin; 33 {
36 34 return Promise.all([
37 before(() => 35 module.ensureBrowser(),
38 new Promise((resolve, reject) => 36 new Promise((resolve, reject) =>
37 {
38 exec(`python build.py devenv -t ${module.platform}`,
39 (error, stdout, stderr) =>
40 {
41 if (error)
42 {
43 console.error(stderr);
44 reject(error);
45 }
46 else resolve(stdout);
47 });
48 })
49 ]).then(([browserBinary]) =>
39 { 50 {
40 exec(`python build.py devenv -t ${module.platform}`, 51 this.driver = module.getDriver(
41 (error, stdout, stderr) => 52 browserBinary,
42 { 53 path.resolve(`./devenv.${module.platform}`)
43 if (error) 54 );
44 { 55 return this.driver.wait(() =>
45 console.error(error); 56 this.driver.getAllWindowHandles().then(handles => handles[1])
46 reject(stderr);
Sebastian Noack 2018/08/28 14:44:58 It seems you got it the wrong way around. You want
tlucas 2018/08/29 09:16:53 Done.
47 }
48 else resolve(stdout);
49 });
50 }
51 ).then(() =>
Sebastian Noack 2018/08/28 14:44:58 Nit: The indention is off here. Closing parenthesi
tlucas 2018/08/29 09:16:53 re indented here and above (at "new Promise")
52 module.getDriver().then(d =>
53 {
54 driver = d;
55 return driver.wait(() =>
56 driver.getAllWindowHandles().then(handles => handles[1])
57 ); 57 );
58 }).then(handle => 58 }).then(handle =>
59 driver.switchTo().window(handle) 59 this.driver.switchTo().window(handle)
60 ).then(() => 60 ).then(() =>
61 driver.executeScript("return location.origin;") 61 this.driver.executeScript("return location.origin;")
62 ).then(o => 62 ).then(origin =>
63 { 63 {
64 origin = o; 64 this.origin = origin;
65 }) 65 });
66 )); 66 });
67 67
68 for (let file of glob.sync("./test/wrappers/*.js")) 68 for (let file of glob.sync("./test/wrappers/*.js"))
69 { 69 {
70 let testModule = require(path.resolve(file)); 70 // Reload the module(s) for every browser
71 71 let modulePath = path.resolve(file);
72 it(testModule.title, () => 72 delete require.cache[require.resolve(modulePath)];
73 { 73 require(modulePath);
74 return testModule.it(driver, origin);
75 });
76 } 74 }
77 75
78 after(() => driver.quit()); 76 after(function()
77 {
78 this.driver.quit();
79 });
79 }); 80 });
80 } 81 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld