Skip to content

Commit 3ad3485

Browse files
committed
feat: support --pref in "web-ext run" for Android
1 parent 64342ef commit 3ad3485

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/extension-runners/firefox-android.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,17 @@ export class FirefoxAndroidExtensionRunner {
423423
selectedAdbDevice,
424424
selectedFirefoxApk,
425425
params: {
426+
customPrefs,
426427
firefoxApp,
427428
},
428429
} = this;
429430
// Create the preferences file and the Fennec temporary profile.
430431
log.debug(`Preparing a temporary profile for ${selectedFirefoxApk}...`);
431432

432-
const profile = await firefoxApp.createProfile({app: 'fennec'});
433+
const profile = await firefoxApp.createProfile({
434+
app: 'fennec',
435+
customPrefs,
436+
});
433437

434438
// Choose a artifacts dir name for the assets pushed to the
435439
// Android device.

tests/unit/test-extension-runners/test.firefox-android.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,31 @@ describe('util/extension-runners/firefox-android', () => {
351351
);
352352
});
353353

354+
it('supports custom prefs via --pref', async () => {
355+
const fakeFirefoxApp = {
356+
createProfile: sinon.spy(() => {
357+
return Promise.resolve({profileDir: '/path/to/fake/profile'});
358+
}),
359+
};
360+
const {params} = prepareSelectedDeviceAndAPKParams({
361+
fakeFirefoxApp,
362+
});
363+
364+
// cmd/run.js maps --pref to customPrefs.
365+
params.customPrefs = {'some.pref.name': 123};
366+
367+
const runnerInstance = new FirefoxAndroidExtensionRunner(params);
368+
await runnerInstance.run();
369+
370+
sinon.assert.calledWithMatch(
371+
fakeFirefoxApp.createProfile,
372+
{
373+
app: 'fennec',
374+
customPrefs: {'some.pref.name': 123},
375+
},
376+
);
377+
});
378+
354379
it('builds and pushes the extension xpi to the android device',
355380
async () => {
356381
const {

0 commit comments

Comments
 (0)