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

Side by Side Diff: test/all.js

Issue 29959561: Issue 6930 - Add support for Microsoft Edge to WebDriver-based test automation
Patch Set: Created Dec. 5, 2018, 1:09 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 glob = require("glob"); 20 const glob = require("glob");
21 const path = require("path"); 21 const path = require("path");
22 const os = require("os");
22 const {exec} = require("child_process"); 23 const {exec} = require("child_process");
23 24
24 function getBrowserBinaries(module, browser) 25 function getBrowserBinaries(module, browser)
25 { 26 {
26 let spec = process.env[`${browser.toUpperCase()}_BINARY`]; 27 let spec = process.env[`${browser.toUpperCase()}_BINARY`];
28
29 if (browser == "edge")
Sebastian Noack 2018/12/06 03:47:31 Nit: This can go at the very top of the function.
30 return [{version: "installed", getPath: () => Promise.resolve(null)}];
Sebastian Noack 2018/12/06 03:47:31 Nit: The version property only exists to distingui
31
27 if (spec) 32 if (spec)
28 { 33 {
29 if (spec == "installed") 34 if (spec == "installed")
30 return [{getPath: () => Promise.resolve(null)}]; 35 return [{getPath: () => Promise.resolve(null)}];
31 if (spec.startsWith("path:")) 36 if (spec.startsWith("path:"))
32 return [{getPath: () => Promise.resolve(spec.substr(5))}]; 37 return [{getPath: () => Promise.resolve(spec.substr(5))}];
33 if (spec.startsWith("download:")) 38 if (spec.startsWith("download:"))
34 return [{getPath: () => module.ensureBrowser(spec.substr(9))}]; 39 return [{getPath: () => module.ensureBrowser(spec.substr(9))}];
35 } 40 }
36 41
(...skipping 11 matching lines...) Expand all
48 53
49 for (let backend of glob.sync("./test/browsers/*.js")) 54 for (let backend of glob.sync("./test/browsers/*.js"))
50 { 55 {
51 let module = require(path.resolve(backend)); 56 let module = require(path.resolve(backend));
52 let browser = path.basename(backend, ".js"); 57 let browser = path.basename(backend, ".js");
53 let devenvCreated = null; 58 let devenvCreated = null;
54 59
55 for (let binary of getBrowserBinaries(module, browser)) 60 for (let binary of getBrowserBinaries(module, browser))
56 { 61 {
57 let description = browser.replace(/./, c => c.toUpperCase()); 62 let description = browser.replace(/./, c => c.toUpperCase());
63 let describeTest = module.platform == "edge" && os.platform() != "win32" ?
64 describe.skip : describe;
Sebastian Noack 2018/12/06 03:47:31 Is this sufficient? I suppose the before() hook wo
65
58 if (binary.version) 66 if (binary.version)
59 description += ` (${binary.version})`; 67 description += ` (${binary.version})`;
60 68
61 describe(description, function() 69 describeTest(description, function()
62 { 70 {
63 this.timeout(0); 71 this.timeout(0);
64 72
65 before(function() 73 before(function()
66 { 74 {
67 if (!devenvCreated) 75 if (!devenvCreated)
68 devenvCreated = new Promise((resolve, reject) => 76 devenvCreated = new Promise((resolve, reject) =>
69 { 77 {
70 exec( 78 exec(
71 `bash -c "python build.py devenv -t ${module.platform}"`, 79 `bash -c "python build.py devenv -t ${module.platform}"`,
72 (error, stdout, stderr) => 80 (error, stdout, stderr) =>
73 { 81 {
74 if (error) 82 if (error)
75 { 83 {
76 console.error(stderr); 84 console.error(stderr);
77 reject(error); 85 reject(error);
78 } 86 }
79 else resolve(stdout); 87 else resolve(stdout);
80 } 88 }
81 ); 89 );
82 }); 90 });
83 91
84 return Promise.all([binary.getPath(), devenvCreated]).then( 92 return Promise.all([binary.getPath(), devenvCreated]).then(
85 ([browserBinary]) => 93 ([browserBinary]) =>
86 { 94 {
95 if (module.platform == "edge" && os.platform() == "win32")
96 {
97 return module
98 .sideloadExtension(`devenv.${module.platform}`)
99 .then(extensionPath =>
100 {
101 this.driver = module.getDriver(extensionPath);
102
103 return this.driver.sleep(3000)
Sebastian Noack 2018/12/06 03:47:30 Is this really necessary? Or is there any promise
104 .then(() => this.driver.wait(() =>
105 this.driver.getAllWindowHandles()
106 .then(handles => handles[1])));
107 });
108 }
109
87 this.driver = module.getDriver( 110 this.driver = module.getDriver(
88 browserBinary, 111 browserBinary,
89 path.resolve(`./devenv.${module.platform}`) 112 path.resolve(`./devenv.${module.platform}`)
90 ); 113 );
91 return this.driver.wait(() => 114 return this.driver.wait(() =>
92 this.driver.getAllWindowHandles().then(handles => handles[1]) 115 this.driver.getAllWindowHandles().then(handles => handles[1])
93 ); 116 );
94 } 117 }
95 ).then(handle => 118 ).then(handle =>
96 this.driver.switchTo().window(handle) 119 this.driver.switchTo().window(handle)
(...skipping 14 matching lines...) Expand all
111 } 134 }
112 135
113 after(function() 136 after(function()
114 { 137 {
115 if (this.driver) 138 if (this.driver)
116 return this.driver.quit(); 139 return this.driver.quit();
117 }); 140 });
118 }); 141 });
119 } 142 }
120 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld