- Add the observer:
Code: Select all
let prefs = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService) .getBranch("extensions.yami.preftest."); prefs.addObserver("", yami.preftest, false);
- Point it to an object with observe method:
Code: Select all
yami.preftest = { observe: function observe(sub, topic, data) { if(topic == "nsPref:changed") { /* ... */ } return; }, }
- Install preftest
- Open add-on manager
- Open preftest's options page
- Restart the browser (File > Restart...)
- After the browser restarts, quickly try to change drop-down menu's selection
- "Observer execution counter" should increment
- Open a new tab
- While on that tab, navigate to any webpage
- Switch to the add-on manager's/preftest's options tab
- Try to change drop-down menu's selection again
Does anyone have any idea why this is not working correctly?