Bug 1253565 - [webext] reusable 'UnrecognizedProperty' type for manifest schema validation. r=kmag
authorLuca Greco <lgreco@mozilla.com>
Thu, 10 Mar 2016 19:06:55 +0100
changeset 288934 46794fe72b80b118bcafcf7ce9c830c7c8073a3a
parent 288933 9891272b3f0985a58c1e98b8887619a6e3422af5
child 288935 96c02999683fcc53b23aafa0987211a4c0659ffc
push id18202
push usercbook@mozilla.com
push dateWed, 16 Mar 2016 15:51:57 +0000
treeherderfx-team@c715f7a51827 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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>