nsIPrefBranch for Firefox for android extension returns NS_ERROR_UNEXPECTED

Bootstrapped (restartless) add-ons do not support auto-prefs via defaults/preferences. It is the responsibility of your bootstrap code to set up default preferences accordingly.

Since your auto-prefs were never loaded, the getCharPref() call has to fail.

You will need to get the default branch and seed your preferences. An easy way to do so would be:

const PREF_BRANCH =
"extensions.myaddon.";
const PREFS = {
  someIntPref: 1,
  someStringPref: "some text value"
};

function setDefaultPrefs() {
  let branch =
Services.prefs.getDefaultBranch(PREF_BRANCH);
  for (let [key, val] in Iterator(PREFS)) {
    switch (typeof val) {
      case "boolean":
        branch.setBoolPref(key, val);
        break;
      case "number":
        branch.setIntPref(key, val);
        break;
      case "string":
        branch.setCharPref(key, val);
        break;
    }
  }
}

function startup(aData, aReason) {
  // Always set the default prefs as they
disappear on restart
  setDefaultPrefs();
  ...
}

There are alternatives, like using mozISubscriptLoader or Sandboxes, but I don't really have stand-alone code that can be easily copied for that.


Related to : nsIPrefBranch for Firefox for android extension returns NS_ERROR_UNEXPECTED
jvectormaps with firefox results in unexpected error
Issue resolved. Well a work around really. The issues is that Jvectormap does not do well with dynamic width and height. i was using a 85% height on the div container. I set this to one, and then in the Java doc ready i use this code to set it to the correct size taking in consideration for other elements $("#map").css("height", $(document).height() - 120); // Hot fix for cross browser support
Firefox extension js error log, where?
Make sure you don't have your logging level turned off: extensions.sdk.console.logLevel Logging Levels
Firefox extension debugging - how can I enable showing info about syntax error in error console?
It's a Bug 986689 in v30 and newer. For now I'm using older version of Firefox. v29 seems to be the latest that still shows the errors. Another possible solution is to use try { //code here } catch(ex) { //error captured dump(ex) } and output in console ex in catch (although it won't help with syntax errors)
Why my firefox for android extension is deactivated on its own?
the error was caused by the tabSelect event listener, it was added in the wrong place, to make it work properly, I did this: //adding the listeners let addListener = function() { window.BrowserApp.deck.addEventListener("TabSelect", function(){ watchTab(window);}, false); window.BrowserApp.deck.addEventListener("pageshow", function(){ watchTab(window);}, false); win
unexpected error with php fileinfo extension usage (windows wamp)
The examples for finfo_open in the manual only show finfo_close being used when the procedural style with finfo_open is used – in the first example for the object-oriented style (new finfo(…)) you’ll notice that there is no call to finfo_close there … so I’d assume that it is simply not needed in this case.

Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .