This API allows extensions to hide all default Firefox menu items in favor of providing a custom context menu UI. This context menu can consist of multiple top-level menu items from the extension, and may optionally include tab or bookmark context menu items from other extensions. This should be called during a contextmenu DOM event handler, and only applies to the menu that opens after this event.

This API becomes callable only if the addon has the "menus.overrideContext" permission.


  contextOptions // object


object. Properties that set the context for the context menu.
bookmarkId Optional
string Required when context is bookmark. Requires the "bookmark" permission.
context Optional
string. ContextType to override, to allow menu items from other extensions in the menu. Currently only "bookmark" and "tab" are supported. showDefaults cannot be used with this option.
showDefaults Optional
boolean. Whether to also include default menu items in the menu.
tabId Optional
string Required when context is "tab". Requires the "tabs" permission.


Open the tab context menu on your custom UI, in this case :

document.addEventListener('contextmenu', event => {
  const foo ='.foo');
  if (foo) {
    // When the context menu is opened on an element with the foo class
    // set the context to "opening a tab context menu".
      context: 'tab',
      tabId: parseInt(foo.dataset.tabId)
}, { capture: true });

See this blog post for more details.