Bug 1444456 - Fix contentScripts.register API schema should not use additionalProperties.
MozReview-Commit-ID: 2Ygqrn42NI3
--- 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}`);