-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime.onInstalled use in event pages clarification #29716
runtime.onInstalled use in event pages clarification #29716
Conversation
Preview URLs
External URLs (1)URL:
(comment last updated: 2023-10-27 01:44:42) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that more details are needed before #17212 can be marked as resolved.
The Extension Workshop has a lot of detail on the persistence of menu items across restarts. The short version is that in Firefox, menu items are not persisted in persistent background pages (a persistent background page starts up once and doesn't terminate until the browser or extension unloads, so a top-level create
call will always create the menu), and persisted in non-persistent background pages (aka event page; to avoid repeated attempts to create the menu item, it should be registered only once).
Can you clarify the documentation to reduce this confusion? E.g. by adding a NOTE and more details (maybe even a link to Extension workshop?) in the menus.create article on MDN.
files/en-us/mozilla/add-ons/webextensions/api/menus/create/index.md
Outdated
Show resolved
Hide resolved
@@ -21,6 +21,8 @@ Except for [`menus.getTargetElement()`](/en-US/docs/Mozilla/Add-ons/WebExtension | |||
|
|||
To create a menu item call the {{WebExtAPIRef("menus.create()")}} method. You pass this method an object containing options for the item, including the item ID, item type, and the contexts in which it should be shown. | |||
|
|||
In an extension using non-persistent [background pages](/en-US/docs/Mozilla/Add-ons/WebExtensions/Background_scripts) (Event pages), you call `menus.create` from within a {{WebExtAPIRef("runtime.onInstalled")}} listener. In an extension using persistent background pages, you make a top-level call. See {{WebExtAPIRef("menus.create()")}} for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior is Firefox/Chrome-dependent.
Co-authored-by: Rob Wu <rob@robwu.nl>
Thanks @Rob--W |
Description
Add an explanation as to why stateful API should be included in the onInstalled for event pages. Fixed #17212