Closed
Bug 1338789
Opened 8 years ago
Closed 8 years ago
WebExtension: context menu listener not correctly removed
Categories
(WebExtensions :: Untriaged, defect)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: geoffreydebelie, Unassigned)
References
Details
Attachments
(1 file)
3.96 KB,
application/zip
|
Details |
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0
Build ID: 20170203110047
Steps to reproduce:
This took a while to reproduce, but I'm able to provide this to you :)
1) Load the attached webextension.
2) Make a selection -> right click -> "Click me and check browser console".
3) The listener fires one time.
4) Go to the settings of the bug-webextension. Click "Save preferences".
5) Now, go to step 2 (make a DIFFERENT selection so the output is clear)
6) The listener fires two times (can be seen in the browser console)
7) If you do this many times after each other, the listener will fire n times + 1
If I wrote the code the wrong way, please tell me how to write the code otherwise.
Actual results:
Browser console output:
you clicked me with selectionText Vertalingen hug EN>NL. 1 to hold close to oneself with the arms, especially to show love: “She hugged her son when he returned from the war.” omhelzen background.js:28:3 (x1)
you clicked me with selectionText Betekenis ' hug '. Je hebt gezocht op het woord: hug. hug·gen (hugde, heeft gehugd) 1knuffelen door te omhelzen en tegen zich aan te drukken ... background.js:28:3 (x2)
you clicked me with selectionText I think what you need is a hug.Creo que lo que necesitas es un abrazo. transitive verb. 2. (to embrace). a. abrazar. When he finally saw his brother, background.js:28:3 (x3)
you clicked me with selectionText hug - Translation to Spanish, pronunciation, and forum discussions. background.js:28:3 (x4)
Expected results:
Browser console output:
you clicked me with selectionText Vertalingen hug EN>NL. 1 to hold close to oneself with the arms, especially to show love: “She hugged her son when he returned from the war.” omhelzen background.js:28:3 (x1)
you clicked me with selectionText Betekenis ' hug '. Je hebt gezocht op het woord: hug. hug·gen (hugde, heeft gehugd) 1knuffelen door te omhelzen en tegen zich aan te drukken ... background.js:28:3 (x1)
you clicked me with selectionText I think what you need is a hug.Creo que lo que necesitas es un abrazo. transitive verb. 2. (to embrace). a. abrazar. When he finally saw his brother, background.js:28:3 (x1)
you clicked me with selectionText hug - Translation to Spanish, pronunciation, and forum discussions. background.js:28:3 (x1)
Reporter | ||
Comment 1•8 years ago
|
||
If this is due to the "listener" function being enclosed in another function and such Firefox not recognising it anymore, maybe that's a bug because I used a named function and not an anonymous function.
The best approach to this is probably when I call browser.contextMenus.removeAll(); to also remove all listeners attached to those context menu items.
Component: Untriaged → WebExtensions: Untriaged
Product: Firefox → Toolkit
Comment 2•8 years ago
|
||
Each call to initContextMenus creates a new `listener` function. The second call tries to remove the new listener that you haven't added yet, not the one that was added in the previous call.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
Updated•7 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•