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

Delta Between Two Patch Sets: test/runners/firefox_download.js

Issue 29720661: Issue 6391 - Allow running the browser unit tests with Firefox (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Added firefox download Created March 19, 2018, 8:37 p.m.
Right Patch Set: Update Firefox version in README Created Aug. 3, 2018, 4:15 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/runners/download.js ('k') | test/runners/firefox_process.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
18 /* eslint-env node */
19 /* eslint no-console: "off" */
20 17
21 "use strict"; 18 "use strict";
22 19
23 const {exec} = require("child_process"); 20 const {exec} = require("child_process");
24 const fs = require("fs"); 21 const fs = require("fs");
25 const path = require("path"); 22 const path = require("path");
26 23
27 const {ncp} = require("ncp"); 24 const {ncp} = require("ncp");
28 25
29 const {download} = require("./download"); 26 const {download} = require("./download");
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 reject(ncperr); 73 reject(ncperr);
77 } 74 }
78 else 75 else
79 resolve(); 76 resolve();
80 }); 77 });
81 } 78 }
82 }); 79 });
83 }); 80 });
84 } 81 }
85 82
83 function runWinInstaller(archive, browserDir)
84 {
85 // Procedure inspired from mozinstall:
86 // https://hg.mozilla.org/mozilla-central/file/tip/testing/mozbase/mozinstall/ mozinstall/mozinstall.py
87 // Also uninstaller will need to be run.
88 return new Promise((resolve, reject) =>
89 {
90 exec([archive, `/extractdir=${browserDir}`].join(" "),
91 err =>
92 {
93 if (err)
94 reject(err);
95 else
96 resolve();
97 });
98 });
99 }
100
86 function extractArchive(archive, browserDir) 101 function extractArchive(archive, browserDir)
87 { 102 {
88 switch (platform) 103 switch (platform)
89 { 104 {
90 // case "win32": 105 case "win32":
91 // return unzipArchive(archive, browserDir); 106 return runWinInstaller(archive, browserDir);
92 case "linux": 107 case "linux":
93 return extractTar(archive, browserDir); 108 return extractTar(archive, browserDir);
94 case "darwin": 109 case "darwin":
95 return extractDmg(archive, browserDir); 110 return extractDmg(archive, browserDir);
96 default: 111 default:
97 throw new Error("Unexpected platform"); 112 throw new Error("Unexpected platform");
98 } 113 }
99 } 114 }
100 115
101 function getFirefoxExecutable(browserDir) 116 function getFirefoxExecutable(browserDir)
102 { 117 {
103 switch (platform) 118 switch (platform)
104 { 119 {
105 // case "win32": 120 case "win32":
106 // return path.join(browserDir, "firefox", "firefox.exe"); 121 return path.join(browserDir, "firefox.exe");
107 case "linux": 122 case "linux":
108 return path.join(browserDir, "firefox", "firefox"); 123 return path.join(browserDir, "firefox", "firefox");
109 case "darwin": 124 case "darwin":
110 return path.join(browserDir, "Firefox.app", "Contents", 125 return path.join(browserDir, "Firefox.app", "Contents",
111 "MacOS", "firefox"); 126 "MacOS", "firefox");
112 default: 127 default:
113 throw new Error("Unexpected platform"); 128 throw new Error("Unexpected platform");
114 } 129 }
115 } 130 }
116 131
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return download(url, archive); 171 return download(url, archive);
157 } 172 }
158 console.info(`Reusing cached archive ${archive}`); 173 console.info(`Reusing cached archive ${archive}`);
159 }) 174 })
160 .then(() => extractArchive(archive, browserDir)) 175 .then(() => extractArchive(archive, browserDir))
161 .then(() => browserDir); 176 .then(() => browserDir);
162 }).then(dir => getFirefoxExecutable(dir)); 177 }).then(dir => getFirefoxExecutable(dir));
163 } 178 }
164 179
165 module.exports.ensureFirefox = ensureFirefox; 180 module.exports.ensureFirefox = ensureFirefox;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld