Skip to content

Commit 04dbffc

Browse files
committed
Merge pull request #130 from marco-c/cleanup_test_download_code
Cleanup Firefox download code
2 parents 7affce4 + b8fa399 commit 04dbffc

File tree

1 file changed

+13
-41
lines changed

1 file changed

+13
-41
lines changed

test/selenium-init.js

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ function downloadFirefoxNightly() {
158158
});
159159
}
160160

161-
// Download Firefox Release
162-
163-
function downloadFirefoxRelease() {
161+
function downloadFirefoxFromDMO(product, destDir) {
164162
return new Promise(function(resolve, reject) {
165163
var firefoxPlatform;
166164
if (process.platform === 'linux') {
@@ -173,63 +171,37 @@ function downloadFirefoxRelease() {
173171
}
174172

175173
function getFile() {
176-
var files = fs.readdirSync(stableDestDir);
174+
var files = fs.readdirSync(destDir);
177175
return files.find(function(file) {
178176
return file.indexOf('index.html?') === 0;
179177
});
180178
}
181179

182-
var fileName = 'index.html?product=firefox-latest&lang=en-US&os=' + firefoxPlatform;
180+
var fileName = 'index.html?product=' + product + '&lang=en-US&os=' + firefoxPlatform;
183181

184-
wget(stableDestDir, 'https://download.mozilla.org/?product=firefox-latest&lang=en-US&os=' + firefoxPlatform)
182+
wget(destDir, 'https://download.mozilla.org/?product=' + product + '&lang=en-US&os=' + firefoxPlatform)
185183
.then(function() {
186184
if (process.platform === 'linux') {
187-
untar(stableDestDir, path.join(stableDestDir, fileName))
185+
untar(destDir, path.join(destDir, fileName))
188186
.then(resolve);
189187
} else if (process.platform === 'darwin') {
190-
dmg.mount(path.join(stableDestDir, fileName), function(err, extractedPath) {
191-
fse.copySync(path.join(extractedPath, 'Firefox.app'), path.join(stableDestDir, 'Firefox.app'));
188+
dmg.mount(path.join(destDir, fileName), function(err, extractedPath) {
189+
fse.copySync(path.join(extractedPath, 'Firefox.app'), path.join(destDir, 'Firefox.app'));
192190
dmg.unmount(extractedPath, resolve);
193191
});
194192
}
195193
});
196194
});
197195
}
198196

199-
function downloadFirefoxBeta() {
200-
return new Promise(function(resolve, reject) {
201-
var firefoxPlatform;
202-
if (process.platform === 'linux') {
203-
firefoxPlatform = 'linux';
204-
if (process.arch === 'x64') {
205-
firefoxPlatform += '64';
206-
}
207-
} else if (process.platform === 'darwin') {
208-
firefoxPlatform = 'osx';
209-
}
210-
211-
function getFile() {
212-
var files = fs.readdirSync(betaDestDir);
213-
return files.find(function(file) {
214-
return file.indexOf('index.html?') === 0;
215-
});
216-
}
197+
// Download Firefox Release
217198

218-
var fileName = 'index.html?product=firefox-beta-latest&lang=en-US&os=' + firefoxPlatform;
199+
function downloadFirefoxRelease() {
200+
return downloadFirefoxFromDMO('firefox-latest', stableDestDir);
201+
}
219202

220-
wget(betaDestDir, 'https://download.mozilla.org/?product=firefox-beta-latest&lang=en-US&os=' + firefoxPlatform)
221-
.then(function() {
222-
if (process.platform === 'linux') {
223-
untar(betaDestDir, path.join(betaDestDir, fileName))
224-
.then(resolve);
225-
} else if (process.platform === 'darwin') {
226-
dmg.mount(path.join(betaDestDir, fileName), function(err, extractedPath) {
227-
fse.copySync(path.join(extractedPath, 'Firefox.app'), path.join(betaDestDir, 'Firefox.app'));
228-
dmg.unmount(extractedPath, resolve);
229-
});
230-
}
231-
});
232-
});
203+
function downloadFirefoxBeta() {
204+
return downloadFirefoxFromDMO('firefox-beta-latest', betaDestDir);
233205
}
234206

235207
// Download Chrome Canary

0 commit comments

Comments
 (0)