michael@0: "use strict"; michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: const Cr = Components.results; michael@0: michael@0: const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); michael@0: const { require } = devtools; michael@0: michael@0: this.sourceMap = require("source-map"); michael@0: this.acorn = require("acorn/acorn"); michael@0: this.prettyFast = require("devtools/pretty-fast"); michael@0: const { console } = Cu.import("resource://gre/modules/devtools/Console.jsm", {}); michael@0: michael@0: // Register a console listener, so console messages don't just disappear michael@0: // into the ether. michael@0: let errorCount = 0; michael@0: let listener = { michael@0: observe: function (aMessage) { michael@0: errorCount++; michael@0: try { michael@0: // If we've been given an nsIScriptError, then we can print out michael@0: // something nicely formatted, for tools like Emacs to pick up. michael@0: var scriptError = aMessage.QueryInterface(Ci.nsIScriptError); michael@0: dump(aMessage.sourceName + ":" + aMessage.lineNumber + ": " + michael@0: scriptErrorFlagsToKind(aMessage.flags) + ": " + michael@0: aMessage.errorMessage + "\n"); michael@0: var string = aMessage.errorMessage; michael@0: } catch (x) { michael@0: // Be a little paranoid with message, as the whole goal here is to lose michael@0: // no information. michael@0: try { michael@0: var string = "" + aMessage.message; michael@0: } catch (x) { michael@0: var string = ""; michael@0: } michael@0: } michael@0: michael@0: do_throw("head_pretty-fast.js got console message: " + string + "\n"); michael@0: } michael@0: }; michael@0: michael@0: let consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService); michael@0: consoleService.registerListener(listener); michael@0: