Skip to content

Commit 881b4ba

Browse files
committed
add more enviroment variables for the Firefox profile used in tests
1 parent 6861ebd commit 881b4ba

File tree

3 files changed

+33
-26
lines changed

3 files changed

+33
-26
lines changed

src/test/.env

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# this file defines environment variables used in tests
22

3-
# optional: set the Firefox executable and profile to be used in the tests
4-
# and whether the tests should run in headless mode
5-
# FIREFOX_EXECUTABLE=/usr/bin/firefox
6-
# FIREFOX_PROFILE=debug
3+
# FIREFOX_EXECUTABLE=developer
4+
# FIREFOX_PROFILE=test
5+
# FIREFOX_PROFILE_DIR=/tmp/firefox-test-profile
6+
# KEEP_PROFILE_CHANGES=true
77
HEADLESS=true

src/test/testTerminateAndCleanup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ describe('Terminate and cleanup: The debugger', function() {
1414

1515
it('should eventually delete the temporary profile after terminating Firefox', async function() {
1616

17+
if (process.env['KEEP_PROFILE_CHANGES'] === 'true') {
18+
this.skip();
19+
return;
20+
}
21+
1722
const tmpDir = path.join(os.tmpdir(), `vscode-firefox-debug-test-${uuid.v4()}`);
1823
const dc = await util.initDebugClient(TESTDATA_PATH, true, { tmpDir });
1924

src/test/util.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,7 @@ export async function initDebugClient(
2020
file: path.join(testDataPath, 'web/index.html')
2121
};
2222

23-
if (process.env['FIREFOX_EXECUTABLE']) {
24-
launchArgs.firefoxExecutable = process.env['FIREFOX_EXECUTABLE'];
25-
}
26-
27-
if (process.env['FIREFOX_PROFILE']) {
28-
launchArgs.profile = process.env['FIREFOX_PROFILE'];
29-
}
30-
31-
if (process.env['HEADLESS'] === "true") {
32-
launchArgs.firefoxArgs = ["-headless"];
33-
}
23+
processEnvironmentVariables(launchArgs);
3424

3525
if (extraLaunchArgs !== undefined) {
3626
launchArgs = Object.assign(launchArgs, extraLaunchArgs);
@@ -77,17 +67,7 @@ export async function initDebugClientForAddon(
7767
dcArgs.file = path.join(testDataPath, `webExtension/index.html`);
7868
}
7969

80-
if (process.env['FIREFOX_EXECUTABLE']) {
81-
dcArgs.firefoxExecutable = process.env['FIREFOX_EXECUTABLE'];
82-
}
83-
84-
if (process.env['FIREFOX_PROFILE']) {
85-
dcArgs.profile = process.env['FIREFOX_PROFILE'];
86-
}
87-
88-
if (process.env['HEADLESS'] === "true") {
89-
dcArgs.firefoxArgs = ["-headless"];
90-
}
70+
processEnvironmentVariables(dcArgs);
9171

9272
let dc = new DebugClient('node', './dist/adapter.bundle.js', 'firefox');
9373

@@ -113,6 +93,28 @@ export async function initDebugClientForAddon(
11393
return dc;
11494
}
11595

96+
function processEnvironmentVariables(launchArgs: LaunchConfiguration) {
97+
if (process.env['FIREFOX_EXECUTABLE']) {
98+
launchArgs.firefoxExecutable = process.env['FIREFOX_EXECUTABLE'];
99+
}
100+
101+
if (process.env['FIREFOX_PROFILE']) {
102+
launchArgs.profile = process.env['FIREFOX_PROFILE'];
103+
}
104+
105+
if (process.env['FIREFOX_PROFILE_DIR']) {
106+
launchArgs.profileDir = process.env['FIREFOX_PROFILE_DIR'];
107+
}
108+
109+
if (process.env['KEEP_PROFILE_CHANGES'] === 'true') {
110+
launchArgs.keepProfileChanges = true;
111+
}
112+
113+
if (process.env['HEADLESS'] === 'true') {
114+
launchArgs.firefoxArgs = ['-headless'];
115+
}
116+
}
117+
116118
async function waitForUnoccupiedPort(port: number, timeout: number) {
117119
if (!await isPortOccupied(port)) {
118120
return;

0 commit comments

Comments
 (0)