Skip to content

Commit e666180

Browse files
Lusitorpl
authored andcommittedJul 24, 2020
fix: web-ext should look for the extension id also in browser_specific_settings
1 parent 7013b6d commit e666180

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed
 

‎src/util/manifest.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const log = createLogger(__filename);
1515
// getValidatedManifest helper types and implementation
1616

1717
export type ExtensionManifestApplications = {|
18-
gecko: {|
18+
gecko?: {|
1919
id?: string,
2020
strict_min_version?: string,
2121
strict_max_version?: string,
@@ -28,6 +28,7 @@ export type ExtensionManifest = {|
2828
version: string,
2929
default_locale?: string,
3030
applications?: ExtensionManifestApplications,
31+
browser_specific_settings?: ExtensionManifestApplications,
3132
permissions?: Array<string>,
3233
|};
3334

@@ -85,6 +86,15 @@ export default async function getValidatedManifest(
8586

8687

8788
export function getManifestId(manifestData: ExtensionManifest): string | void {
88-
return manifestData.applications ?
89-
manifestData.applications.gecko.id : undefined;
89+
const manifestApps = [
90+
manifestData.browser_specific_settings,
91+
manifestData.applications,
92+
];
93+
for (const apps of manifestApps) {
94+
if (apps && apps.gecko && apps.gecko.id) {
95+
return apps.gecko.id;
96+
}
97+
}
98+
99+
return undefined;
90100
}

‎tests/unit/test-cmd/test.sign.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ describe('sign', () => {
279279
apiSecret: stubs.signingConfig.apiSecret,
280280
apiUrlPrefix: stubs.signingConfig.apiUrlPrefix,
281281
downloadDir: artifactsDir,
282-
id: applications.gecko.id,
282+
id: applications.gecko && applications.gecko.id,
283283
timeout: stubs.signingConfig.timeout,
284284
version: stubs.preValidatedManifest.version,
285285
xpiPath: stubs.buildResult.extensionPath,

‎tests/unit/test-extension-runners/test.firefox-desktop.js

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ describe('util/extension-runners/firefox-desktop', () => {
285285
assert.equal(install.asProxy, true);
286286
assert.equal(install.manifestData.applications.gecko.id,
287287
manifestData.applications &&
288+
manifestData.applications.gecko &&
288289
manifestData.applications.gecko.id);
289290
assert.deepEqual(install.profile, fakeProfile);
290291
// This needs to be the source of the extension.

‎tests/unit/test-util/test.manifest.js

+30-5
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,39 @@ describe('util/manifest', () => {
211211
});
212212

213213
describe('getManifestId', () => {
214+
const id = 'basic-manifest@web-ext-test-suite';
215+
216+
['applications', 'browser_specific_settings'].forEach((key) => {
217+
218+
describe(`with ${key}`, () => {
219+
220+
it('returns gecko.id if present', () => {
221+
assert.equal(getManifestId({
222+
...manifestWithoutApps,
223+
[key]: basicManifest.applications,
224+
}), id);
225+
});
226+
227+
it('returns undefined when gecko does not exist', () => {
228+
assert.equal(
229+
getManifestId({
230+
...manifestWithoutApps,
231+
[key]: {},
232+
}),
233+
undefined
234+
);
235+
});
236+
237+
});
214238

215-
it('returns a gecko ID', () => {
216-
assert.equal(getManifestId(basicManifest),
217-
'basic-manifest@web-ext-test-suite');
218239
});
219240

220-
it('returns undefined when ID is not specified', () => {
221-
assert.strictEqual(getManifestId(manifestWithoutApps), undefined);
241+
describe('without applications and browser_specific_settings', () => {
242+
243+
it('returns undefined when ID is not specified', () => {
244+
assert.strictEqual(getManifestId(manifestWithoutApps), undefined);
245+
});
246+
222247
});
223248

224249
});

0 commit comments

Comments
 (0)
Please sign in to comment.