Bug 1339131 - Provide warnings instead of throwing errors for unrecognized properties r?jaws,mikedeboer
MozReview-Commit-ID: Ger9hssqqpO
--- a/toolkit/components/extensions/schemas/theme.json
+++ b/toolkit/components/extensions/schemas/theme.json
@@ -17,17 +17,18 @@
"headerURL": {
"type": "string",
"optional": true
},
"theme_frame": {
"type": "string",
"optional": true
}
- }
+ },
+ "additionalProperties": { "$ref": "UnrecognizedProperty" }
},
"colors": {
"type": "object",
"optional": true,
"properties": {
"accentcolor": {
"type": "string",
"optional": true
@@ -45,17 +46,18 @@
"type": "number"
},
"optional": true
},
"textcolor": {
"type": "string",
"optional": true
}
- }
+ },
+ "additionalProperties": { "$ref": "UnrecognizedProperty" }
},
"icons": {
"type": "object",
"optional": true,
"properties": {
"back": {
"$ref": "ExtensionURL",
"optional": true
@@ -175,19 +177,21 @@
"forget": {
"$ref": "ExtensionURL",
"optional": true
},
"pocket": {
"$ref": "ExtensionURL",
"optional": true
}
- }
+ },
+ "additionalProperties": { "$ref": "UnrecognizedProperty" }
}
- }
+ },
+ "additionalProperties": { "$ref": "UnrecognizedProperty" }
},
{
"$extend": "WebExtensionManifest",
"properties": {
"theme": {
"optional": true,
"$ref": "ThemeType"
}
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_manifest_themes.js
@@ -0,0 +1,31 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+function* test_theme_property(property) {
+ let normalized = yield ExtensionTestUtils.normalizeManifest({
+ "theme": {
+ [property]: {
+ "unrecognized_key": "unrecognized_value",
+ },
+ },
+ });
+
+ let expectedWarning;
+ if (property === "unrecognized_key") {
+ expectedWarning = `Error processing theme.${property}`;
+ } else {
+ expectedWarning = `Error processing theme.${property}.unrecognized_key`;
+ }
+ equal(normalized.error, undefined, "Should not have an error");
+ equal(normalized.errors.length, 1, "Should have a warning");
+ ok(normalized.errors[0].includes(expectedWarning),
+ `The manifest warning ${JSON.stringify(normalized.errors[0])} must contain ${JSON.stringify(expectedWarning)}`);
+}
+
+add_task(function* test_manifest_themes() {
+ yield test_theme_property("images");
+ yield test_theme_property("colors");
+ yield test_theme_property("icons");
+ yield test_theme_property("unrecognized_key");
+});
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini
@@ -44,16 +44,17 @@ skip-if = release_or_beta
[test_ext_idle.js]
[test_ext_json_parser.js]
[test_ext_localStorage.js]
[test_ext_management.js]
[test_ext_management_uninstall_self.js]
[test_ext_manifest_content_security_policy.js]
[test_ext_manifest_incognito.js]
[test_ext_manifest_minimum_chrome_version.js]
+[test_ext_manifest_themes.js]
[test_ext_onmessage_removelistener.js]
skip-if = true # This test no longer tests what it is meant to test.
[test_ext_privacy.js]
[test_ext_privacy_disable.js]
[test_ext_privacy_update.js]
[test_ext_runtime_connect_no_receiver.js]
[test_ext_runtime_getBrowserInfo.js]
[test_ext_runtime_getPlatformInfo.js]