Bug 1234020: Part 2i - [webext] Return promises from the contextMenus API. r=rpl
--- a/browser/components/extensions/ext-contextMenus.js
+++ b/browser/components/extensions/ext-contextMenus.js
@@ -422,44 +422,38 @@ extensions.registerSchemaAPI("contextMen
let menuItem = new MenuItem(extension, context, createProperties);
contextMenuMap.get(extension).set(menuItem.id, menuItem);
if (callback) {
runSafe(context, callback);
}
return menuItem.id;
},
- update: function(id, updateProperties, callback) {
+ update: function(id, updateProperties) {
let menuItem = contextMenuMap.get(extension).get(id);
if (menuItem) {
menuItem.setProps(updateProperties);
}
- if (callback) {
- runSafe(context, callback);
- }
+ return Promise.resolve();
},
- remove: function(id, callback) {
+ remove: function(id) {
let menuItem = contextMenuMap.get(extension).get(id);
if (menuItem) {
menuItem.remove();
}
- if (callback) {
- runSafe(context, callback);
- }
+ return Promise.resolve();
},
- removeAll: function(callback) {
+ removeAll: function() {
let root = rootItems.get(extension);
if (root) {
root.remove();
}
- if (callback) {
- runSafe(context, callback);
- }
+ return Promise.resolve();
},
// TODO: implement this once event pages are ready.
onClicked: new EventManager(context, "contextMenus.onClicked", fire => {
let callback = menuItem => {
fire(menuItem.data);
};
--- a/browser/components/extensions/schemas/context_menus.json
+++ b/browser/components/extensions/schemas/context_menus.json
@@ -204,16 +204,17 @@
"parameters": []
}
]
},
{
"name": "update",
"type": "function",
"description": "Updates a previously created context menu item.",
+ "async": "callback",
"parameters": [
{
"choices": [
{ "type": "integer" },
{ "type": "string" }
],
"name": "id",
"description": "The ID of the item to update."
@@ -290,16 +291,17 @@
"description": "Called when the context menu has been updated."
}
]
},
{
"name": "remove",
"type": "function",
"description": "Removes a context menu item.",
+ "async": "callback",
"parameters": [
{
"choices": [
{ "type": "integer" },
{ "type": "string" }
],
"name": "menuItemId",
"description": "The ID of the context menu item to remove."
@@ -312,16 +314,17 @@
"description": "Called when the context menu has been removed."
}
]
},
{
"name": "removeAll",
"type": "function",
"description": "Removes all context menu items added by this extension.",
+ "async": "callback",
"parameters": [
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [],
"description": "Called when removal is complete."
}