[Webextensions] Debugging management.onDisabled listener in FDE


we have webExtension that installs a proprietary pkcs#11
at Firefox startup.

We would this security module be unloaded when the extension is disable.

I’am working aroud the management.onDisabled listener to add code
for this logic.

I added a console.log() statement in the code of this listener to verify it’s called.

In about:debugging environment within FDE:

  • i load the extension file as temporary extension,
  • click on ‘Examine’ button: I see in webconsole that the extension is correctly loaded and do its job (ie installing the pkcs#11).
  • Then I go to extensions panel, i disable the extension,
  • I return to webconsole, and i don’t see the log: the listener seems not called. I only see the message ‘webconsole context has changed

So how do I debug listeners of the ‘onDisabled’ event in FDE?

Note that I execute the code of listener installation in the backgroud script. Is it the right place?

Thanks for your help.

The background script is the right place for the listeners, because it’s guaranteed to always exist.

As for debugging the onDisabled (or onUninstalled) handler, I don’t know if that’s possible. This seems like a flaw in Firefox.

  • Using the debugger to set breakpoints inside the handlers doesn’t work, they simply aren’t triggered.
  • notifications don’t work, they aren’t shown

I’m not even sure what kind of cleanup you can perform in these handlers.
The only thing that seems to work reliably is detecting when another extension is disabled/uninstalled, because the onInstalled/onUninstalled/onEnabled/onDisabled events fire for all extensions, not just the one where the handlers are defined.

Hi hans,

Thanks for your reply,

We will do meet our need another way: ie show a popup for end user to explicitly unload the security module if it is loaded and conversely…