Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Zombie compartments in GM_registerMenuCommand/GM_MenuCommander.onPopupShowing #1608
Steps to reproduce:
Tested with GM 1.0, Firefox 15.0 and 17.0a1 (nightly from 2012-08-24).
The reason for this leak seems to be that GM_MenuCommander.onPopupShowing (via createMenuItem) attaches an event listener to the menu item, which via the command function keeps a reference to the content scope. Since the event listener is never removed, the scope and thus the compartment is held alive.
I'm only able to reproduce this once per Firefox instance though, not sure why.
This depends on DOM cleanup. I thought removing the element from the DOM meant Firefox also cleaned up the event handlers' references.
But if you have two separate GM_rmc scripts affecting two different domains, you can see that the first page's menu item causes a leaked compartment. The second time you open the menu on a different domain, you should see the first compartment removed, and the second compartment stays referenced by that different menu item.
But that's not what I see. I see the first page that you ever opened the menu on stay, forever. Everything else gets cleaned up as expected. I don't have an explanation yet.