Skip to content

Commit ad8822d

Browse files
authored
fix(launcher): detect Firefox installed in AppData on Windows (#8460)
1 parent 1ad9bd1 commit ad8822d

File tree

3 files changed

+89
-8
lines changed

3 files changed

+89
-8
lines changed

packages/launcher/__snapshots__/windows_spec.ts.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,63 @@ exports['windows browser detection detects new Chrome 64-bit app path 1'] = {
182182
"version": "4.4.4",
183183
"path": "C:/Program Files/Google/Chrome/Application/chrome.exe"
184184
}
185+
186+
exports['windows browser detection detects local Firefox installs 1'] = [
187+
{
188+
"name": "firefox",
189+
"family": "firefox",
190+
"channel": "stable",
191+
"displayName": "Firefox",
192+
"info": "Firefox support is currently in beta! You can help us continue to improve the Cypress + Firefox experience by [reporting any issues you find](https://on.cypress.io/new-issue).",
193+
"versionRegex": {},
194+
"binary": "firefox",
195+
"path": "C:/Users/flotwig/AppData/Local/Mozilla Firefox/firefox.exe",
196+
"version": "100",
197+
"findAppParams": {
198+
"appName": "Firefox.app",
199+
"executable": "Contents/MacOS/firefox-bin",
200+
"appId": "org.mozilla.firefox",
201+
"versionProperty": "CFBundleShortVersionString"
202+
}
203+
},
204+
{
205+
"name": "firefox",
206+
"family": "firefox",
207+
"channel": "dev",
208+
"displayName": "Firefox Developer Edition",
209+
"info": "Firefox support is currently in beta! You can help us continue to improve the Cypress + Firefox experience by [reporting any issues you find](https://on.cypress.io/new-issue).",
210+
"versionRegex": {},
211+
"binary": [
212+
"firefox-developer-edition",
213+
"firefox"
214+
],
215+
"path": "C:/Users/flotwig/AppData/Local/Firefox Developer Edition/firefox.exe",
216+
"version": "300",
217+
"findAppParams": {
218+
"appName": "Firefox Developer Edition.app",
219+
"executable": "Contents/MacOS/firefox-bin",
220+
"appId": "org.mozilla.firefoxdeveloperedition",
221+
"versionProperty": "CFBundleShortVersionString"
222+
}
223+
},
224+
{
225+
"name": "firefox",
226+
"family": "firefox",
227+
"channel": "nightly",
228+
"displayName": "Firefox Nightly",
229+
"info": "Firefox support is currently in beta! You can help us continue to improve the Cypress + Firefox experience by [reporting any issues you find](https://on.cypress.io/new-issue).",
230+
"versionRegex": {},
231+
"binary": [
232+
"firefox-nightly",
233+
"firefox-trunk"
234+
],
235+
"path": "C:/Users/flotwig/AppData/Local/Firefox Nightly/firefox.exe",
236+
"version": "200",
237+
"findAppParams": {
238+
"appName": "Firefox Nightly.app",
239+
"executable": "Contents/MacOS/firefox-bin",
240+
"appId": "org.mozilla.nightly",
241+
"versionProperty": "CFBundleShortVersionString"
242+
}
243+
}
244+
]

packages/launcher/lib/windows/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ function getFirefoxPaths (editionFolder) {
4242
.map((programFiles) => {
4343
return normalize(`C:/${programFiles}/${editionFolder}/firefox.exe`)
4444
})
45+
.concat(normalize(join(
46+
os.homedir(),
47+
'AppData',
48+
'Local',
49+
editionFolder,
50+
'firefox.exe',
51+
)))
4552
}
4653
}
4754

packages/launcher/test/unit/windows_spec.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Bluebird from 'bluebird'
99
import fse from 'fs-extra'
1010
import os from 'os'
1111
import snapshot from 'snap-shot-it'
12+
import { Browser } from '../../lib/types'
1213

1314
function stubBrowser (path: string, version: string) {
1415
path = normalize(path.replace(/\\/g, '\\\\'))
@@ -22,6 +23,15 @@ function stubBrowser (path: string, version: string) {
2223
.resolves(true)
2324
}
2425

26+
function detect (goalBrowsers: Browser[]) {
27+
return Bluebird.mapSeries(goalBrowsers, (browser) => {
28+
return windowsHelper.detect(browser)
29+
.then((foundBrowser) => {
30+
return _.merge(browser, foundBrowser)
31+
})
32+
})
33+
}
34+
2535
const HOMEDIR = 'C:/Users/flotwig'
2636

2737
describe('windows browser detection', () => {
@@ -55,14 +65,7 @@ describe('windows browser detection', () => {
5565
// edge canary is installed in homedir
5666
stubBrowser(`${HOMEDIR}/AppData/Local/Microsoft/Edge SxS/Application/msedge.exe`, '14')
5767

58-
const detected = (await Bluebird.mapSeries(browsers, (browser) => {
59-
return windowsHelper.detect(browser)
60-
.then((foundBrowser) => {
61-
return _.merge(browser, foundBrowser)
62-
})
63-
}))
64-
65-
snapshot(detected)
68+
snapshot(await detect(browsers))
6669
})
6770

6871
// @see https://github.com/cypress-io/cypress/issues/8425
@@ -73,6 +76,17 @@ describe('windows browser detection', () => {
7376
snapshot(await windowsHelper.detect(chrome))
7477
})
7578

79+
// @see https://github.com/cypress-io/cypress/issues/8432
80+
it('detects local Firefox installs', async () => {
81+
stubBrowser(`${HOMEDIR}/AppData/Local/Mozilla Firefox/firefox.exe`, '100')
82+
stubBrowser(`${HOMEDIR}/AppData/Local/Firefox Nightly/firefox.exe`, '200')
83+
stubBrowser(`${HOMEDIR}/AppData/Local/Firefox Developer Edition/firefox.exe`, '300')
84+
85+
const firefoxes = _.filter(browsers, { family: 'firefox' })
86+
87+
snapshot(await detect(firefoxes))
88+
})
89+
7690
context('#getVersionString', () => {
7791
it('runs wmic and returns output', async () => {
7892
stubBrowser('foo', 'bar')

0 commit comments

Comments
 (0)