menu-demo to Manifest v3#634
Open
rebloor wants to merge 3 commits into
Open
Conversation
Rob--W
approved these changes
May 28, 2026
Member
Rob--W
left a comment
There was a problem hiding this comment.
Looks good with minor adjustments.
| */ | ||
| function onCreated() { | ||
| if (browser.runtime.lastError) { | ||
| console.log(`Error: ${browser.runtime.lastError}`); |
Member
There was a problem hiding this comment.
menus.create is special, unlike many other extension APIs it does not return a Promise even though it is async.
I think that it would still be useful to log an error to show how error handling works. The "Item created successfully" part can be dropped though.
The console.log call should include a .message though, as in: browser.runtime.lastError.message
Collaborator
Author
There was a problem hiding this comment.
@Rob--W done, plus some tweaks to the comments
| "menus.onClicked", | ||
| "menus.remove", | ||
| "menus.update", | ||
| "runtime.lastError", |
Member
There was a problem hiding this comment.
Keep runtime.lastError as an example, see my comment in background.js.
Co-authored-by: Rob Wu <rob@robwu.nl>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change migrates the menu-demo example to manifest V3. To do this, these changes were made:
manifest.json
manifest_versionupgraded from2to3scriptsarray)"scripting"permission (required by the Scripting API)menu-demo@mozilla.orgstrict_min_versionupdated from56.0a1to109.0(minimum for MV3)data_collection_permissionskey added with"required": ["none"]open_at_install: falseadded tosidebar_actionto suppress automatic sidebar opening on installbackground.js
browser.runtime.onInstalled.addListener()— the correct pattern for non-persistent backgrounds, since menus persist across restarts but the top-level code would otherwise re-run each time the background wakesbrowser.tabs.executeScriptreplaced withbrowser.scripting.executeScriptusingfuncandargsinstead of an inline code stringlet blue/green(code strings) replaced withconst blue/green(border value strings)removing.then(...)inlined tobrowser.menus.remove(...).then(...)examples.json
runtime.lastErrorreplaced withruntime.onInstalledtabs.executeScriptreplaced withscripting.executeScriptmessages.json
README.md
contextMenusalias are needed to run on Chrome.