Skip to content

Commit 8a95388

Browse files
authored
Include required data collection permissions (#5670)
1 parent 9e86dde commit 8a95388

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

src/schema/imported/manifest.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,20 @@
943943
]
944944
},
945945
"default": []
946+
},
947+
"required": {
948+
"type": "array",
949+
"items": {
950+
"allOf": [
951+
{
952+
"$ref": "#/types/DataCollectionPermission"
953+
},
954+
{
955+
"onError": "warn"
956+
}
957+
]
958+
},
959+
"default": []
946960
}
947961
}
948962
}

src/schema/updates/manifest.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@
1515
},
1616
"update_url": {
1717
"format": "secureUrl"
18+
},
19+
"data_collection_permissions": {
20+
"type": "object",
21+
"properties": {
22+
"required": {
23+
"type": "array",
24+
"items": {
25+
"allOf": [
26+
{
27+
"$ref": "#/types/DataCollectionPermission"
28+
},
29+
{
30+
"onError": "warn"
31+
}
32+
]
33+
},
34+
"default": []
35+
}
36+
}
1837
}
1938
}
2039
},

tests/unit/parsers/test.manifestjson.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5832,6 +5832,34 @@ describe('ManifestJSONParser', () => {
58325832
expect(manifestJSONParser.isValid).toEqual(false);
58335833
});
58345834

5835+
it('validates data collection permissions - unknown required perm', () => {
5836+
const linter = new Linter({ _: ['bar'] });
5837+
5838+
const manifestJSONParser = new ManifestJSONParser(
5839+
JSON.stringify({
5840+
manifest_version: 2,
5841+
name: 'some name',
5842+
version: '1',
5843+
browser_specific_settings: {
5844+
gecko: {
5845+
data_collection_permissions: {
5846+
required: ['invalid_perm'],
5847+
},
5848+
},
5849+
},
5850+
}),
5851+
linter.collector,
5852+
{ schemaValidatorOptions: { enableDataCollectionPermissions: true } }
5853+
);
5854+
5855+
assertHasMatchingError(linter.collector.errors, {
5856+
code: messages.JSON_INVALID.code,
5857+
message:
5858+
/"\/browser_specific_settings\/gecko\/data_collection_permissions\/required\/0" must be equal to one of the allowed values/,
5859+
});
5860+
expect(manifestJSONParser.isValid).toEqual(false);
5861+
});
5862+
58355863
it('validates data collection permissions - unknown optional perm', () => {
58365864
const linter = new Linter({ _: ['bar'] });
58375865

0 commit comments

Comments
 (0)