Permalink
Browse files

Merge pull request #7 from ochameau/log-pref

Bug 855798 - Make add-on builder helper set logging prefs for add-ons it runs so console.log shows up r=@Mossop
  • Loading branch information...
2 parents d0a717f + eafde59 commit ea95f68e12e02058fcc92d36f220d7e0bdb694f8 @ochameau ochameau committed Apr 15, 2013
Showing with 16 additions and 2 deletions.
  1. BIN addons-builder-helper.xpi
  2. +16 −2 lib/addons-builder-helper.js
View
Binary file not shown.
@@ -6,7 +6,7 @@ const { Cc, Ci, Cu } = require('chrome');
const windowManager = Cc['@mozilla.org/appshell/window-mediator;1'].
getService(Ci.nsIWindowMediator);
const windowUtils = require("sdk/window/utils");
-
+const prefService = require("sdk/preferences/service");
const { PageMod } = require("sdk/page-mod");
const AddonInstaller = require("sdk/addon/installer");
@@ -133,6 +133,15 @@ function onContentScriptRequest(addonManager, args, callback) {
return null;
}
+function setLogPref(addonId) {
+ let prefName = "extensions." + addonId + ".sdk.console.logLevel";
+ prefService.set(prefName, "all");
+}
+function resetLogPref(addonId) {
+ let prefName = "extensions." + addonId + ".sdk.console.logLevel";
+ prefService.reset(prefName);
+}
+
function SingleAddonManager() {
let currentAddonId = null;
@@ -156,6 +165,9 @@ function SingleAddonManager() {
else {
let xpiPath = tmpFile.createFromString(xpiData);
AddonInstaller.install(xpiPath).then(function success(addonId) {
+ // Enable log for this addon:
+ setLogPref(addonId);
+
currentAddonId = addonId;
if (typeof callback == "function")
callback(true, addonId);
@@ -176,7 +188,9 @@ function SingleAddonManager() {
else {
let addonId = currentAddonId;
currentAddonId = null;
- AddonInstaller.uninstall(addonId).then(callback);
+ AddonInstaller.uninstall(addonId)
+ .then(resetLogPref.bind(null, addonId))
+ .then(callback);
}
}
};

0 comments on commit ea95f68

Please sign in to comment.