Closed Bug 1288695 Opened 8 years ago Closed 8 years ago

Reloading web extension duplicates context menu items

Categories

(WebExtensions :: Untriaged, defect)

49 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1246044

People

(Reporter: haavii, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0
Build ID: 20160623154057

Steps to reproduce:

1. Create a web extension that adds a background script that calls chrome.contextMenus.create() to create a new context menu item. What contexts or type you use for the menu item does not make any difference.

2. Reload the extension using either by autoreloading it using web-ext or by manually reloading using the reload button in the about:debugging window.

I can reproduce this issue using the context menu demo found here: https://github.com/mdn/webextensions-examples/tree/master/context-menu-demo

I'm using Firefox Developer Edition 49.0a2 (2016-07-21) running with Administrator rights when testing this.


Actual results:

Context menu items created before previous reloads are not being removed so it will add a new menu item every time the extension gets reloaded. Calling chrome.contextMenus.removeAll() and chrome.contextMenus.remove('id') before adding new menu items does not remove menu items that were added before the previous reload.

If you register an onClicked listener the callback will only get called if you click the last duplicated menu item in the context menu.


Expected results:

Old context menu items should be removed when reloading the web extension. 

If they don't get cleaned up on reloads the context menu will get filled up with duplicated menu items very quickly if you use the autoreload feature in web-ext that will reload the extension every time a file is modified.
It's already fixed in Nightly, by bug 1246044 patch part 2.
  https://hg.mozilla.org/integration/fx-team/rev/2eb259ef1448
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
QA Whiteboard: [bugday-20160725]
Component: Untriaged → WebExtensions
Product: Firefox → Toolkit
Resolution: --- → DUPLICATE
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.