content icon indicating copy to clipboard operation
content copied to clipboard

Document `contextMenus` alongside `menus` in WebExtensions API docs

Open caugner opened this issue 1 month ago • 1 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/menus

What specific section or headline is this issue about?

All menus reference pages and the "Context menu items" user interface guide.

What information was incorrect, unhelpful, or incomplete?

MDN only documents the menus namespace. The same API is also available under the contextMenus namespace, with a different permission:

  • menus namespace + menus permission: Firefox and Safari.
  • contextMenus namespace + contextMenus permission: all browsers.

Because contextMenus is barely mentioned, the pages are hard to find when searching for e.g. contextMenus.create, and attempts to fix webextapiref flaws by replacing contextMenus links with menus links (mdn/content#44041, mdn/content#44090) or renaming examples (mdn/webextensions-examples#631) make the content less accurate.

In addition, menus.create and menus.ContextType claim that tools_menu is only available via the menus namespace. This has been incorrect since Firefox 91, where the ContextType differences between the two namespaces were dropped (Bugzilla bug 1706398).

What did you expect to see?

  • [ ] menus landing page: a section explaining the overlap and differences between the two namespaces. Overlap: everything, unless stated otherwise. Differences: menus.getTargetElement() is only available in content scripts with the menus permission; contextMenus is never available in content scripts; browser support as above.
  • [ ] Every menus method, event, and type page: state prominently at the top that it documents both menus.* and contextMenus.*, linking to that section.
  • [ ] menus.create and menus.ContextType: remove the claim that tools_menu requires the menus namespace.
  • [ ] "Context menu items" guide: mention both namespaces and their permissions in the introduction, and use menus in the examples.
  • [ ] menus.create and menus.onClicked: manually link the examples in mdn/webextensions-examples that use contextMenus from the Examples sections, noting that they use contextMenus. The examples themselves stay unchanged (https://github.com/mdn/webextensions-examples/pull/631#issuecomment-6345055895).
  • [ ] Decide how {{WebExtAPIRef("contextMenus.*")}} links should resolve (e.g. in Firefox release notes) once the above is in place.

Do you have any supporting links, references, or citations?

  • https://github.com/mdn/content/pull/44090#discussion_r3226428159
  • https://github.com/mdn/webextensions-examples/pull/631#pullrequestreview-4272353548
  • https://bugzilla.mozilla.org/show_bug.cgi?id=1706398

Do you have anything more you want to share?

No response

caugner avatar Oct 22 '26 16:10 caugner

Hi everyone, I’d like to give it a try.

TheCoderGeekSquadLeader avatar Oct 22 '26 23:10 TheCoderGeekSquadLeader