Skip to content

Commit

Permalink
Suggest dropping incognito:"split" when present in manifest.json (#5316)
Browse files Browse the repository at this point in the history
Co-authored-by: Rob Wu <rob@robwu.nl>
  • Loading branch information
willdurand and Rob--W authored Jun 6, 2024
1 parent dfef570 commit 14a3a87
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@ <h2 id="web-extensions-%2F-manifest.json" tabindex="-1">Web Extensions / manifes
<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>
<tr>
<td><code>INCOGNITO_SPLIT_UNSUPPORTED</code></td>
<td>warning</td>
<td>The incognito &quot;split&quot; value is unsupported in Firefox</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 @@ -135,6 +135,7 @@ Rules are sorted by severity.
| `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 |
| `INCOGNITO_SPLIT_UNSUPPORTED` | warning | The incognito "split" value is unsupported in Firefox |

### Static Theme / manifest.json

Expand Down
9 changes: 9 additions & 0 deletions src/messages/manifestjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -823,3 +823,12 @@ export const VERSION_FORMAT_INVALID = {
https://mzl.la/3h3mCRu (MDN Docs) for more information.`),
file: MANIFEST_JSON,
};

export const INCOGNITO_SPLIT_UNSUPPORTED = {
code: 'INCOGNITO_SPLIT_UNSUPPORTED',
message: i18n._('incognito "split" is unsupported.'),
description: i18n._(`The incognito "split" value is unsupported and will be
treated as "not_allowed" in Firefox. Remove the key from the manifest
file, if your extension is compatible with Firefox's private browsing mode.`),
file: MANIFEST_JSON,
};
7 changes: 7 additions & 0 deletions src/parsers/manifestjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ export default class ManifestJSONParser extends JSONParser {
this.validateExtensionID();
this.validateHiddenAddon();
this.validateDeprecatedBrowserStyle();
this.validateIncognito();
}

/**
Expand Down Expand Up @@ -1238,6 +1239,12 @@ export default class ManifestJSONParser extends JSONParser {
}
}

validateIncognito() {
if (this.parsedJSON.incognito === 'split') {
this.collector.addWarning(messages.INCOGNITO_SPLIT_UNSUPPORTED);
}
}

getAddonId() {
try {
const { id } = this.parsedJSON.applications.gecko;
Expand Down
5 changes: 4 additions & 1 deletion src/schema/imported/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@
},
"incognito": {
"type": "string",
"description": "The 'split' value is not supported.",
"enum": [
"not_allowed",
"spanning"
"spanning",
"split"
],
"postprocess": "incognitoSplitUnsupportedAndFallback",
"default": "spanning"
},
"background": {
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 @@ -5456,4 +5456,26 @@ describe('ManifestJSONParser', () => {
});
});
});

describe('incognito', () => {
it('emits a warning when incognito:split is used', () => {
const linter = new Linter({ _: ['bar'] });

const manifestJSONParser = new ManifestJSONParser(
JSON.stringify({
manifest_version: 2,
name: 'some name',
version: '1',
incognito: 'split',
}),
linter.collector
);

expect(manifestJSONParser.isValid).toEqual(true);
expect(linter.collector.errors).toEqual([]);
expect(linter.collector.warnings).toEqual([
expect.objectContaining(messages.INCOGNITO_SPLIT_UNSUPPORTED),
]);
});
});
});

0 comments on commit 14a3a87

Please sign in to comment.