web-ext 7.2.0 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/cmd/build.js +18 -36
- package/lib/cmd/build.js.map +1 -1
- package/lib/cmd/docs.js +1 -0
- package/lib/cmd/docs.js.map +1 -1
- package/lib/cmd/index.js +3 -5
- package/lib/cmd/index.js.map +1 -1
- package/lib/cmd/lint.js +28 -17
- package/lib/cmd/lint.js.map +1 -1
- package/lib/cmd/run.js +19 -23
- package/lib/cmd/run.js.map +1 -1
- package/lib/cmd/sign.js +80 -47
- package/lib/cmd/sign.js.map +1 -1
- package/lib/config.js +18 -29
- package/lib/config.js.map +1 -1
- package/lib/errors.js +8 -18
- package/lib/errors.js.map +1 -1
- package/lib/extension-runners/base.js +2 -0
- package/lib/extension-runners/base.js.map +1 -1
- package/lib/extension-runners/chromium.js +36 -62
- package/lib/extension-runners/chromium.js.map +1 -1
- package/lib/extension-runners/firefox-android.js +65 -102
- package/lib/extension-runners/firefox-android.js.map +1 -1
- package/lib/extension-runners/firefox-desktop.js +29 -42
- package/lib/extension-runners/firefox-desktop.js.map +1 -1
- package/lib/extension-runners/index.js +33 -46
- package/lib/extension-runners/index.js.map +1 -1
- package/lib/firefox/index.js +59 -52
- package/lib/firefox/index.js.map +1 -1
- package/lib/firefox/package-identifiers.js +2 -0
- package/lib/firefox/package-identifiers.js.map +1 -1
- package/lib/firefox/preferences.js +14 -15
- package/lib/firefox/preferences.js.map +1 -1
- package/lib/firefox/rdp-client.js +16 -64
- package/lib/firefox/rdp-client.js.map +1 -1
- package/lib/firefox/remote.js +15 -30
- package/lib/firefox/remote.js.map +1 -1
- package/lib/main.js +4 -2
- package/lib/main.js.map +1 -1
- package/lib/program.js +74 -76
- package/lib/program.js.map +1 -1
- package/lib/util/adb.js +33 -63
- package/lib/util/adb.js.map +1 -1
- package/lib/util/artifacts.js +3 -5
- package/lib/util/artifacts.js.map +1 -1
- package/lib/util/desktop-notifier.js +1 -0
- package/lib/util/desktop-notifier.js.map +1 -1
- package/lib/util/file-exists.js +1 -2
- package/lib/util/file-exists.js.map +1 -1
- package/lib/util/file-filter.js +17 -19
- package/lib/util/file-filter.js.map +1 -1
- package/lib/util/is-directory.js +2 -1
- package/lib/util/is-directory.js.map +1 -1
- package/lib/util/logger.js +7 -12
- package/lib/util/logger.js.map +1 -1
- package/lib/util/manifest.js +6 -13
- package/lib/util/manifest.js.map +1 -1
- package/lib/util/promisify.js +7 -3
- package/lib/util/promisify.js.map +1 -1
- package/lib/util/stdin.js +2 -0
- package/lib/util/stdin.js.map +1 -1
- package/lib/util/submit-addon.js +288 -0
- package/lib/util/submit-addon.js.map +1 -0
- package/lib/util/temp-dir.js +8 -18
- package/lib/util/temp-dir.js.map +1 -1
- package/lib/util/updates.js +1 -1
- package/lib/util/updates.js.map +1 -1
- package/lib/watcher.js +14 -9
- package/lib/watcher.js.map +1 -1
- package/package.json +16 -14
package/lib/firefox/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
import nodeFs from 'fs';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
import { promisify } from 'util';
|
|
@@ -10,7 +11,8 @@ import { isErrorWithCode, UsageError, WebExtError } from '../errors.js';
|
|
|
10
11
|
import { getPrefs as defaultPrefGetter } from './preferences.js';
|
|
11
12
|
import { getManifestId } from '../util/manifest.js';
|
|
12
13
|
import { findFreeTcpPort as defaultRemotePortFinder } from './remote.js';
|
|
13
|
-
import { createLogger } from '../util/logger.js';
|
|
14
|
+
import { createLogger } from '../util/logger.js';
|
|
15
|
+
// Import flow types
|
|
14
16
|
|
|
15
17
|
const log = createLogger(import.meta.url);
|
|
16
18
|
const defaultAsyncFsStat = fs.stat.bind(fs);
|
|
@@ -18,7 +20,9 @@ const defaultUserProfileCopier = FirefoxProfile.copyFromUserProfile;
|
|
|
18
20
|
export const defaultFirefoxEnv = {
|
|
19
21
|
XPCOM_DEBUG_BREAK: 'stack',
|
|
20
22
|
NS_TRACE_MALLOC_DISABLE_STACKS: '1'
|
|
21
|
-
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// defaultRemotePortFinder types and implementation.
|
|
22
26
|
|
|
23
27
|
/*
|
|
24
28
|
* Runs Firefox with the given profile object and resolves a promise on exit.
|
|
@@ -28,27 +32,29 @@ export async function run(profile, {
|
|
|
28
32
|
findRemotePort = defaultRemotePortFinder,
|
|
29
33
|
firefoxBinary,
|
|
30
34
|
binaryArgs,
|
|
31
|
-
extensions
|
|
35
|
+
extensions,
|
|
36
|
+
devtools
|
|
32
37
|
} = {}) {
|
|
33
38
|
log.debug(`Running Firefox with profile at ${profile.path()}`);
|
|
34
39
|
const remotePort = await findRemotePort();
|
|
35
|
-
|
|
36
40
|
if (firefoxBinary && firefoxBinary.startsWith('flatpak:')) {
|
|
37
41
|
const flatpakAppId = firefoxBinary.substring(8);
|
|
38
|
-
log.debug(`Configuring Firefox with flatpak: appId=${flatpakAppId}`);
|
|
42
|
+
log.debug(`Configuring Firefox with flatpak: appId=${flatpakAppId}`);
|
|
39
43
|
|
|
44
|
+
// This should be resolved by the fx-runner.
|
|
40
45
|
firefoxBinary = 'flatpak';
|
|
41
46
|
binaryArgs = ['run', `--filesystem=${profile.path()}`, ...extensions.map(({
|
|
42
47
|
sourceDir
|
|
43
|
-
}) => `--filesystem=${sourceDir}:ro`),
|
|
48
|
+
}) => `--filesystem=${sourceDir}:ro`),
|
|
49
|
+
// We need to share the network namespace because we want to connect to
|
|
44
50
|
// Firefox with the remote protocol. There is no way to tell flatpak to
|
|
45
51
|
// only expose a port AFAIK.
|
|
46
|
-
'--share=network',
|
|
52
|
+
'--share=network',
|
|
53
|
+
// Kill the entire sandbox when the launching process dies, which is what
|
|
47
54
|
// we want since exiting web-ext involves `kill` and the process executed
|
|
48
55
|
// here is `flatpak run`.
|
|
49
56
|
'--die-with-parent', flatpakAppId].concat(...(binaryArgs || []));
|
|
50
57
|
}
|
|
51
|
-
|
|
52
58
|
const results = await fxRunner({
|
|
53
59
|
// if this is falsey, fxRunner tries to find the default one.
|
|
54
60
|
'binary': firefoxBinary,
|
|
@@ -62,7 +68,8 @@ export async function run(profile, {
|
|
|
62
68
|
'listen': remotePort,
|
|
63
69
|
'foreground': true,
|
|
64
70
|
'profile': profile.path(),
|
|
65
|
-
'env': {
|
|
71
|
+
'env': {
|
|
72
|
+
...process.env,
|
|
66
73
|
...defaultFirefoxEnv
|
|
67
74
|
},
|
|
68
75
|
'verbose': true
|
|
@@ -76,7 +83,13 @@ export async function run(profile, {
|
|
|
76
83
|
log.error(`Firefox error: ${error}`);
|
|
77
84
|
throw error;
|
|
78
85
|
});
|
|
79
|
-
|
|
86
|
+
if (!devtools) {
|
|
87
|
+
log.info('Use --verbose or --devtools to see logging');
|
|
88
|
+
}
|
|
89
|
+
if (devtools) {
|
|
90
|
+
log.info('More info about WebExtensions debugging:');
|
|
91
|
+
log.info('https://extensionworkshop.com/documentation/develop/debugging/');
|
|
92
|
+
}
|
|
80
93
|
firefox.stderr.on('data', data => {
|
|
81
94
|
log.debug(`Firefox stderr: ${data.toString().trim()}`);
|
|
82
95
|
});
|
|
@@ -90,10 +103,11 @@ export async function run(profile, {
|
|
|
90
103
|
firefox,
|
|
91
104
|
debuggerPort: remotePort
|
|
92
105
|
};
|
|
93
|
-
}
|
|
106
|
+
}
|
|
94
107
|
|
|
95
|
-
|
|
108
|
+
// isDefaultProfile types and implementation.
|
|
96
109
|
|
|
110
|
+
const DEFAULT_PROFILES_NAMES = ['default', 'dev-edition-default'];
|
|
97
111
|
/*
|
|
98
112
|
* Tests if a profile is a default Firefox profile (both as a profile name or
|
|
99
113
|
* profile path).
|
|
@@ -104,56 +118,56 @@ export async function isDefaultProfile(profilePathOrName, ProfileFinder = Firefo
|
|
|
104
118
|
if (DEFAULT_PROFILES_NAMES.includes(profilePathOrName)) {
|
|
105
119
|
return true;
|
|
106
120
|
}
|
|
107
|
-
|
|
108
121
|
const baseProfileDir = ProfileFinder.locateUserDirectory();
|
|
109
122
|
const profilesIniPath = path.join(baseProfileDir, 'profiles.ini');
|
|
110
|
-
|
|
111
123
|
try {
|
|
112
124
|
await fsStat(profilesIniPath);
|
|
113
125
|
} catch (error) {
|
|
114
126
|
if (isErrorWithCode('ENOENT', error)) {
|
|
115
|
-
log.debug(`profiles.ini not found: ${error}`);
|
|
116
|
-
// random generated component).
|
|
127
|
+
log.debug(`profiles.ini not found: ${error}`);
|
|
117
128
|
|
|
129
|
+
// No profiles exist yet, default to false (the default profile name contains a
|
|
130
|
+
// random generated component).
|
|
118
131
|
return false;
|
|
119
|
-
}
|
|
120
|
-
|
|
132
|
+
}
|
|
121
133
|
|
|
134
|
+
// Re-throw any unexpected exception.
|
|
122
135
|
throw error;
|
|
123
|
-
}
|
|
124
|
-
|
|
136
|
+
}
|
|
125
137
|
|
|
138
|
+
// Check for profile dir path.
|
|
126
139
|
const finder = new ProfileFinder(baseProfileDir);
|
|
127
140
|
const readProfiles = promisify((...args) => finder.readProfiles(...args));
|
|
128
141
|
await readProfiles();
|
|
129
142
|
const normalizedProfileDirPath = path.normalize(path.join(path.resolve(profilePathOrName), path.sep));
|
|
130
|
-
|
|
131
143
|
for (const profile of finder.profiles) {
|
|
132
144
|
// Check if the profile dir path or name is one of the default profiles
|
|
133
145
|
// defined in the profiles.ini file.
|
|
134
146
|
if (DEFAULT_PROFILES_NAMES.includes(profile.Name) || profile.Default === '1') {
|
|
135
|
-
let profileFullPath;
|
|
147
|
+
let profileFullPath;
|
|
136
148
|
|
|
149
|
+
// Check for profile name.
|
|
137
150
|
if (profile.Name === profilePathOrName) {
|
|
138
151
|
return true;
|
|
139
|
-
}
|
|
140
|
-
|
|
152
|
+
}
|
|
141
153
|
|
|
154
|
+
// Check for profile path.
|
|
142
155
|
if (profile.IsRelative === '1') {
|
|
143
156
|
profileFullPath = path.join(baseProfileDir, profile.Path, path.sep);
|
|
144
157
|
} else {
|
|
145
158
|
profileFullPath = path.join(profile.Path, path.sep);
|
|
146
159
|
}
|
|
147
|
-
|
|
148
160
|
if (path.normalize(profileFullPath) === normalizedProfileDirPath) {
|
|
149
161
|
return true;
|
|
150
162
|
}
|
|
151
163
|
}
|
|
152
|
-
}
|
|
153
|
-
|
|
164
|
+
}
|
|
154
165
|
|
|
166
|
+
// Profile directory not found.
|
|
155
167
|
return false;
|
|
156
|
-
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// configureProfile types and implementation.
|
|
157
171
|
|
|
158
172
|
/*
|
|
159
173
|
* Configures a profile with common preferences that are required to
|
|
@@ -172,7 +186,6 @@ export function configureProfile(profile, {
|
|
|
172
186
|
Object.keys(prefs).forEach(pref => {
|
|
173
187
|
profile.setPreference(pref, prefs[pref]);
|
|
174
188
|
});
|
|
175
|
-
|
|
176
189
|
if (Object.keys(customPrefs).length > 0) {
|
|
177
190
|
const customPrefsStr = JSON.stringify(customPrefs, null, 2);
|
|
178
191
|
log.info(`Setting custom Firefox preferences: ${customPrefsStr}`);
|
|
@@ -180,7 +193,6 @@ export function configureProfile(profile, {
|
|
|
180
193
|
profile.setPreference(custom, customPrefs[custom]);
|
|
181
194
|
});
|
|
182
195
|
}
|
|
183
|
-
|
|
184
196
|
profile.updatePreferences();
|
|
185
197
|
return Promise.resolve(profile);
|
|
186
198
|
}
|
|
@@ -195,7 +207,6 @@ export function defaultCreateProfileFinder({
|
|
|
195
207
|
try {
|
|
196
208
|
await readProfiles();
|
|
197
209
|
const hasProfileName = finder.profiles.filter(profileDef => profileDef.Name === profileName).length !== 0;
|
|
198
|
-
|
|
199
210
|
if (hasProfileName) {
|
|
200
211
|
return await getPath(profileName);
|
|
201
212
|
}
|
|
@@ -203,13 +214,15 @@ export function defaultCreateProfileFinder({
|
|
|
203
214
|
if (!isErrorWithCode('ENOENT', error)) {
|
|
204
215
|
throw error;
|
|
205
216
|
}
|
|
206
|
-
|
|
207
217
|
log.warn('Unable to find Firefox profiles.ini');
|
|
208
218
|
}
|
|
209
219
|
};
|
|
210
|
-
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// useProfile types and implementation.
|
|
211
223
|
|
|
212
224
|
// Use the target path as a Firefox profile without cloning it
|
|
225
|
+
|
|
213
226
|
export async function useProfile(profilePath, {
|
|
214
227
|
app,
|
|
215
228
|
configureThisProfile = configureProfile,
|
|
@@ -218,27 +231,22 @@ export async function useProfile(profilePath, {
|
|
|
218
231
|
createProfileFinder = defaultCreateProfileFinder
|
|
219
232
|
} = {}) {
|
|
220
233
|
const isForbiddenProfile = await isFirefoxDefaultProfile(profilePath);
|
|
221
|
-
|
|
222
234
|
if (isForbiddenProfile) {
|
|
223
235
|
throw new UsageError('Cannot use --keep-profile-changes on a default profile' + ` ("${profilePath}")` + ' because web-ext will make it insecure and unsuitable for daily use.' + '\nSee https://github.com/mozilla/web-ext/issues/1005');
|
|
224
236
|
}
|
|
225
|
-
|
|
226
237
|
let destinationDirectory;
|
|
227
238
|
const getProfilePath = createProfileFinder();
|
|
228
239
|
const profileIsDirPath = await isDirectory(profilePath);
|
|
229
|
-
|
|
230
240
|
if (profileIsDirPath) {
|
|
231
241
|
log.debug(`Using profile directory "${profilePath}"`);
|
|
232
242
|
destinationDirectory = profilePath;
|
|
233
243
|
} else {
|
|
234
244
|
log.debug(`Assuming ${profilePath} is a named profile`);
|
|
235
245
|
destinationDirectory = await getProfilePath(profilePath);
|
|
236
|
-
|
|
237
246
|
if (!destinationDirectory) {
|
|
238
247
|
throw new UsageError(`The request "${profilePath}" profile name ` + 'cannot be resolved to a profile path');
|
|
239
248
|
}
|
|
240
249
|
}
|
|
241
|
-
|
|
242
250
|
const profile = new FirefoxProfile({
|
|
243
251
|
destinationDirectory
|
|
244
252
|
});
|
|
@@ -246,7 +254,9 @@ export async function useProfile(profilePath, {
|
|
|
246
254
|
app,
|
|
247
255
|
customPrefs
|
|
248
256
|
});
|
|
249
|
-
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// createProfile types and implementation.
|
|
250
260
|
|
|
251
261
|
/*
|
|
252
262
|
* Creates a new temporary profile and resolves with the profile object.
|
|
@@ -263,7 +273,9 @@ export async function createProfile({
|
|
|
263
273
|
app,
|
|
264
274
|
customPrefs
|
|
265
275
|
});
|
|
266
|
-
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// copyProfile types and implementation.
|
|
267
279
|
|
|
268
280
|
/*
|
|
269
281
|
* Copies an existing Firefox profile and creates a new temporary profile.
|
|
@@ -285,11 +297,9 @@ export async function copyProfile(profileDirectory, {
|
|
|
285
297
|
} = {}) {
|
|
286
298
|
const copy = promisify(FirefoxProfile.copy);
|
|
287
299
|
const copyByName = promisify(copyFromUserProfile);
|
|
288
|
-
|
|
289
300
|
try {
|
|
290
301
|
const dirExists = await isDirectory(profileDirectory);
|
|
291
302
|
let profile;
|
|
292
|
-
|
|
293
303
|
if (dirExists) {
|
|
294
304
|
log.debug(`Copying profile directory from "${profileDirectory}"`);
|
|
295
305
|
profile = await copy({
|
|
@@ -301,7 +311,6 @@ export async function copyProfile(profileDirectory, {
|
|
|
301
311
|
name: profileDirectory
|
|
302
312
|
});
|
|
303
313
|
}
|
|
304
|
-
|
|
305
314
|
return configureThisProfile(profile, {
|
|
306
315
|
app,
|
|
307
316
|
customPrefs
|
|
@@ -309,7 +318,9 @@ export async function copyProfile(profileDirectory, {
|
|
|
309
318
|
} catch (error) {
|
|
310
319
|
throw new WebExtError(`Could not copy Firefox profile from ${profileDirectory}: ${error}`);
|
|
311
320
|
}
|
|
312
|
-
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// installExtension types and implementation.
|
|
313
324
|
|
|
314
325
|
/*
|
|
315
326
|
* Installs an extension into the given Firefox profile object.
|
|
@@ -333,10 +344,10 @@ export async function installExtension({
|
|
|
333
344
|
// https://github.com/saadtazi/firefox-profile-js/blob/master/lib/firefox_profile.js#L531
|
|
334
345
|
// (which is broken for web extensions).
|
|
335
346
|
// TODO: maybe uplift a patch that supports web extensions instead?
|
|
347
|
+
|
|
336
348
|
if (!profile.extensionsDir) {
|
|
337
349
|
throw new WebExtError('profile.extensionsDir was unexpectedly empty');
|
|
338
350
|
}
|
|
339
|
-
|
|
340
351
|
try {
|
|
341
352
|
await asyncFsStat(profile.extensionsDir);
|
|
342
353
|
} catch (error) {
|
|
@@ -347,24 +358,20 @@ export async function installExtension({
|
|
|
347
358
|
throw error;
|
|
348
359
|
}
|
|
349
360
|
}
|
|
350
|
-
|
|
351
361
|
const id = getManifestId(manifestData);
|
|
352
|
-
|
|
353
362
|
if (!id) {
|
|
354
363
|
throw new UsageError('An explicit extension ID is required when installing to ' + 'a profile (applications.gecko.id not found in manifest.json)');
|
|
355
364
|
}
|
|
356
|
-
|
|
357
365
|
if (asProxy) {
|
|
358
366
|
log.debug(`Installing as an extension proxy; source: ${extensionPath}`);
|
|
359
367
|
const isDir = await isDirectory(extensionPath);
|
|
360
|
-
|
|
361
368
|
if (!isDir) {
|
|
362
369
|
throw new WebExtError('proxy install: extensionPath must be the extension source ' + `directory; got: ${extensionPath}`);
|
|
363
|
-
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Write a special extension proxy file containing the source
|
|
364
373
|
// directory. See:
|
|
365
374
|
// https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment#Firefox_extension_proxy_file
|
|
366
|
-
|
|
367
|
-
|
|
368
375
|
const destPath = path.join(profile.extensionsDir, `${id}`);
|
|
369
376
|
const writeStream = nodeFs.createWriteStream(destPath);
|
|
370
377
|
writeStream.write(extensionPath);
|
package/lib/firefox/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["nodeFs","path","promisify","default","defaultFxRunner","FirefoxProfile","fs","fromEvent","isDirectory","isErrorWithCode","UsageError","WebExtError","getPrefs","defaultPrefGetter","getManifestId","findFreeTcpPort","defaultRemotePortFinder","createLogger","log","import","meta","url","defaultAsyncFsStat","stat","bind","defaultUserProfileCopier","copyFromUserProfile","defaultFirefoxEnv","XPCOM_DEBUG_BREAK","NS_TRACE_MALLOC_DISABLE_STACKS","run","profile","fxRunner","findRemotePort","firefoxBinary","binaryArgs","extensions","debug","remotePort","startsWith","flatpakAppId","substring","map","sourceDir","concat","results","process","env","firefox","binary","args","join","on","error","info","stderr","data","toString","trim","stdout","debuggerPort","DEFAULT_PROFILES_NAMES","isDefaultProfile","profilePathOrName","ProfileFinder","Finder","fsStat","includes","baseProfileDir","locateUserDirectory","profilesIniPath","finder","readProfiles","normalizedProfileDirPath","normalize","resolve","sep","profiles","Name","Default","profileFullPath","IsRelative","Path","configureProfile","app","customPrefs","prefs","Object","keys","forEach","pref","setPreference","length","customPrefsStr","JSON","stringify","custom","updatePreferences","Promise","defaultCreateProfileFinder","userDirectoryPath","FxProfile","getPath","profileName","hasProfileName","filter","profileDef","warn","useProfile","profilePath","configureThisProfile","isFirefoxDefaultProfile","createProfileFinder","isForbiddenProfile","destinationDirectory","getProfilePath","profileIsDirPath","createProfile","copyProfile","profileDirectory","copy","copyByName","dirExists","name","installExtension","asProxy","manifestData","extensionPath","asyncFsStat","extensionsDir","mkdir","id","isDir","destPath","writeStream","createWriteStream","write","end","readStream","createReadStream","pipe","all"],"sources":["../../src/firefox/index.js"],"sourcesContent":["/* @flow */\nimport nodeFs from 'fs';\nimport path from 'path';\nimport {promisify} from 'util';\n\nimport {default as defaultFxRunner} from 'fx-runner';\nimport FirefoxProfile from 'firefox-profile';\nimport {fs} from 'mz';\nimport fromEvent from 'promise-toolbox/fromEvent';\n\nimport isDirectory from '../util/is-directory.js';\nimport {isErrorWithCode, UsageError, WebExtError} from '../errors.js';\nimport {getPrefs as defaultPrefGetter} from './preferences.js';\nimport {getManifestId} from '../util/manifest.js';\nimport {findFreeTcpPort as defaultRemotePortFinder} from './remote.js';\nimport {createLogger} from '../util/logger.js';\n// Import flow types\nimport type {\n PreferencesAppName,\n PreferencesGetterFn,\n FirefoxPreferences,\n} from './preferences';\nimport type {ExtensionManifest} from '../util/manifest.js';\nimport type {Extension} from '../extension-runners/base.js';\n\n\nconst log = createLogger(import.meta.url);\n\nconst defaultAsyncFsStat: typeof fs.stat = fs.stat.bind(fs);\n\nconst defaultUserProfileCopier = FirefoxProfile.copyFromUserProfile;\n\nexport const defaultFirefoxEnv = {\n XPCOM_DEBUG_BREAK: 'stack',\n NS_TRACE_MALLOC_DISABLE_STACKS: '1',\n};\n\n// defaultRemotePortFinder types and implementation.\n\n\nexport type RemotePortFinderFn =\n () => Promise<number>;\n\n// Declare the needed 'fx-runner' module flow types.\n\nexport type FirefoxRunnerParams = {|\n binary: ?string,\n profile?: string,\n 'new-instance'?: boolean,\n 'no-remote'?: boolean,\n 'foreground'?: boolean,\n 'listen': number,\n 'binary-args'?: Array<string> | string,\n 'binary-args-first'?: boolean,\n 'env'?: {\n // This match the flowtype signature for process.env (and prevent flow\n // from complaining about differences between their type signature)\n [key: string]: string | void\n },\n 'verbose'?: boolean,\n|};\n\nexport interface FirefoxProcess extends events$EventEmitter {\n stderr: events$EventEmitter;\n stdout: events$EventEmitter;\n kill: Function;\n}\n\nexport type FirefoxRunnerResults = {|\n process: FirefoxProcess,\n binary: string,\n args: Array<string>,\n|}\n\nexport type FirefoxRunnerFn =\n (params: FirefoxRunnerParams) => Promise<FirefoxRunnerResults>;\n\n\nexport type FirefoxInfo = {|\n firefox: FirefoxProcess,\n debuggerPort: number,\n|}\n\n// Run command types and implementaion.\n\nexport type FirefoxRunOptions = {\n fxRunner?: FirefoxRunnerFn,\n findRemotePort?: RemotePortFinderFn,\n firefoxBinary?: string,\n binaryArgs?: Array<string>,\n args?: Array<any>,\n extensions: Array<Extension>,\n};\n\n/*\n * Runs Firefox with the given profile object and resolves a promise on exit.\n */\nexport async function run(\n profile: FirefoxProfile,\n {\n fxRunner = defaultFxRunner,\n findRemotePort = defaultRemotePortFinder,\n firefoxBinary,\n binaryArgs,\n extensions,\n }: FirefoxRunOptions = {}\n): Promise<FirefoxInfo> {\n\n log.debug(`Running Firefox with profile at ${profile.path()}`);\n\n const remotePort = await findRemotePort();\n\n if (firefoxBinary && firefoxBinary.startsWith('flatpak:')) {\n const flatpakAppId = firefoxBinary.substring(8);\n log.debug(`Configuring Firefox with flatpak: appId=${flatpakAppId}`);\n\n // This should be resolved by the fx-runner.\n firefoxBinary = 'flatpak';\n binaryArgs = [\n 'run',\n `--filesystem=${profile.path()}`,\n ...extensions.map(({ sourceDir }) => `--filesystem=${sourceDir}:ro`),\n // We need to share the network namespace because we want to connect to\n // Firefox with the remote protocol. There is no way to tell flatpak to\n // only expose a port AFAIK.\n '--share=network',\n // Kill the entire sandbox when the launching process dies, which is what\n // we want since exiting web-ext involves `kill` and the process executed\n // here is `flatpak run`.\n '--die-with-parent',\n flatpakAppId,\n ].concat(...(binaryArgs || []));\n }\n\n const results = await fxRunner({\n // if this is falsey, fxRunner tries to find the default one.\n 'binary': firefoxBinary,\n 'binary-args': binaryArgs,\n // For Flatpak we need to respect the order of the command arguments because\n // we have arguments for Flapack (first) and then Firefox.\n 'binary-args-first': firefoxBinary === 'flatpak',\n // This ensures a new instance of Firefox is created. It has nothing\n // to do with the devtools remote debugger.\n 'no-remote': true,\n 'listen': remotePort,\n 'foreground': true,\n 'profile': profile.path(),\n 'env': {\n ...process.env,\n ...defaultFirefoxEnv,\n },\n 'verbose': true,\n });\n\n const firefox = results.process;\n\n log.debug(`Executing Firefox binary: ${results.binary}`);\n log.debug(`Firefox args: ${results.args.join(' ')}`);\n\n firefox.on('error', (error) => {\n // TODO: show a nice error when it can't find Firefox.\n // if (/No such file/.test(err) || err.code === 'ENOENT') {\n log.error(`Firefox error: ${error}`);\n throw error;\n });\n\n log.info(\n 'Use --verbose or open Tools > Web Developer > Browser Console ' +\n 'to see logging');\n\n firefox.stderr.on('data', (data) => {\n log.debug(`Firefox stderr: ${data.toString().trim()}`);\n });\n\n firefox.stdout.on('data', (data) => {\n log.debug(`Firefox stdout: ${data.toString().trim()}`);\n });\n\n firefox.on('close', () => {\n log.debug('Firefox closed');\n });\n\n return { firefox, debuggerPort: remotePort };\n}\n\n\n// isDefaultProfile types and implementation.\n\nconst DEFAULT_PROFILES_NAMES = [\n 'default',\n 'dev-edition-default',\n];\n\nexport type IsDefaultProfileFn = (\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder,\n fsStat?: typeof fs.stat,\n) => Promise<boolean>;\n\n/*\n * Tests if a profile is a default Firefox profile (both as a profile name or\n * profile path).\n *\n * Returns a promise that resolves to true if the profile is one of default Firefox profile.\n */\nexport async function isDefaultProfile(\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder = FirefoxProfile.Finder,\n fsStat?: typeof fs.stat = fs.stat,\n): Promise<boolean> {\n if (DEFAULT_PROFILES_NAMES.includes(profilePathOrName)) {\n return true;\n }\n\n const baseProfileDir = ProfileFinder.locateUserDirectory();\n const profilesIniPath = path.join(baseProfileDir, 'profiles.ini');\n try {\n await fsStat(profilesIniPath);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`profiles.ini not found: ${error}`);\n\n // No profiles exist yet, default to false (the default profile name contains a\n // random generated component).\n return false;\n }\n\n // Re-throw any unexpected exception.\n throw error;\n }\n\n // Check for profile dir path.\n const finder = new ProfileFinder(baseProfileDir);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n\n await readProfiles();\n\n const normalizedProfileDirPath = path.normalize(\n path.join(path.resolve(profilePathOrName), path.sep)\n );\n\n for (const profile of finder.profiles) {\n // Check if the profile dir path or name is one of the default profiles\n // defined in the profiles.ini file.\n if (DEFAULT_PROFILES_NAMES.includes(profile.Name) ||\n profile.Default === '1') {\n let profileFullPath;\n\n // Check for profile name.\n if (profile.Name === profilePathOrName) {\n return true;\n }\n\n // Check for profile path.\n if (profile.IsRelative === '1') {\n profileFullPath = path.join(baseProfileDir, profile.Path, path.sep);\n } else {\n profileFullPath = path.join(profile.Path, path.sep);\n }\n\n if (path.normalize(profileFullPath) === normalizedProfileDirPath) {\n return true;\n }\n }\n }\n\n // Profile directory not found.\n return false;\n}\n\n// configureProfile types and implementation.\n\nexport type ConfigureProfileOptions = {\n app?: PreferencesAppName,\n getPrefs?: PreferencesGetterFn,\n customPrefs?: FirefoxPreferences,\n};\n\nexport type ConfigureProfileFn = (\n profile: FirefoxProfile,\n options?: ConfigureProfileOptions\n) => Promise<FirefoxProfile>;\n\n/*\n * Configures a profile with common preferences that are required to\n * activate extension development.\n *\n * Returns a promise that resolves with the original profile object.\n */\nexport function configureProfile(\n profile: FirefoxProfile,\n {\n app = 'firefox',\n getPrefs = defaultPrefGetter,\n customPrefs = {},\n }: ConfigureProfileOptions = {},\n): Promise<FirefoxProfile> {\n // Set default preferences. Some of these are required for the add-on to\n // operate, such as disabling signatures.\n const prefs = getPrefs(app);\n Object.keys(prefs).forEach((pref) => {\n profile.setPreference(pref, prefs[pref]);\n });\n if (Object.keys(customPrefs).length > 0) {\n const customPrefsStr = JSON.stringify(customPrefs, null, 2);\n log.info(`Setting custom Firefox preferences: ${customPrefsStr}`);\n Object.keys(customPrefs).forEach((custom) => {\n profile.setPreference(custom, customPrefs[custom]);\n });\n }\n profile.updatePreferences();\n return Promise.resolve(profile);\n}\n\nexport type getProfileFn = (profileName: string) => Promise<string | void>;\n\nexport type CreateProfileFinderParams = {\n userDirectoryPath?: string,\n FxProfile?: typeof FirefoxProfile\n}\n\nexport function defaultCreateProfileFinder(\n {\n userDirectoryPath,\n FxProfile = FirefoxProfile,\n }: CreateProfileFinderParams = {}\n): getProfileFn {\n const finder = new FxProfile.Finder(userDirectoryPath);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n const getPath = promisify((...args) => finder.getPath(...args));\n return async (profileName: string): Promise<string | void> => {\n try {\n await readProfiles();\n const hasProfileName = finder.profiles.filter(\n (profileDef) => profileDef.Name === profileName).length !== 0;\n if (hasProfileName) {\n return await getPath(profileName);\n }\n } catch (error) {\n if (!isErrorWithCode('ENOENT', error)) {\n throw error;\n }\n log.warn('Unable to find Firefox profiles.ini');\n }\n };\n}\n\n// useProfile types and implementation.\n\nexport type UseProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n isFirefoxDefaultProfile?: IsDefaultProfileFn,\n customPrefs?: FirefoxPreferences,\n createProfileFinder?: typeof defaultCreateProfileFinder,\n};\n\n// Use the target path as a Firefox profile without cloning it\n\nexport async function useProfile(\n profilePath: string,\n {\n app,\n configureThisProfile = configureProfile,\n isFirefoxDefaultProfile = isDefaultProfile,\n customPrefs = {},\n createProfileFinder = defaultCreateProfileFinder,\n }: UseProfileParams = {},\n): Promise<FirefoxProfile> {\n const isForbiddenProfile = await isFirefoxDefaultProfile(profilePath);\n if (isForbiddenProfile) {\n throw new UsageError(\n 'Cannot use --keep-profile-changes on a default profile' +\n ` (\"${profilePath}\")` +\n ' because web-ext will make it insecure and unsuitable for daily use.' +\n '\\nSee https://github.com/mozilla/web-ext/issues/1005'\n );\n }\n\n let destinationDirectory;\n const getProfilePath = createProfileFinder();\n\n const profileIsDirPath = await isDirectory(profilePath);\n if (profileIsDirPath) {\n log.debug(`Using profile directory \"${profilePath}\"`);\n destinationDirectory = profilePath;\n } else {\n log.debug(`Assuming ${profilePath} is a named profile`);\n destinationDirectory = await getProfilePath(profilePath);\n if (!destinationDirectory) {\n throw new UsageError(\n `The request \"${profilePath}\" profile name ` +\n 'cannot be resolved to a profile path'\n );\n }\n }\n\n const profile = new FirefoxProfile({destinationDirectory});\n return await configureThisProfile(profile, {app, customPrefs});\n}\n\n\n// createProfile types and implementation.\n\nexport type CreateProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Creates a new temporary profile and resolves with the profile object.\n *\n * The profile will be deleted when the system process exits.\n */\nexport async function createProfile(\n {\n app,\n configureThisProfile = configureProfile,\n customPrefs = {},\n }: CreateProfileParams = {},\n): Promise<FirefoxProfile> {\n const profile = new FirefoxProfile();\n return await configureThisProfile(profile, {app, customPrefs});\n}\n\n\n// copyProfile types and implementation.\n\nexport type CopyProfileOptions = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n copyFromUserProfile?: Function,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Copies an existing Firefox profile and creates a new temporary profile.\n * The new profile will be configured with some preferences required to\n * activate extension development.\n *\n * It resolves with the new profile object.\n *\n * The temporary profile will be deleted when the system process exits.\n *\n * The existing profile can be specified as a directory path or a name of\n * one that exists in the current user's Firefox directory.\n */\nexport async function copyProfile(\n profileDirectory: string,\n {\n app,\n configureThisProfile = configureProfile,\n copyFromUserProfile = defaultUserProfileCopier,\n customPrefs = {},\n }: CopyProfileOptions = {},\n): Promise<FirefoxProfile> {\n\n const copy = promisify(FirefoxProfile.copy);\n const copyByName = promisify(copyFromUserProfile);\n\n try {\n const dirExists = await isDirectory(profileDirectory);\n\n let profile;\n\n if (dirExists) {\n log.debug(`Copying profile directory from \"${profileDirectory}\"`);\n profile = await copy({profileDirectory});\n } else {\n log.debug(`Assuming ${profileDirectory} is a named profile`);\n profile = await copyByName({name: profileDirectory});\n }\n\n return configureThisProfile(profile, {app, customPrefs});\n } catch (error) {\n throw new WebExtError(\n `Could not copy Firefox profile from ${profileDirectory}: ${error}`);\n }\n}\n\n\n// installExtension types and implementation.\n\nexport type InstallExtensionParams = {|\n asProxy?: boolean,\n manifestData: ExtensionManifest,\n profile: FirefoxProfile,\n extensionPath: string,\n asyncFsStat?: typeof defaultAsyncFsStat,\n|};\n\n/*\n * Installs an extension into the given Firefox profile object.\n * Resolves when complete.\n *\n * The extension is copied into a special location and you need to turn\n * on some preferences to allow this. See extensions.autoDisableScopes in\n * ./preferences.js.\n *\n * When asProxy is true, a special proxy file will be installed. This is a\n * text file that contains the path to the extension source.\n */\nexport async function installExtension(\n {\n asProxy = false,\n manifestData,\n profile,\n extensionPath,\n asyncFsStat = defaultAsyncFsStat,\n }: InstallExtensionParams): Promise<any> {\n // This more or less follows\n // https://github.com/saadtazi/firefox-profile-js/blob/master/lib/firefox_profile.js#L531\n // (which is broken for web extensions).\n // TODO: maybe uplift a patch that supports web extensions instead?\n\n if (!profile.extensionsDir) {\n throw new WebExtError('profile.extensionsDir was unexpectedly empty');\n }\n\n try {\n await asyncFsStat(profile.extensionsDir);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`Creating extensions directory: ${profile.extensionsDir}`);\n await fs.mkdir(profile.extensionsDir);\n } else {\n throw error;\n }\n }\n\n const id = getManifestId(manifestData);\n if (!id) {\n throw new UsageError(\n 'An explicit extension ID is required when installing to ' +\n 'a profile (applications.gecko.id not found in manifest.json)');\n }\n\n if (asProxy) {\n log.debug(`Installing as an extension proxy; source: ${extensionPath}`);\n\n const isDir = await isDirectory(extensionPath);\n if (!isDir) {\n throw new WebExtError(\n 'proxy install: extensionPath must be the extension source ' +\n `directory; got: ${extensionPath}`);\n }\n\n // Write a special extension proxy file containing the source\n // directory. See:\n // https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment#Firefox_extension_proxy_file\n const destPath = path.join(profile.extensionsDir, `${id}`);\n const writeStream = nodeFs.createWriteStream(destPath);\n writeStream.write(extensionPath);\n writeStream.end();\n return await fromEvent(writeStream, 'close');\n } else {\n // Write the XPI file to the profile.\n const readStream = nodeFs.createReadStream(extensionPath);\n const destPath = path.join(profile.extensionsDir, `${id}.xpi`);\n const writeStream = nodeFs.createWriteStream(destPath);\n\n log.debug(`Installing extension from ${extensionPath} to ${destPath}`);\n readStream.pipe(writeStream);\n\n return await Promise.all([\n fromEvent(readStream, 'close'),\n fromEvent(writeStream, 'close'),\n ]);\n }\n}\n"],"mappings":"AACA,OAAOA,MAAP,MAAmB,IAAnB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAAQC,SAAR,QAAwB,MAAxB;AAEA,SAAQC,OAAO,IAAIC,eAAnB,QAAyC,WAAzC;AACA,OAAOC,cAAP,MAA2B,iBAA3B;AACA,SAAQC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IAAIzH,WAAJ,CACJ,+DACC,mBAAkBoH,aAAc,EAF7B,CAAN;IAGD,CARU,CAUX;IACA;IACA;;;IACA,MAAMM,QAAQ,GAAGpI,IAAI,CAACkD,IAAL,CAAUpB,OAAO,CAACkG,aAAlB,EAAkC,GAAEE,EAAG,EAAvC,CAAjB;IACA,MAAMG,WAAW,GAAGtI,MAAM,CAACuI,iBAAP,CAAyBF,QAAzB,CAApB;IACAC,WAAW,CAACE,KAAZ,CAAkBT,aAAlB;IACAO,WAAW,CAACG,GAAZ;IACA,OAAO,MAAMlI,SAAS,CAAC+H,WAAD,EAAc,OAAd,CAAtB;EACD,CAlBD,MAkBO;IACL;IACA,MAAMI,UAAU,GAAG1I,MAAM,CAAC2I,gBAAP,CAAwBZ,aAAxB,CAAnB;IACA,MAAMM,QAAQ,GAAGpI,IAAI,CAACkD,IAAL,CAAUpB,OAAO,CAACkG,aAAlB,EAAkC,GAAEE,EAAG,MAAvC,CAAjB;IACA,MAAMG,WAAW,GAAGtI,MAAM,CAACuI,iBAAP,CAAyBF,QAAzB,CAApB;IAEAnH,GAAG,CAACmB,KAAJ,CAAW,6BAA4B0F,aAAc,OAAMM,QAAS,EAApE;IACAK,UAAU,CAACE,IAAX,CAAgBN,WAAhB;IAEA,OAAO,MAAMpC,OAAO,CAAC2C,GAAR,CAAY,CACvBtI,SAAS,CAACmI,UAAD,EAAa,OAAb,CADc,EAEvBnI,SAAS,CAAC+H,WAAD,EAAc,OAAd,CAFc,CAAZ,CAAb;EAID;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["nodeFs","path","promisify","default","defaultFxRunner","FirefoxProfile","fs","fromEvent","isDirectory","isErrorWithCode","UsageError","WebExtError","getPrefs","defaultPrefGetter","getManifestId","findFreeTcpPort","defaultRemotePortFinder","createLogger","log","import","meta","url","defaultAsyncFsStat","stat","bind","defaultUserProfileCopier","copyFromUserProfile","defaultFirefoxEnv","XPCOM_DEBUG_BREAK","NS_TRACE_MALLOC_DISABLE_STACKS","run","profile","fxRunner","findRemotePort","firefoxBinary","binaryArgs","extensions","devtools","debug","remotePort","startsWith","flatpakAppId","substring","map","sourceDir","concat","results","process","env","firefox","binary","args","join","on","error","info","stderr","data","toString","trim","stdout","debuggerPort","DEFAULT_PROFILES_NAMES","isDefaultProfile","profilePathOrName","ProfileFinder","Finder","fsStat","includes","baseProfileDir","locateUserDirectory","profilesIniPath","finder","readProfiles","normalizedProfileDirPath","normalize","resolve","sep","profiles","Name","Default","profileFullPath","IsRelative","Path","configureProfile","app","customPrefs","prefs","Object","keys","forEach","pref","setPreference","length","customPrefsStr","JSON","stringify","custom","updatePreferences","Promise","defaultCreateProfileFinder","userDirectoryPath","FxProfile","getPath","profileName","hasProfileName","filter","profileDef","warn","useProfile","profilePath","configureThisProfile","isFirefoxDefaultProfile","createProfileFinder","isForbiddenProfile","destinationDirectory","getProfilePath","profileIsDirPath","createProfile","copyProfile","profileDirectory","copy","copyByName","dirExists","name","installExtension","asProxy","manifestData","extensionPath","asyncFsStat","extensionsDir","mkdir","id","isDir","destPath","writeStream","createWriteStream","write","end","readStream","createReadStream","pipe","all"],"sources":["../../src/firefox/index.js"],"sourcesContent":["/* @flow */\nimport nodeFs from 'fs';\nimport path from 'path';\nimport {promisify} from 'util';\n\nimport {default as defaultFxRunner} from 'fx-runner';\nimport FirefoxProfile from 'firefox-profile';\nimport {fs} from 'mz';\nimport fromEvent from 'promise-toolbox/fromEvent';\n\nimport isDirectory from '../util/is-directory.js';\nimport {isErrorWithCode, UsageError, WebExtError} from '../errors.js';\nimport {getPrefs as defaultPrefGetter} from './preferences.js';\nimport {getManifestId} from '../util/manifest.js';\nimport {findFreeTcpPort as defaultRemotePortFinder} from './remote.js';\nimport {createLogger} from '../util/logger.js';\n// Import flow types\nimport type {\n PreferencesAppName,\n PreferencesGetterFn,\n FirefoxPreferences,\n} from './preferences';\nimport type {ExtensionManifest} from '../util/manifest.js';\nimport type {Extension} from '../extension-runners/base.js';\n\n\nconst log = createLogger(import.meta.url);\n\nconst defaultAsyncFsStat: typeof fs.stat = fs.stat.bind(fs);\n\nconst defaultUserProfileCopier = FirefoxProfile.copyFromUserProfile;\n\nexport const defaultFirefoxEnv = {\n XPCOM_DEBUG_BREAK: 'stack',\n NS_TRACE_MALLOC_DISABLE_STACKS: '1',\n};\n\n// defaultRemotePortFinder types and implementation.\n\n\nexport type RemotePortFinderFn =\n () => Promise<number>;\n\n// Declare the needed 'fx-runner' module flow types.\n\nexport type FirefoxRunnerParams = {|\n binary: ?string,\n profile?: string,\n 'new-instance'?: boolean,\n 'no-remote'?: boolean,\n 'foreground'?: boolean,\n 'listen': number,\n 'binary-args'?: Array<string> | string,\n 'binary-args-first'?: boolean,\n 'env'?: {\n // This match the flowtype signature for process.env (and prevent flow\n // from complaining about differences between their type signature)\n [key: string]: string | void\n },\n 'verbose'?: boolean,\n|};\n\nexport interface FirefoxProcess extends events$EventEmitter {\n stderr: events$EventEmitter;\n stdout: events$EventEmitter;\n kill: Function;\n}\n\nexport type FirefoxRunnerResults = {|\n process: FirefoxProcess,\n binary: string,\n args: Array<string>,\n|}\n\nexport type FirefoxRunnerFn =\n (params: FirefoxRunnerParams) => Promise<FirefoxRunnerResults>;\n\n\nexport type FirefoxInfo = {|\n firefox: FirefoxProcess,\n debuggerPort: number,\n|}\n\n// Run command types and implementaion.\n\nexport type FirefoxRunOptions = {\n fxRunner?: FirefoxRunnerFn,\n findRemotePort?: RemotePortFinderFn,\n firefoxBinary?: string,\n binaryArgs?: Array<string>,\n args?: Array<any>,\n extensions: Array<Extension>,\n devtools: boolean,\n};\n\n/*\n * Runs Firefox with the given profile object and resolves a promise on exit.\n */\nexport async function run(\n profile: FirefoxProfile,\n {\n fxRunner = defaultFxRunner,\n findRemotePort = defaultRemotePortFinder,\n firefoxBinary,\n binaryArgs,\n extensions,\n devtools,\n }: FirefoxRunOptions = {}\n): Promise<FirefoxInfo> {\n\n log.debug(`Running Firefox with profile at ${profile.path()}`);\n\n const remotePort = await findRemotePort();\n\n if (firefoxBinary && firefoxBinary.startsWith('flatpak:')) {\n const flatpakAppId = firefoxBinary.substring(8);\n log.debug(`Configuring Firefox with flatpak: appId=${flatpakAppId}`);\n\n // This should be resolved by the fx-runner.\n firefoxBinary = 'flatpak';\n binaryArgs = [\n 'run',\n `--filesystem=${profile.path()}`,\n ...extensions.map(({ sourceDir }) => `--filesystem=${sourceDir}:ro`),\n // We need to share the network namespace because we want to connect to\n // Firefox with the remote protocol. There is no way to tell flatpak to\n // only expose a port AFAIK.\n '--share=network',\n // Kill the entire sandbox when the launching process dies, which is what\n // we want since exiting web-ext involves `kill` and the process executed\n // here is `flatpak run`.\n '--die-with-parent',\n flatpakAppId,\n ].concat(...(binaryArgs || []));\n }\n\n const results = await fxRunner({\n // if this is falsey, fxRunner tries to find the default one.\n 'binary': firefoxBinary,\n 'binary-args': binaryArgs,\n // For Flatpak we need to respect the order of the command arguments because\n // we have arguments for Flapack (first) and then Firefox.\n 'binary-args-first': firefoxBinary === 'flatpak',\n // This ensures a new instance of Firefox is created. It has nothing\n // to do with the devtools remote debugger.\n 'no-remote': true,\n 'listen': remotePort,\n 'foreground': true,\n 'profile': profile.path(),\n 'env': {\n ...process.env,\n ...defaultFirefoxEnv,\n },\n 'verbose': true,\n });\n\n const firefox = results.process;\n\n log.debug(`Executing Firefox binary: ${results.binary}`);\n log.debug(`Firefox args: ${results.args.join(' ')}`);\n\n firefox.on('error', (error) => {\n // TODO: show a nice error when it can't find Firefox.\n // if (/No such file/.test(err) || err.code === 'ENOENT') {\n log.error(`Firefox error: ${error}`);\n throw error;\n });\n\n if (!devtools) {\n log.info('Use --verbose or --devtools to see logging');\n }\n if (devtools) {\n log.info('More info about WebExtensions debugging:');\n log.info('https://extensionworkshop.com/documentation/develop/debugging/');\n }\n\n firefox.stderr.on('data', (data) => {\n log.debug(`Firefox stderr: ${data.toString().trim()}`);\n });\n\n firefox.stdout.on('data', (data) => {\n log.debug(`Firefox stdout: ${data.toString().trim()}`);\n });\n\n firefox.on('close', () => {\n log.debug('Firefox closed');\n });\n\n return { firefox, debuggerPort: remotePort };\n}\n\n\n// isDefaultProfile types and implementation.\n\nconst DEFAULT_PROFILES_NAMES = [\n 'default',\n 'dev-edition-default',\n];\n\nexport type IsDefaultProfileFn = (\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder,\n fsStat?: typeof fs.stat,\n) => Promise<boolean>;\n\n/*\n * Tests if a profile is a default Firefox profile (both as a profile name or\n * profile path).\n *\n * Returns a promise that resolves to true if the profile is one of default Firefox profile.\n */\nexport async function isDefaultProfile(\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder = FirefoxProfile.Finder,\n fsStat?: typeof fs.stat = fs.stat,\n): Promise<boolean> {\n if (DEFAULT_PROFILES_NAMES.includes(profilePathOrName)) {\n return true;\n }\n\n const baseProfileDir = ProfileFinder.locateUserDirectory();\n const profilesIniPath = path.join(baseProfileDir, 'profiles.ini');\n try {\n await fsStat(profilesIniPath);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`profiles.ini not found: ${error}`);\n\n // No profiles exist yet, default to false (the default profile name contains a\n // random generated component).\n return false;\n }\n\n // Re-throw any unexpected exception.\n throw error;\n }\n\n // Check for profile dir path.\n const finder = new ProfileFinder(baseProfileDir);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n\n await readProfiles();\n\n const normalizedProfileDirPath = path.normalize(\n path.join(path.resolve(profilePathOrName), path.sep)\n );\n\n for (const profile of finder.profiles) {\n // Check if the profile dir path or name is one of the default profiles\n // defined in the profiles.ini file.\n if (DEFAULT_PROFILES_NAMES.includes(profile.Name) ||\n profile.Default === '1') {\n let profileFullPath;\n\n // Check for profile name.\n if (profile.Name === profilePathOrName) {\n return true;\n }\n\n // Check for profile path.\n if (profile.IsRelative === '1') {\n profileFullPath = path.join(baseProfileDir, profile.Path, path.sep);\n } else {\n profileFullPath = path.join(profile.Path, path.sep);\n }\n\n if (path.normalize(profileFullPath) === normalizedProfileDirPath) {\n return true;\n }\n }\n }\n\n // Profile directory not found.\n return false;\n}\n\n// configureProfile types and implementation.\n\nexport type ConfigureProfileOptions = {\n app?: PreferencesAppName,\n getPrefs?: PreferencesGetterFn,\n customPrefs?: FirefoxPreferences,\n};\n\nexport type ConfigureProfileFn = (\n profile: FirefoxProfile,\n options?: ConfigureProfileOptions\n) => Promise<FirefoxProfile>;\n\n/*\n * Configures a profile with common preferences that are required to\n * activate extension development.\n *\n * Returns a promise that resolves with the original profile object.\n */\nexport function configureProfile(\n profile: FirefoxProfile,\n {\n app = 'firefox',\n getPrefs = defaultPrefGetter,\n customPrefs = {},\n }: ConfigureProfileOptions = {},\n): Promise<FirefoxProfile> {\n // Set default preferences. Some of these are required for the add-on to\n // operate, such as disabling signatures.\n const prefs = getPrefs(app);\n Object.keys(prefs).forEach((pref) => {\n profile.setPreference(pref, prefs[pref]);\n });\n if (Object.keys(customPrefs).length > 0) {\n const customPrefsStr = JSON.stringify(customPrefs, null, 2);\n log.info(`Setting custom Firefox preferences: ${customPrefsStr}`);\n Object.keys(customPrefs).forEach((custom) => {\n profile.setPreference(custom, customPrefs[custom]);\n });\n }\n profile.updatePreferences();\n return Promise.resolve(profile);\n}\n\nexport type getProfileFn = (profileName: string) => Promise<string | void>;\n\nexport type CreateProfileFinderParams = {\n userDirectoryPath?: string,\n FxProfile?: typeof FirefoxProfile\n}\n\nexport function defaultCreateProfileFinder(\n {\n userDirectoryPath,\n FxProfile = FirefoxProfile,\n }: CreateProfileFinderParams = {}\n): getProfileFn {\n const finder = new FxProfile.Finder(userDirectoryPath);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n const getPath = promisify((...args) => finder.getPath(...args));\n return async (profileName: string): Promise<string | void> => {\n try {\n await readProfiles();\n const hasProfileName = finder.profiles.filter(\n (profileDef) => profileDef.Name === profileName).length !== 0;\n if (hasProfileName) {\n return await getPath(profileName);\n }\n } catch (error) {\n if (!isErrorWithCode('ENOENT', error)) {\n throw error;\n }\n log.warn('Unable to find Firefox profiles.ini');\n }\n };\n}\n\n// useProfile types and implementation.\n\nexport type UseProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n isFirefoxDefaultProfile?: IsDefaultProfileFn,\n customPrefs?: FirefoxPreferences,\n createProfileFinder?: typeof defaultCreateProfileFinder,\n};\n\n// Use the target path as a Firefox profile without cloning it\n\nexport async function useProfile(\n profilePath: string,\n {\n app,\n configureThisProfile = configureProfile,\n isFirefoxDefaultProfile = isDefaultProfile,\n customPrefs = {},\n createProfileFinder = defaultCreateProfileFinder,\n }: UseProfileParams = {},\n): Promise<FirefoxProfile> {\n const isForbiddenProfile = await isFirefoxDefaultProfile(profilePath);\n if (isForbiddenProfile) {\n throw new UsageError(\n 'Cannot use --keep-profile-changes on a default profile' +\n ` (\"${profilePath}\")` +\n ' because web-ext will make it insecure and unsuitable for daily use.' +\n '\\nSee https://github.com/mozilla/web-ext/issues/1005'\n );\n }\n\n let destinationDirectory;\n const getProfilePath = createProfileFinder();\n\n const profileIsDirPath = await isDirectory(profilePath);\n if (profileIsDirPath) {\n log.debug(`Using profile directory \"${profilePath}\"`);\n destinationDirectory = profilePath;\n } else {\n log.debug(`Assuming ${profilePath} is a named profile`);\n destinationDirectory = await getProfilePath(profilePath);\n if (!destinationDirectory) {\n throw new UsageError(\n `The request \"${profilePath}\" profile name ` +\n 'cannot be resolved to a profile path'\n );\n }\n }\n\n const profile = new FirefoxProfile({destinationDirectory});\n return await configureThisProfile(profile, {app, customPrefs});\n}\n\n\n// createProfile types and implementation.\n\nexport type CreateProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Creates a new temporary profile and resolves with the profile object.\n *\n * The profile will be deleted when the system process exits.\n */\nexport async function createProfile(\n {\n app,\n configureThisProfile = configureProfile,\n customPrefs = {},\n }: CreateProfileParams = {},\n): Promise<FirefoxProfile> {\n const profile = new FirefoxProfile();\n return await configureThisProfile(profile, {app, customPrefs});\n}\n\n\n// copyProfile types and implementation.\n\nexport type CopyProfileOptions = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n copyFromUserProfile?: Function,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Copies an existing Firefox profile and creates a new temporary profile.\n * The new profile will be configured with some preferences required to\n * activate extension development.\n *\n * It resolves with the new profile object.\n *\n * The temporary profile will be deleted when the system process exits.\n *\n * The existing profile can be specified as a directory path or a name of\n * one that exists in the current user's Firefox directory.\n */\nexport async function copyProfile(\n profileDirectory: string,\n {\n app,\n configureThisProfile = configureProfile,\n copyFromUserProfile = defaultUserProfileCopier,\n customPrefs = {},\n }: CopyProfileOptions = {},\n): Promise<FirefoxProfile> {\n\n const copy = promisify(FirefoxProfile.copy);\n const copyByName = promisify(copyFromUserProfile);\n\n try {\n const dirExists = await isDirectory(profileDirectory);\n\n let profile;\n\n if (dirExists) {\n log.debug(`Copying profile directory from \"${profileDirectory}\"`);\n profile = await copy({profileDirectory});\n } else {\n log.debug(`Assuming ${profileDirectory} is a named profile`);\n profile = await copyByName({name: profileDirectory});\n }\n\n return configureThisProfile(profile, {app, customPrefs});\n } catch (error) {\n throw new WebExtError(\n `Could not copy Firefox profile from ${profileDirectory}: ${error}`);\n }\n}\n\n\n// installExtension types and implementation.\n\nexport type InstallExtensionParams = {|\n asProxy?: boolean,\n manifestData: ExtensionManifest,\n profile: FirefoxProfile,\n extensionPath: string,\n asyncFsStat?: typeof defaultAsyncFsStat,\n|};\n\n/*\n * Installs an extension into the given Firefox profile object.\n * Resolves when complete.\n *\n * The extension is copied into a special location and you need to turn\n * on some preferences to allow this. See extensions.autoDisableScopes in\n * ./preferences.js.\n *\n * When asProxy is true, a special proxy file will be installed. This is a\n * text file that contains the path to the extension source.\n */\nexport async function installExtension(\n {\n asProxy = false,\n manifestData,\n profile,\n extensionPath,\n asyncFsStat = defaultAsyncFsStat,\n }: InstallExtensionParams): Promise<any> {\n // This more or less follows\n // https://github.com/saadtazi/firefox-profile-js/blob/master/lib/firefox_profile.js#L531\n // (which is broken for web extensions).\n // TODO: maybe uplift a patch that supports web extensions instead?\n\n if (!profile.extensionsDir) {\n throw new WebExtError('profile.extensionsDir was unexpectedly empty');\n }\n\n try {\n await asyncFsStat(profile.extensionsDir);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`Creating extensions directory: ${profile.extensionsDir}`);\n await fs.mkdir(profile.extensionsDir);\n } else {\n throw error;\n }\n }\n\n const id = getManifestId(manifestData);\n if (!id) {\n throw new UsageError(\n 'An explicit extension ID is required when installing to ' +\n 'a profile (applications.gecko.id not found in manifest.json)');\n }\n\n if (asProxy) {\n log.debug(`Installing as an extension proxy; source: ${extensionPath}`);\n\n const isDir = await isDirectory(extensionPath);\n if (!isDir) {\n throw new WebExtError(\n 'proxy install: extensionPath must be the extension source ' +\n `directory; got: ${extensionPath}`);\n }\n\n // Write a special extension proxy file containing the source\n // directory. See:\n // https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment#Firefox_extension_proxy_file\n const destPath = path.join(profile.extensionsDir, `${id}`);\n const writeStream = nodeFs.createWriteStream(destPath);\n writeStream.write(extensionPath);\n writeStream.end();\n return await fromEvent(writeStream, 'close');\n } else {\n // Write the XPI file to the profile.\n const readStream = nodeFs.createReadStream(extensionPath);\n const destPath = path.join(profile.extensionsDir, `${id}.xpi`);\n const writeStream = nodeFs.createWriteStream(destPath);\n\n log.debug(`Installing extension from ${extensionPath} to ${destPath}`);\n readStream.pipe(writeStream);\n\n return await Promise.all([\n fromEvent(readStream, 'close'),\n fromEvent(writeStream, 'close'),\n ]);\n }\n}\n"],"mappings":";AACA,OAAOA,MAAM,MAAM,IAAI;AACvB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAAQC,SAAS,QAAO,MAAM;AAE9B,SAAQC,OAAO,IAAIC,eAAe,QAAO,WAAW;AACpD,OAAOC,cAAc,MAAM,iBAAiB;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AAE,OAAO,CAAC,CAChC,CAAC;EACJ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-identifiers.js","names":["defaultApkComponents"],"sources":["../../src/firefox/package-identifiers.js"],"sourcesContent":["/* @flow */\n\nexport default [\n 'org.mozilla.fennec',\n 'org.mozilla.fenix',\n 'org.mozilla.geckoview_example',\n 'org.mozilla.geckoview',\n 'org.mozilla.firefox',\n 'org.mozilla.reference.browser',\n];\n\nexport const defaultApkComponents = {\n 'org.mozilla.reference.browser': '.BrowserActivity',\n};\n"],"mappings":"AAEA,eAAe,CACb,
|
|
1
|
+
{"version":3,"file":"package-identifiers.js","names":["defaultApkComponents"],"sources":["../../src/firefox/package-identifiers.js"],"sourcesContent":["/* @flow */\n\nexport default [\n 'org.mozilla.fennec',\n 'org.mozilla.fenix',\n 'org.mozilla.geckoview_example',\n 'org.mozilla.geckoview',\n 'org.mozilla.firefox',\n 'org.mozilla.reference.browser',\n];\n\nexport const defaultApkComponents = {\n 'org.mozilla.reference.browser': '.BrowserActivity',\n};\n"],"mappings":";;AAEA,eAAe,CACb,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,EACvB,qBAAqB,EACrB,+BAA+B,CAChC;AAED,OAAO,MAAMA,oBAAoB,GAAG;EAClC,+BAA+B,EAAE;AACnC,CAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
|
|
1
2
|
import { WebExtError, UsageError } from '../errors.js';
|
|
2
3
|
import { createLogger } from '../util/logger.js';
|
|
3
4
|
const log = createLogger(import.meta.url);
|
|
4
|
-
export const nonOverridablePreferences = ['devtools.debugger.remote-enabled', 'devtools.debugger.prompt-connection', 'xpinstall.signatures.required'];
|
|
5
|
+
export const nonOverridablePreferences = ['devtools.debugger.remote-enabled', 'devtools.debugger.prompt-connection', 'xpinstall.signatures.required'];
|
|
6
|
+
|
|
7
|
+
// Flow Types
|
|
5
8
|
|
|
6
9
|
// Preferences Maps
|
|
10
|
+
|
|
7
11
|
const prefsCommon = {
|
|
8
12
|
// Allow debug output via dump to be printed to the system console
|
|
9
13
|
'browser.dom.window.dump.enabled': true,
|
|
@@ -42,14 +46,16 @@ const prefsCommon = {
|
|
|
42
46
|
// https://github.com/saadtazi/firefox-profile-js/blob/cafc793d940a779d280103ae17d02a92de862efc/lib/firefox_profile.js#L32
|
|
43
47
|
// Restore original value to avoid https://github.com/mozilla/web-ext/issues/1592
|
|
44
48
|
'browser.link.open_newwindow': 3
|
|
45
|
-
};
|
|
49
|
+
};
|
|
46
50
|
|
|
51
|
+
// Prefs specific to Firefox for Android.
|
|
47
52
|
const prefsFennec = {
|
|
48
53
|
'browser.console.showInPanel': true,
|
|
49
54
|
'browser.firstrun.show.uidiscovery': false,
|
|
50
55
|
'devtools.remote.usb.enabled': true
|
|
51
|
-
};
|
|
56
|
+
};
|
|
52
57
|
|
|
58
|
+
// Prefs specific to Firefox for desktop.
|
|
53
59
|
const prefsFirefox = {
|
|
54
60
|
'browser.startup.homepage': 'about:blank',
|
|
55
61
|
'startup.homepage_welcome_url': 'about:blank',
|
|
@@ -77,50 +83,43 @@ const prefs = {
|
|
|
77
83
|
common: prefsCommon,
|
|
78
84
|
fennec: prefsFennec,
|
|
79
85
|
firefox: prefsFirefox
|
|
80
|
-
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Module exports
|
|
81
89
|
|
|
82
90
|
export function getPrefs(app = 'firefox') {
|
|
83
91
|
const appPrefs = prefs[app];
|
|
84
|
-
|
|
85
92
|
if (!appPrefs) {
|
|
86
93
|
throw new WebExtError(`Unsupported application: ${app}`);
|
|
87
94
|
}
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
return {
|
|
96
|
+
...prefsCommon,
|
|
90
97
|
...appPrefs
|
|
91
98
|
};
|
|
92
99
|
}
|
|
93
100
|
export function coerceCLICustomPreference(cliPrefs) {
|
|
94
101
|
const customPrefs = {};
|
|
95
|
-
|
|
96
102
|
for (const pref of cliPrefs) {
|
|
97
103
|
const prefsAry = pref.split('=');
|
|
98
|
-
|
|
99
104
|
if (prefsAry.length < 2) {
|
|
100
105
|
throw new UsageError(`Incomplete custom preference: "${pref}". ` + 'Syntax expected: "prefname=prefvalue".');
|
|
101
106
|
}
|
|
102
|
-
|
|
103
107
|
const key = prefsAry[0];
|
|
104
108
|
let value = prefsAry.slice(1).join('=');
|
|
105
|
-
|
|
106
109
|
if (/[^\w{@}.-]/.test(key)) {
|
|
107
110
|
throw new UsageError(`Invalid custom preference name: ${key}`);
|
|
108
111
|
}
|
|
109
|
-
|
|
110
112
|
if (value === `${parseInt(value)}`) {
|
|
111
113
|
value = parseInt(value, 10);
|
|
112
114
|
} else if (value === 'true' || value === 'false') {
|
|
113
115
|
value = value === 'true';
|
|
114
116
|
}
|
|
115
|
-
|
|
116
117
|
if (nonOverridablePreferences.includes(key)) {
|
|
117
118
|
log.warn(`'${key}' preference cannot be customized.`);
|
|
118
119
|
continue;
|
|
119
120
|
}
|
|
120
|
-
|
|
121
121
|
customPrefs[`${key}`] = value;
|
|
122
122
|
}
|
|
123
|
-
|
|
124
123
|
return customPrefs;
|
|
125
124
|
}
|
|
126
125
|
//# sourceMappingURL=preferences.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preferences.js","names":["WebExtError","UsageError","createLogger","log","import","meta","url","nonOverridablePreferences","prefsCommon","prefsFennec","prefsFirefox","prefs","common","fennec","firefox","getPrefs","app","appPrefs","coerceCLICustomPreference","cliPrefs","customPrefs","pref","prefsAry","split","length","key","value","slice","join","test","parseInt","includes","warn"],"sources":["../../src/firefox/preferences.js"],"sourcesContent":["/* @flow */\nimport {WebExtError, UsageError} from '../errors.js';\nimport {createLogger} from '../util/logger.js';\n\nconst log = createLogger(import.meta.url);\n\nexport const nonOverridablePreferences = [\n 'devtools.debugger.remote-enabled', 'devtools.debugger.prompt-connection',\n 'xpinstall.signatures.required',\n];\n\n// Flow Types\n\nexport type FirefoxPreferences = {\n [key: string]: boolean | string | number,\n};\n\nexport type PreferencesAppName = 'firefox' | 'fennec';\n\n\n// Preferences Maps\n\nconst prefsCommon: FirefoxPreferences = {\n // Allow debug output via dump to be printed to the system console\n 'browser.dom.window.dump.enabled': true,\n\n // From:\n // https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/internals/preferences.html#data-choices-notification\n // This is the data submission master kill switch. If disabled, no policy is shown or upload takes place, ever.\n 'datareporting.policy.dataSubmissionEnabled': false,\n\n // Allow remote connections to the debugger.\n 'devtools.debugger.remote-enabled': true,\n // Disable the prompt for allowing connections.\n 'devtools.debugger.prompt-connection': false,\n // Allow extensions to log messages on browser's console.\n 'devtools.browserconsole.contentMessages': true,\n\n // Turn off platform logging because it is a lot of info.\n 'extensions.logging.enabled': false,\n\n // Disable extension updates and notifications.\n 'extensions.checkCompatibility.nightly': false,\n 'extensions.update.enabled': false,\n 'extensions.update.notifyUser': false,\n\n // From:\n // http://hg.mozilla.org/mozilla-central/file/1dd81c324ac7/build/automation.py.in//l372\n // Only load extensions from the application and user profile.\n // AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION\n 'extensions.enabledScopes': 5,\n // Disable metadata caching for installed add-ons by default.\n 'extensions.getAddons.cache.enabled': false,\n // Disable intalling any distribution add-ons.\n 'extensions.installDistroAddons': false,\n // Allow installing extensions dropped into the profile folder.\n 'extensions.autoDisableScopes': 10,\n\n // Disable app update.\n 'app.update.enabled': false,\n\n // Allow unsigned add-ons.\n 'xpinstall.signatures.required': false,\n\n // browser.link.open_newwindow is changed from 3 to 2 in:\n // https://github.com/saadtazi/firefox-profile-js/blob/cafc793d940a779d280103ae17d02a92de862efc/lib/firefox_profile.js#L32\n // Restore original value to avoid https://github.com/mozilla/web-ext/issues/1592\n 'browser.link.open_newwindow': 3,\n};\n\n// Prefs specific to Firefox for Android.\nconst prefsFennec: FirefoxPreferences = {\n 'browser.console.showInPanel': true,\n 'browser.firstrun.show.uidiscovery': false,\n 'devtools.remote.usb.enabled': true,\n};\n\n// Prefs specific to Firefox for desktop.\nconst prefsFirefox: FirefoxPreferences = {\n 'browser.startup.homepage': 'about:blank',\n 'startup.homepage_welcome_url': 'about:blank',\n 'startup.homepage_welcome_url.additional': '',\n 'devtools.errorconsole.enabled': true,\n 'devtools.chrome.enabled': true,\n\n // From:\n // http://hg.mozilla.org/mozilla-central/file/1dd81c324ac7/build/automation.py.in//l388\n // Make url-classifier updates so rare that they won't affect tests.\n 'urlclassifier.updateinterval': 172800,\n // Point the url-classifier to a nonexistent local URL for fast failures.\n 'browser.safebrowsing.provider.0.gethashURL':\n 'http://localhost/safebrowsing-dummy/gethash',\n 'browser.safebrowsing.provider.0.keyURL':\n 'http://localhost/safebrowsing-dummy/newkey',\n 'browser.safebrowsing.provider.0.updateURL':\n 'http://localhost/safebrowsing-dummy/update',\n\n // Disable self repair/SHIELD\n 'browser.selfsupport.url': 'https://localhost/selfrepair',\n // Disable Reader Mode UI tour\n 'browser.reader.detectedFirstArticle': true,\n\n // Set the policy firstURL to an empty string to prevent\n // the privacy info page to be opened on every \"web-ext run\".\n // (See #1114 for rationale)\n 'datareporting.policy.firstRunURL': '',\n};\n\nconst prefs = {\n common: prefsCommon,\n fennec: prefsFennec,\n firefox: prefsFirefox,\n};\n\n\n// Module exports\n\nexport type PreferencesGetterFn =\n (appName: PreferencesAppName) => FirefoxPreferences;\n\nexport function getPrefs(\n app: PreferencesAppName = 'firefox'\n): FirefoxPreferences {\n const appPrefs = prefs[app];\n if (!appPrefs) {\n throw new WebExtError(`Unsupported application: ${app}`);\n }\n return {\n ...prefsCommon,\n ...appPrefs,\n };\n}\n\nexport function coerceCLICustomPreference(\n cliPrefs: Array<string>\n): FirefoxPreferences {\n const customPrefs = {};\n\n for (const pref of cliPrefs) {\n const prefsAry = pref.split('=');\n\n if (prefsAry.length < 2) {\n throw new UsageError(\n `Incomplete custom preference: \"${pref}\". ` +\n 'Syntax expected: \"prefname=prefvalue\".'\n );\n }\n\n const key = prefsAry[0];\n let value = prefsAry.slice(1).join('=');\n\n if (/[^\\w{@}.-]/.test(key)) {\n throw new UsageError(`Invalid custom preference name: ${key}`);\n }\n\n if (value === `${parseInt(value)}`) {\n value = parseInt(value, 10);\n } else if (value === 'true' || value === 'false') {\n value = (value === 'true');\n }\n\n if (nonOverridablePreferences.includes(key)) {\n log.warn(`'${key}' preference cannot be customized.`);\n continue;\n }\n customPrefs[`${key}`] = value;\n }\n\n return customPrefs;\n}\n"],"mappings":"AACA,SAAQA,
|
|
1
|
+
{"version":3,"file":"preferences.js","names":["WebExtError","UsageError","createLogger","log","import","meta","url","nonOverridablePreferences","prefsCommon","prefsFennec","prefsFirefox","prefs","common","fennec","firefox","getPrefs","app","appPrefs","coerceCLICustomPreference","cliPrefs","customPrefs","pref","prefsAry","split","length","key","value","slice","join","test","parseInt","includes","warn"],"sources":["../../src/firefox/preferences.js"],"sourcesContent":["/* @flow */\nimport {WebExtError, UsageError} from '../errors.js';\nimport {createLogger} from '../util/logger.js';\n\nconst log = createLogger(import.meta.url);\n\nexport const nonOverridablePreferences = [\n 'devtools.debugger.remote-enabled', 'devtools.debugger.prompt-connection',\n 'xpinstall.signatures.required',\n];\n\n// Flow Types\n\nexport type FirefoxPreferences = {\n [key: string]: boolean | string | number,\n};\n\nexport type PreferencesAppName = 'firefox' | 'fennec';\n\n\n// Preferences Maps\n\nconst prefsCommon: FirefoxPreferences = {\n // Allow debug output via dump to be printed to the system console\n 'browser.dom.window.dump.enabled': true,\n\n // From:\n // https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/internals/preferences.html#data-choices-notification\n // This is the data submission master kill switch. If disabled, no policy is shown or upload takes place, ever.\n 'datareporting.policy.dataSubmissionEnabled': false,\n\n // Allow remote connections to the debugger.\n 'devtools.debugger.remote-enabled': true,\n // Disable the prompt for allowing connections.\n 'devtools.debugger.prompt-connection': false,\n // Allow extensions to log messages on browser's console.\n 'devtools.browserconsole.contentMessages': true,\n\n // Turn off platform logging because it is a lot of info.\n 'extensions.logging.enabled': false,\n\n // Disable extension updates and notifications.\n 'extensions.checkCompatibility.nightly': false,\n 'extensions.update.enabled': false,\n 'extensions.update.notifyUser': false,\n\n // From:\n // http://hg.mozilla.org/mozilla-central/file/1dd81c324ac7/build/automation.py.in//l372\n // Only load extensions from the application and user profile.\n // AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION\n 'extensions.enabledScopes': 5,\n // Disable metadata caching for installed add-ons by default.\n 'extensions.getAddons.cache.enabled': false,\n // Disable intalling any distribution add-ons.\n 'extensions.installDistroAddons': false,\n // Allow installing extensions dropped into the profile folder.\n 'extensions.autoDisableScopes': 10,\n\n // Disable app update.\n 'app.update.enabled': false,\n\n // Allow unsigned add-ons.\n 'xpinstall.signatures.required': false,\n\n // browser.link.open_newwindow is changed from 3 to 2 in:\n // https://github.com/saadtazi/firefox-profile-js/blob/cafc793d940a779d280103ae17d02a92de862efc/lib/firefox_profile.js#L32\n // Restore original value to avoid https://github.com/mozilla/web-ext/issues/1592\n 'browser.link.open_newwindow': 3,\n};\n\n// Prefs specific to Firefox for Android.\nconst prefsFennec: FirefoxPreferences = {\n 'browser.console.showInPanel': true,\n 'browser.firstrun.show.uidiscovery': false,\n 'devtools.remote.usb.enabled': true,\n};\n\n// Prefs specific to Firefox for desktop.\nconst prefsFirefox: FirefoxPreferences = {\n 'browser.startup.homepage': 'about:blank',\n 'startup.homepage_welcome_url': 'about:blank',\n 'startup.homepage_welcome_url.additional': '',\n 'devtools.errorconsole.enabled': true,\n 'devtools.chrome.enabled': true,\n\n // From:\n // http://hg.mozilla.org/mozilla-central/file/1dd81c324ac7/build/automation.py.in//l388\n // Make url-classifier updates so rare that they won't affect tests.\n 'urlclassifier.updateinterval': 172800,\n // Point the url-classifier to a nonexistent local URL for fast failures.\n 'browser.safebrowsing.provider.0.gethashURL':\n 'http://localhost/safebrowsing-dummy/gethash',\n 'browser.safebrowsing.provider.0.keyURL':\n 'http://localhost/safebrowsing-dummy/newkey',\n 'browser.safebrowsing.provider.0.updateURL':\n 'http://localhost/safebrowsing-dummy/update',\n\n // Disable self repair/SHIELD\n 'browser.selfsupport.url': 'https://localhost/selfrepair',\n // Disable Reader Mode UI tour\n 'browser.reader.detectedFirstArticle': true,\n\n // Set the policy firstURL to an empty string to prevent\n // the privacy info page to be opened on every \"web-ext run\".\n // (See #1114 for rationale)\n 'datareporting.policy.firstRunURL': '',\n};\n\nconst prefs = {\n common: prefsCommon,\n fennec: prefsFennec,\n firefox: prefsFirefox,\n};\n\n\n// Module exports\n\nexport type PreferencesGetterFn =\n (appName: PreferencesAppName) => FirefoxPreferences;\n\nexport function getPrefs(\n app: PreferencesAppName = 'firefox'\n): FirefoxPreferences {\n const appPrefs = prefs[app];\n if (!appPrefs) {\n throw new WebExtError(`Unsupported application: ${app}`);\n }\n return {\n ...prefsCommon,\n ...appPrefs,\n };\n}\n\nexport function coerceCLICustomPreference(\n cliPrefs: Array<string>\n): FirefoxPreferences {\n const customPrefs = {};\n\n for (const pref of cliPrefs) {\n const prefsAry = pref.split('=');\n\n if (prefsAry.length < 2) {\n throw new UsageError(\n `Incomplete custom preference: \"${pref}\". ` +\n 'Syntax expected: \"prefname=prefvalue\".'\n );\n }\n\n const key = prefsAry[0];\n let value = prefsAry.slice(1).join('=');\n\n if (/[^\\w{@}.-]/.test(key)) {\n throw new UsageError(`Invalid custom preference name: ${key}`);\n }\n\n if (value === `${parseInt(value)}`) {\n value = parseInt(value, 10);\n } else if (value === 'true' || value === 'false') {\n value = (value === 'true');\n }\n\n if (nonOverridablePreferences.includes(key)) {\n log.warn(`'${key}' preference cannot be customized.`);\n continue;\n }\n customPrefs[`${key}`] = value;\n }\n\n return customPrefs;\n}\n"],"mappings":";AACA,SAAQA,WAAW,EAAEC,UAAU,QAAO,cAAc;AACpD,SAAQC,YAAY,QAAO,mBAAmB;AAE9C,MAAMC,GAAG,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;AAEzC,OAAO,MAAMC,yBAA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