Updating Firefox addon jsm module code without browser restart

181 Views Asked by At

I am developing a Firefox addon that is loaded from a directory instead of an xpi, Firefox extension proxy file. The extension is based on jsm modules.

Is there a way to update those modules to reflect the code changes. The only way to do it now is to close and restart the browser but that its not a sane way to develop anything.

Tried to:

    Components.utils.unload('resource://myextension/mymodule.jsm');
    Components.utils.import('resource://myextension/mymodule.jsm');

but changes are not made.

1

There are 1 best solutions below

1
On

Got the answer from Victor Porof. In order to make this work you need to clear first the cache:

var obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
obs.notifyObservers(null, "startupcache-invalidate", null);

Hope this helps anyone