Skip to content

Replace another webextapiref link for contextMenus#44090

Open
caugner wants to merge 1 commit into
mainfrom
replace-contextmenus-with-menus
Open

Replace another webextapiref link for contextMenus#44090
caugner wants to merge 1 commit into
mainfrom
replace-contextmenus-with-menus

Conversation

@caugner
Copy link
Copy Markdown
Collaborator

@caugner caugner commented May 12, 2026

Description

Replaces a link to the contextMenus API, with a link to the menus API.

Motivation

Resolves the only remaining webextapiref flaw.

Additional details

See: https://caugner.github.io/mdn-flawless/#locale=en-US&templ=webextapiref

Related issues and pull requests

Part of mdn/fred#1462.

Follow-up of #44041.

@caugner caugner requested a review from a team as a code owner May 12, 2026 11:28
@caugner caugner requested review from willdurand and removed request for a team May 12, 2026 11:28
@github-actions github-actions Bot added the Content:WebExt WebExtensions docs label May 12, 2026
@caugner caugner marked this pull request as draft May 12, 2026 11:28
@github-actions github-actions Bot added the size/xs [PR only] 0-5 LoC changed label May 12, 2026
@caugner caugner marked this pull request as ready for review May 12, 2026 11:29
@github-actions
Copy link
Copy Markdown
Contributor


## Specifying context menu items

You manage context menu items programmatically, using the {{WebExtAPIRef("contextMenus")}} API. However, you need to request the `contextMenus` permission in your manifest.json to be able to take advantage of the API.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This edit makes the article incorrect. Although mdn only features "menus" without "contextMenus", we should really be documenting both instead of deleting references to contextMenus.

Sadly the same API is available under 2 namespaces, but different permissions.

contextMenus namespace + contextMenus permission

menus namespace + menus permission.

menus is available in Firefox and Safari, not Chrome.

contextMenus is available in all.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like we should revert #44041 as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked #44041 before and that looks all right. The reference to ContextType doesn't care about the namespace, it is just a pointer to the location for documentation.

The release notes - well until we actually have distinct articles for contextMenus/menus, there is no point in also linkifying contextMenus there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To accommodate this change, we need to:

  • modify the introductory paragraph to note the availability of contextMenu as an alias to menu
  • modify this line to mention contextMenu and menuwith their relevant permissions.
  • modify the examples that follow to use menu (given that this is the API documented).

@caugner, if @Rob--W is happy with this, I can make the necessary changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If menus/contextMenus (plural), sgtm.

Please also check all menus articles and prominently put at the top that the article documents the behavior for menus.create and contextMenus.create (similarly for all other methods), and link to a section that explains the overlap and differences between the two. Right now the SEO for "contextMenus.create" is poor; I hope that the mention would improve the ease of discovery.

Overlap: unless stated otherwise everything.

Differences:

  • the menus permission unlocks the menus namespace with getTargetElement in the content script. This method is only available with menus, not contextMenus. The contextMenus API is never available in content scripts.
  • menus available in Firefox and Safari, contextMenus available to all.

There are also the following inaccuracies:
Some articles (e.g. menus.create) state that tools_menu is only available in the menus namespace. This is not true, in Firefox 91 the differences between the two namespaces with regards to ContextType were intentionally dropped: https://bugzilla.mozilla.org/show_bug.cgi?id=1706398 following my request at https://phabricator.services.mozilla.com/D116858#inline-649130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebExt WebExtensions docs size/xs [PR only] 0-5 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants