Skip to content

Commit d255e92

Browse files
committed
Update background.service_worker message
Fixes #5252
1 parent cca8bcb commit d255e92

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

docs/rules.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Rules are sorted by severity.
142142
| `NONE_DATA_COLLECTION_IS_EXCLUSIVE` | error | "none" must not be specified with other required data collection permissions |
143143
| `HAS_PREVIOUS_CONSENT_IS_RESERVED` | error | The `/browser_specific_settings/gecko/data_collection_permissions/has_previous_consent` property is reserved and cannot be set to `true` |
144144
| `MISSING_ADDON_ID` | warning | The `/browser_specific_settings/gecko/id` property (add-on ID) should be specified in the manifest. This property will become mandatory in the future. See [https://mzl.la/3PLZYdo](https://mzl.la/3PLZYdo) for more information. |
145+
| `BACKGROUND_SERVICE_WORKER` | error | The `/background/service_worker` property is not supported by itself. It may only be used in combination with `/background/scripts` or `/background/page`. |
145146

146147
### Static Theme / manifest.json
147148

src/messages/manifestjson.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,3 +888,13 @@ export const MISSING_ADDON_ID = {
888888
future. See https://mzl.la/3PLZYdo for more information.`),
889889
file: MANIFEST_JSON,
890890
};
891+
892+
export const BACKGROUND_SERVICE_WORKER = {
893+
code: 'BACKGROUND_SERVICE_WORKER',
894+
message: i18n._(`"/background/service_worker" is not supported.`),
895+
description: i18n._(`The "background" property must contain either "scripts"
896+
or "page". See
897+
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background#browser_support
898+
(MDN docs) for more information.`),
899+
file: MANIFEST_JSON,
900+
};

src/parsers/manifestjson.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,13 +589,9 @@ export default class ManifestJSONParser extends JSONParser {
589589
// service worker support isn't enabled by the addons-linter feature
590590
// flag.
591591
if (hasScripts || hasPage) {
592-
this.collector.addWarning(
593-
messages.manifestFieldUnsupported('/background/service_worker')
594-
);
592+
this.collector.addWarning(messages.BACKGROUND_SERVICE_WORKER);
595593
} else {
596-
this.collector.addError(
597-
messages.manifestFieldUnsupported('/background/service_worker')
598-
);
594+
this.collector.addError(messages.BACKGROUND_SERVICE_WORKER);
599595
this.isValid = false;
600596
}
601597
} else if (this.parsedJSON.manifest_version >= 3) {

tests/unit/parsers/test.manifestjson.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3342,7 +3342,7 @@ describe('ManifestJSONParser', () => {
33423342
expect(linter.collector.errors).toEqual(
33433343
expect.arrayContaining([
33443344
expect.objectContaining({
3345-
code: 'MANIFEST_FIELD_UNSUPPORTED',
3345+
code: 'BACKGROUND_SERVICE_WORKER',
33463346
message: expect.stringMatching(
33473347
/"\/background\/service_worker" is not supported/
33483348
),
@@ -3381,7 +3381,7 @@ describe('ManifestJSONParser', () => {
33813381
expect(linter.collector.warnings).toEqual(
33823382
expect.arrayContaining([
33833383
expect.objectContaining({
3384-
code: 'MANIFEST_FIELD_UNSUPPORTED',
3384+
code: 'BACKGROUND_SERVICE_WORKER',
33853385
message: expect.stringMatching(
33863386
/"\/background\/service_worker" is not supported/
33873387
),
@@ -3413,7 +3413,7 @@ describe('ManifestJSONParser', () => {
34133413
expect(linter.collector.errors).toEqual(
34143414
expect.arrayContaining([
34153415
expect.objectContaining({
3416-
code: 'MANIFEST_FIELD_UNSUPPORTED',
3416+
code: 'BACKGROUND_SERVICE_WORKER',
34173417
message: expect.stringMatching(
34183418
/"\/background\/service_worker" is not supported/
34193419
),

0 commit comments

Comments
 (0)