Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Report a warning on manifest_version 3 extensions targeting Firefox for Android #5105

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,11 @@ <h2 id="web-extensions-%2F-manifest.json" tabindex="-1">Web Extensions / manifes
<td>error</td>
<td>The version string is not valid because its format is too complex.</td>
</tr>
<tr>
<td><code>MANIFEST_V3_FIREFOX_ANDROID_LIMITATIONS</code></td>
<td>warning</td>
<td>The extension is marked as compatible with a Firefox for Android version that doesn't fully support Manifest Version 3</td>
</tr>
</tbody>
</table>
<h3 id="static-theme-%2F-manifest.json" tabindex="-1">Static Theme / manifest.json <a class="header-anchor" href="#static-theme-%2F-manifest.json">¶</a></h3>
Expand Down
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 as compatible with a Firefox for Android version that doesn't fully support Manifest Version 3 |

### Static Theme / manifest.json

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

export const MANIFEST_V3_FIREFOX_ANDROID_LIMITATIONS = {
code: 'MANIFEST_V3_FIREFOX_ANDROID_LIMITATIONS',
message: i18n._(
'Manifest Version 3 is not fully supported on Firefox for Android.'
),
// TODO(#5110): replace description with a message including a shorted
// link to a documentation page.
description: i18n._(
'Manifest Version 3 is not fully supported on Firefox for Android.'
),
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