Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bug 855798 - Make add-on builder helper set logging prefs for add-ons it runs so console.log shows up #7

Merged
merged 1 commit into from

2 participants

@Mossop
Owner

Don't we need to unset the preference after the add-on is uninstalled?

@ochameau
Owner

That's something we can do. I pushed an amended revision.

@ochameau ochameau merged commit ea95f68 into mozilla:master
@ochameau ochameau deleted the ochameau:log-pref branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2013
  1. @ochameau

    Bug 855798 - Make add-on builder helper set logging prefs for add-ons…

    ochameau authored
    … it runs so console.log shows up
This page is out of date. Refresh to see the latest.
View
BIN  addons-builder-helper.xpi
Binary file not shown
View
18 lib/addons-builder-helper.js
@@ -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);
}
}
};
Something went wrong with that request. Please try again.