Replace another webextapiref link for contextMenus#44090
Conversation
|
Preview URLs (1 page) |
|
|
||
| ## 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This sounds like we should revert #44041 as well?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
To accommodate this change, we need to:
- modify the introductory paragraph to note the availability of
contextMenuas an alias tomenu - modify this line to mention
contextMenuandmenuwith 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.
There was a problem hiding this comment.
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
Description
Replaces a link to the
contextMenusAPI, with a link to themenusAPI.Motivation
Resolves the only remaining
webextapirefflaw.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.