diff --git a/browser/components/extensions/child/ext-menus.js b/browser/components/extensions/child/ext-menus.js index d9c344dfcc26c..462204a878b38 100644 --- a/browser/components/extensions/child/ext-menus.js +++ b/browser/components/extensions/child/ext-menus.js @@ -136,6 +136,11 @@ this.menusInternal = class extends ExtensionAPI { createProperties.id = ++gNextMenuItemID; } let { onclick } = createProperties; + if (onclick && !context.extension.persistentBackground) { + throw new ExtensionError( + `Property "onclick" cannot be used in menus.create, replace with an "onClicked" event listener.` + ); + } delete createProperties.onclick; context.childManager .callParentAsyncFunction("menusInternal.create", [createProperties]) @@ -159,6 +164,11 @@ this.menusInternal = class extends ExtensionAPI { update(id, updateProperties) { let { onclick } = updateProperties; + if (onclick && !context.extension.persistentBackground) { + throw new ExtensionError( + `Property "onclick" cannot be used in menus.update, replace with an "onClicked" event listener.` + ); + } delete updateProperties.onclick; return context.childManager .callParentAsyncFunction("menusInternal.update", [ diff --git a/browser/components/extensions/schemas/menus.json b/browser/components/extensions/schemas/menus.json index b1aab5212005f..79b1511617f5d 100644 --- a/browser/components/extensions/schemas/menus.json +++ b/browser/components/extensions/schemas/menus.json @@ -243,6 +243,7 @@ }, "onclick": { "type": "function", + "max_manifest_version": 2, "optional": true, "description": "A function that will be called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for $(ref:contextMenus.onClicked).", "parameters": [ @@ -374,6 +375,7 @@ }, "onclick": { "type": "function", + "max_manifest_version": 2, "optional": "omit-key-if-missing", "parameters": [ {