Bug 1444456 - Fix contentScripts.register API schema should not use additionalProperties. draft
authorLuca Greco <lgreco@mozilla.com>
Fri, 09 Mar 2018 18:38:22 +0100
changeset 765381 4b6d6c49cad7e2c228a6f803cfc6fffeac3acca8
parent 765246 f1965cf7425fe422c9e9c78018f11b97e0a0f229
push id102058
push userluca.greco@alcacoop.it
push dateFri, 09 Mar 2018 18:57:21 +0000
bugs1444456
milestone60.0a1
Bug 1444456 - Fix contentScripts.register API schema should not use additionalProperties. MozReview-Commit-ID: 2Ygqrn42NI3
toolkit/components/extensions/schemas/content_scripts.json
toolkit/components/extensions/test/xpcshell/test_ext_contentScripts_register.js
--- a/toolkit/components/extensions/schemas/content_scripts.json
+++ b/toolkit/components/extensions/schemas/content_scripts.json
@@ -26,17 +26,16 @@
             }
           }
         ]
       },
       {
         "id": "RegisteredContentScriptOptions",
         "type": "object",
         "description": "Details of a content script registered programmatically",
-        "additionalProperties": { "$ref": "UnrecognizedProperty" },
         "properties": {
           "matches": {
             "type": "array",
             "optional": false,
             "minItems": 1,
             "items": { "$ref": "manifest.MatchPattern" }
           },
           "excludeMatches": {
--- a/toolkit/components/extensions/test/xpcshell/test_ext_contentScripts_register.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_contentScripts_register.js
@@ -26,25 +26,34 @@ function check_applied_styles() {
 add_task(async function test_contentscripts_register_css() {
   async function background() {
     let cssCode = `
       #registered-extension-text-style {
         background-color: blue;
       }
     `;
 
+    const matches = ["http://localhost/*/file_sample_registered_styles.html"];
+
+    browser.test.assertThrows(() => {
+      browser.contentScripts.register({
+        matches,
+        unknownParam: "unexpected property",
+      });
+    }, /Unexpected property "unknownParam"/, "contentScripts.register throws on unexpected properties");
+
     let fileScript = await browser.contentScripts.register({
       css: [{file: "registered_ext_style.css"}],
-      matches: ["http://localhost/*/file_sample_registered_styles.html"],
+      matches,
       runAt: "document_start",
     });
 
     let textScript = await browser.contentScripts.register({
       css: [{code: cssCode}],
-      matches: ["http://localhost/*/file_sample_registered_styles.html"],
+      matches,
       runAt: "document_start",
     });
 
     browser.test.onMessage.addListener(async (msg) => {
       switch (msg) {
         case "unregister-text":
           await textScript.unregister().catch(err => {
             browser.test.fail(`Unexpected exception while unregistering text style: ${err}`);