Bug 1253565 - [webext] reusable 'UnrecognizedProperty' type for manifest schema validation. r?kmag draft
authorLuca Greco <lgreco@mozilla.com>
Thu, 10 Mar 2016 19:06:55 +0100
changeset 341080 e051d6c445ecd47e55cd4da6393f668fc7af5bd1
parent 341079 568e09611c6adb00ecbfc9dbf8280136e1e84bd4
child 341081 19b8dcfbe7c1bc1a5a06fc66253623b2e9fc1801
push id13131
push userluca.greco@alcacoop.it
push dateWed, 16 Mar 2016 13:28:58 +0000
reviewerskmag
bugs1253565
milestone48.0a1
Bug 1253565 - [webext] reusable 'UnrecognizedProperty' type for manifest schema validation. r?kmag MozReview-Commit-ID: LLWb07ybvlb
toolkit/components/extensions/schemas/manifest.json
toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html
--- 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>