Skip to content

Commit 89ccc55

Browse files
authored
feat: introduce a --firefox-preview flag for 'web-ext run' (#2436)
1 parent 78039fd commit 89ccc55

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

src/cmd/run.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export type CmdRunParams = {|
4343
startUrl?: Array<string>,
4444
target?: Array<string>,
4545
args?: Array<string>,
46+
firefoxPreview: Array<string>,
4647

4748
// Android CLI options.
4849
adbBin?: string,
@@ -89,6 +90,7 @@ export default async function run(
8990
startUrl,
9091
target,
9192
args,
93+
firefoxPreview = [],
9294
// Android CLI options.
9395
adbBin,
9496
adbHost,
@@ -126,7 +128,12 @@ export default async function run(
126128

127129
// Create an alias for --pref since it has been transformed into an
128130
// object containing one or more preferences.
129-
const customPrefs = pref;
131+
const customPrefs: FirefoxPreferences = {...pref};
132+
if (firefoxPreview.includes('mv3')) {
133+
log.info('Configuring Firefox preferences for Manifest V3');
134+
customPrefs['extensions.manifestV3.enabled'] = true;
135+
}
136+
130137
const manifestData = await getValidatedManifest(sourceDir);
131138

132139
const profileDir = firefoxProfile || chromiumProfile;

src/program.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,12 @@ Example: $0 --help run.
691691
demandOption: false,
692692
type: 'array',
693693
},
694+
'firefox-preview': {
695+
describe: 'Turn on developer preview features in Firefox',
696+
demandOption: false,
697+
default: ['mv3'],
698+
type: 'array',
699+
},
694700
// Firefox for Android CLI options.
695701
'adb-bin': {
696702
describe: 'Specify a custom path to the adb binary',

tests/unit/test-cmd/test.run.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,4 +454,22 @@ describe('run', () => {
454454
);
455455
});
456456
});
457+
458+
describe('firefox-preview', () => {
459+
it('supports the MV3 preview', async () => {
460+
const cmd = await prepareRun();
461+
const runOptions = {
462+
firefoxPreview: ['mv3'],
463+
};
464+
465+
await cmd.run(runOptions);
466+
467+
sinon.assert.calledOnce(desktopRunnerStub);
468+
const runnerParams = desktopRunnerStub.firstCall.args[0];
469+
470+
assert.deepEqual(runnerParams.customPrefs, {
471+
'extensions.manifestV3.enabled': true,
472+
});
473+
});
474+
});
457475
});

tests/unit/test.program.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,16 @@ describe('program.main', () => {
912912
}
913913
});
914914

915+
it('sets the default firefox preview to "mv3"', async () => {
916+
const fakeCommands = fake(commands, {
917+
run: () => Promise.resolve(),
918+
});
919+
920+
await execProgram(['run', '--firefox-preview'], {commands: fakeCommands});
921+
922+
const {firefoxPreview} = fakeCommands.run.firstCall.args[0];
923+
assert.deepEqual(firefoxPreview, ['mv3']);
924+
});
915925
});
916926

917927
describe('program.defaultVersionGetter', () => {

0 commit comments

Comments
 (0)