Bug 1253565 - [webext] reusable 'UnrecognizedProperty' type for manifest schema validation. r?kmag
MozReview-Commit-ID: LLWb07ybvlb
--- a/toolkit/components/extensions/schemas/manifest.json
+++ b/toolkit/components/extensions/schemas/manifest.json
@@ -90,30 +90,32 @@
{
"type": "object",
"properties": {
"page": { "$ref": "ExtensionURL" },
"persistent": {
"optional": true,
"$ref": "PersistentBackgroundProperty"
}
- }
+ },
+ "additionalProperties": { "$ref": "UnrecognizedProperty" }
},
{
"type": "object",
"properties": {
"scripts": {
"type": "array",
"items": { "$ref": "ExtensionURL" }
},
"persistent": {
"optional": true,
"$ref": "PersistentBackgroundProperty"
}
- }
+ },
+ "additionalProperties": { "$ref": "UnrecognizedProperty" }
}
],
"optional": true
},
"options_ui": {
"type": "object",
@@ -163,20 +165,17 @@
"web_accessible_resources": {
"type": "array",
"items": { "type": "string" },
"optional": true
}
},
- "additionalProperties": {
- "type": "any",
- "deprecated": "An unexpected property was found in the WebExtension manifest"
- }
+ "additionalProperties": { "$ref": "UnrecognizedProperty" }
},
{
"id": "Permission",
"choices": [
{
"type": "string",
"enum": [
"alarms",
@@ -222,16 +221,17 @@
"pattern": "^file:///.*$"
}
]
},
{
"id": "ContentScript",
"type": "object",
"description": "Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. Based on InjectDetails, but using underscore rather than camel case naming conventions.",
+ "additionalProperties": { "$ref": "UnrecognizedProperty" },
"properties": {
"matches": {
"type": "array",
"optional": false,
"minItems": 1,
"items": { "$ref": "MatchPattern" }
},
"exclude_matches": {
@@ -289,15 +289,20 @@
},
{
"type": "object",
"isInstanceOf": "ImageData"
}
]
},
{
+ "id": "UnrecognizedProperty",
+ "type": "any",
+ "deprecated": "An unexpected property was found in the WebExtension manifest."
+ },
+ {
"id": "PersistentBackgroundProperty",
"type": "boolean",
"deprecated": "Event pages are not currently supported. This will run as a persistent background page."
}
]
}
]
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html
+++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html
@@ -68,15 +68,38 @@ add_task(function* test_eventpages() {
let [, x] = yield Promise.all([extension.startup(), extension.awaitMessage("running")]);
is(x, 1, "got correct value from extension");
info("test complete");
yield extension.unload();
info("extension unloaded successfully");
SimpleTest.endMonitorConsole();
yield waitForConsole;
+
+ waitForConsole = new Promise(resolve => {
+ SimpleTest.monitorConsole(resolve, [{
+ message: /Reading manifest: Error processing background.nonExistentProp: An unexpected property was found/,
+ }]);
+ });
+
+ info("testing additional unrecognized properties on background page");
+
+ extension = createEventPageExtension({
+ "scripts": ["event-page-script.js"],
+ "nonExistentProp": true,
+ });
+
+ info("load complete");
+ [, x] = yield Promise.all([extension.startup(), extension.awaitMessage("running")]);
+ is(x, 1, "got correct value from extension");
+ info("test complete");
+ yield extension.unload();
+ info("extension unloaded successfully");
+
+ SimpleTest.endMonitorConsole();
+ yield waitForConsole;
}
});
</script>
</body>
</html>