Skip to content

Commit

Permalink
fix: Report a warning on manifest_version 3 extensions targeting Fire…
Browse files Browse the repository at this point in the history
…fox for Android
  • Loading branch information
rpl committed Nov 13, 2023
1 parent 50380ff commit 4478b05
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Rules are sorted by severity.
| `APPLICATIONS_INVALID` | error | The `applications` property is no longer accepted in Manifest Version 3 and above. |
| `VERSION_FORMAT_DEPRECATED` | warning | The version string should be simplified. |
| `VERSION_FORMAT_INVALID` | error | The version string is not valid because its format is too complex. |
| `MANIFEST_V3_FIREFOX_ANDROID_LIMITATIONS` | warning | The extension is marked compatible with a Firefox for Android version with a limited Manifest Version 3 support |

### Static Theme / manifest.json

Expand Down
7 changes: 7 additions & 0 deletions src/messages/manifestjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export const MANIFEST_FIELD_INVALID = {
file: MANIFEST_JSON,
};

export const MANIFEST_V3_FIREFOX_ANDROID_LIMITATIONS = {
code: 'MANIFEST_V3_FIREFOX_ANDROID_LIMITATIONS',
message: i18n._('Limited Manifest Version 3 support on Firefox for Android.'),
description: i18n._('See https://mzl.la/TODO for more information.'),
file: MANIFEST_JSON,
};

export const MANIFEST_FIELD_PRIVILEGEDONLY = 'MANIFEST_FIELD_PRIVILEGEDONLY';
export function manifestFieldPrivilegedOnly(fieldName) {
return {
Expand Down
9 changes: 9 additions & 0 deletions src/parsers/manifestjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,15 @@ export default class ManifestJSONParser extends JSONParser {
};
}

if (
this.parsedJSON.manifest_version >= 3 &&
this.parsedJSON.browser_specific_settings?.gecko_android
) {
this.collector.addWarning(
messages.MANIFEST_V3_FIREFOX_ANDROID_LIMITATIONS
);
}

if (this.parsedJSON.content_security_policy != null) {
this.validateCspPolicy(this.parsedJSON.content_security_policy);
}
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/parsers/test.manifestjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,28 @@ describe('ManifestJSONParser', () => {
expect(manifestJSONParser.isValid).toEqual(true);
});

it('should warn when gecko_android is set along with manifest_version 3', () => {
const addonLinter = new Linter({ _: ['bar'] });
const json = validManifestJSON({
browser_specific_settings: {
gecko: { id: 'test@ext' },
gecko_android: {},
},
manifest_version: 3,
});

const manifestJSONParser = new ManifestJSONParser(
json,
addonLinter.collector
);

const { warnings } = addonLinter.collector;
expect(warnings).toEqual([
expect.objectContaining(messages.MANIFEST_V3_FIREFOX_ANDROID_LIMITATIONS),
]);
expect(manifestJSONParser.isValid).toEqual(true);
});

describe('browser_style', () => {
function parseManifest(manifestVersion, manifestKey, browserStyleValue) {
const manifest = {
Expand Down

0 comments on commit 4478b05

Please sign in to comment.