Restarting manifest v3 extension removes its context menu entry
Categories
(WebExtensions :: General, defect, P2)
Tracking
(firefox128 fixed)
Tracking | Status | |
---|---|---|
firefox128 | --- | fixed |
People
(Reporter: jastekken, Assigned: rpl)
References
(Blocks 3 open bugs)
Details
(Whiteboard: [addons-jira])
Attachments
(1 file, 1 obsolete file)
STR:
Create a manifest v3 extension which only creates simple context menu entry in its background-script:
browser.runtime.onInstalled.addListener(()=>{
browser.menus.create({
id: "test_menu_x",
title: "test_menu_x",
contexts: ["page"]
});
});
browser.menus.onClicked.addListener((menus,tab) => {
console.log("test")
});
- Package it as zip/xpi and install it through about:addons
- Do not grant private mode permission on install time (otherwise next step is impossible to observe)
- Right-click on a page and observe created context-menu entry
- Go back to addons manager and and grant the extension a permission to run in private windows.
- Right-click on a page again, and observe the menu item is not there.
The same also happens when disabling / enabling the extension. And if you grant the extension the private-mode permission on installation popup, then you won't see any menu-item at all. The only way to recover from this state seem to be to re-install the extension.
Updated•2 years ago
|
Updated•2 years ago
|
Comment 1•2 years ago
|
||
For now, this can be worked around by always creating the menu at the top level of the background script. If you use the callback, you'll get lastError in cases it is persisted, If you don't it is silent.
Updated•2 years ago
|
Updated•2 years ago
|
Comment 2•2 years ago
|
||
This is where it is cleared:
https://searchfox.org/mozilla-central/rev/77a39e7595198fd30b57550749c15761d30314fb/toolkit/components/extensions/Extension.jsm#3299-3301
One could exclude the menus storage here:
https://searchfox.org/mozilla-central/rev/77a39e7595198fd30b57550749c15761d30314fb/toolkit/components/extensions/ExtensionParent.jsm#2170
Comment 3•2 years ago
|
||
Comment 4•2 years ago
|
||
Could you give me some feedback about the supplied patch?
Comment 5•2 years ago
|
||
See also bug 1817287, the menus should be persistent also across disable/enable addon. Since enabling addon won't fire onInstalled
event so menus would disappear again.
Comment 6•2 years ago
|
||
Comparison with Chrome behavior: https://bugzilla.mozilla.org/show_bug.cgi?id=1558336#c7
Comment 7•2 years ago
|
||
This doesn't seem to be specific for MV3. I believe I see same problem with my MV2-extension (xIFr 2.9.0(*)).
To work around other (related?) issues, I'm currently adding my menu-item on both:
- onInstalled
- onStartup
However that turns out not to be enough....
I just did a new install of my MV2-extension in Firefox 112 Dev.Ed. When prompted at the install, I choose to ALLOW use in Private mode.
I continued to a webpage where I could try the extension, but the menu-item was missing.
I restarted the browser, and I got my menu-item.
((*) I will probably make a v2.9.1 that also creates menu-item in top-level of backgroundscript, and hope that helps. But work-arounds for various Firefox issues is starting to take a lot of space in my backgroundscript - I guess it also harms browser-performance)
Updated•8 months ago
|
Assignee | ||
Comment 8•6 months ago
|
||
Updated•6 months ago
|
Updated•6 months ago
|
Updated•5 months ago
|
Updated•5 months ago
|
Comment 10•5 months ago
|
||
bugherder |
Comment 11•4 months ago
|
||
This was the last blocker to migrate my extension to MV3. Thank you!
Description
•