Closed Bug 1771328 Opened 2 years ago Closed 5 months ago

Restarting manifest v3 extension removes its context menu entry

Categories

(WebExtensions :: General, defect, P2)

Firefox 102
defect

Tracking

(firefox128 fixed)

RESOLVED FIXED
128 Branch
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.

Assignee: nobody → mixedpuppy
Severity: -- → S2
Priority: -- → P2
Whiteboard: [addons-jira]

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.

Severity: S2 → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Blocks: 1587876
See Also: → 1762394

Could you give me some feedback about the supplied patch?

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.

Blocks: 1817287
See Also: → 1558336

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)

See Also: → 1700797
Assignee: mixedpuppy → nobody
Attachment #9305989 - Attachment is obsolete: true
Assignee: nobody → lgreco
Attachment #9396319 - Attachment description: WIP: Bug 1771328 - Persist WebExtensions menus across sessions for extensions with a non-persistent background context. → Bug 1771328 - Persist WebExtensions menus across sessions for extensions with a non-persistent background context. r?robwu!
Status: NEW → ASSIGNED
Attachment #9396319 - Attachment description: Bug 1771328 - Persist WebExtensions menus across sessions for extensions with a non-persistent background context. r?robwu! → WIP: Bug 1771328 - Persist WebExtensions menus across sessions for extensions with a non-persistent background context. r?robwu!
Attachment #9396319 - Attachment description: WIP: Bug 1771328 - Persist WebExtensions menus across sessions for extensions with a non-persistent background context. r?robwu! → Bug 1771328 - Persist WebExtensions menus across sessions for extensions with a non-persistent background context. r?robwu!
Pushed by luca.greco@alcacoop.it: https://hg.mozilla.org/integration/autoland/rev/13d79f6079ba Persist WebExtensions menus across sessions for extensions with a non-persistent background context. r=robwu
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 128 Branch
See Also: → 1898592

This was the last blocker to migrate my extension to MV3. Thank you!

Blocks: 1901804
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: