diff --git a/common/content/dactyl.js b/common/content/dactyl.js index bcf420d7..ce85f822 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -211,37 +211,10 @@ const Dactyl = Module("dactyl", { } }, - /** - * Prints a message to the console. If msg is an object it is - * pretty printed. - * - * NOTE: the "browser.dom.window.dump.enabled" preference needs to be - * set. - * - * @param {string|Object} msg The message to print. - */ - dump: function dump() { - let msg = Array.map(arguments, function (msg) { - if (typeof msg == "object") - msg = util.objectToString(msg); - return msg; - }).join(", "); - msg = String.replace(msg, /\n?$/, "\n"); - window.dump(msg.replace(/^./gm, ("config" in modules && config.name) + ": $&")); - }, - - /** - * Dumps a stack trace to the console. - * - * @param {string} msg The trace message. - * @param {number} frames The number of frames to print. - */ - dumpStack: function dumpStack(msg, frames) { - let stack = Error().stack.replace(/(?:.*\n){1}/, ""); - if (frames != null) - [stack] = stack.match(RegExp("(?:.*\n){0," + frames + "}")); - dactyl.dump((msg || "Stack") + "\n" + stack + "\n"); - }, + dump: deprecated("Use util.dump instead", + function dump() util.dump.apply(util, arguments)), + dumpStack: deprecated("Use util.dumpStack instead", + function dumpStack() util.dumpStack.apply(util, arguments)), /** * Outputs a plain message to the command line. @@ -1001,29 +974,7 @@ const Dactyl = Module("dactyl", { return; if (echo) dactyl.echoerr(error); - - if (Cu.reportError) - Cu.reportError(error); - - try { - let obj = { - toString: function () String(error), - stack: <>{String.replace(error.stack || Error().stack, /^/mg, "\t")} - }; - for (let [k, v] in Iterator(error)) { - if (!(k in obj)) - obj[k] = v; - } - if (dactyl.storeErrors) { - let errors = storage.newArray("errors", { store: false }); - errors.toString = function () [String(v[0]) + "\n" + v[1] for ([k, v] in this)].join("\n\n"); - errors.push([new Date, obj + obj.stack]); - } - dactyl.dump(String(error)); - dactyl.dump(obj); - dactyl.dump(""); - } - catch (e) { window.dump(e); } + util.reportError(error); }, /** diff --git a/common/modules/highlight.jsm b/common/modules/highlight.jsm index 737714a3..cf617351 100644 --- a/common/modules/highlight.jsm +++ b/common/modules/highlight.jsm @@ -81,7 +81,7 @@ const Highlights = Module("Highlight", { if (/^[[>+ ]/.test(args[1])) obj.selector = this.selector(obj.class) + args[1]; if (old && old.value != old.default) - obj.value = old.style; + obj.value = old.value; if (!old && obj.base && obj.base.enabled) obj.style.enabled = true; diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 508126a1..dcb827b4 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -226,6 +226,38 @@ const Util = Module("Util", { dequote: function dequote(pattern, chars) pattern.replace(/\\(.)/, function (m0, m1) chars.indexOf(m1) >= 0 ? m1 : m0), + /** + * Prints a message to the console. If msg is an object it is + * pretty printed. + * + * NOTE: the "browser.dom.window.dump.enabled" preference needs to be + * set. + * + * @param {string|Object} msg The message to print. + */ + dump: function dump_() { + let msg = Array.map(arguments, function (msg) { + if (typeof msg == "object") + msg = util.objectToString(msg); + return msg; + }).join(", "); + msg = String.replace(msg, /\n?$/, "\n"); + dump(msg.replace(/^./gm, services.get("dactyl:").name + ": $&")); + }, + + /** + * Dumps a stack trace to the console. + * + * @param {string} msg The trace message. + * @param {number} frames The number of frames to print. + */ + dumpStack: function dumpStack(msg, frames) { + let stack = Error().stack.replace(/(?:.*\n){1}/, ""); + if (frames != null) + [stack] = stack.match(RegExp("(?:.*\n){0," + frames + "}")); + util.dump((msg || "Stack") + "\n" + stack + "\n"); + }, + /** * Converts HTML special characters in str to the equivalent HTML * entities. @@ -644,6 +676,29 @@ const Util = Module("Util", { } }, + reportError: function (error) { + if (Cu.reportError) + Cu.reportError(error); + + try { + let obj = update({}, error, { + toString: function () String(error), + stack: <>{String.replace(error.stack || Error().stack, /^/mg, "\t")} + }); + + let errors = storage.newArray("errors", { store: false }); + errors.toString = function () [String(v[0]) + "\n" + v[1] for ([k, v] in this)].join("\n\n"); + errors.push([new Date, obj + obj.stack]); + + util.dump(String(error)); + util.dump(obj); + util.dump(""); + } + catch (e) { + dump(e); + } + }, + /** * An interruptible generator that returns all values between start * and end. The thread yields every time milliseconds.