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: Cu.import("resource://gre/modules/devtools/Loader.jsm"); michael@0: Cu.import("resource://gre/modules/devtools/DevToolsUtils.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: // Make sure we exit all nested event loops so that the test can finish. michael@0: while (DebuggerServer.xpcInspector.eventLoopNestLevel > 0) { michael@0: DebuggerServer.xpcInspector.exitNestedEventLoop(); michael@0: } michael@0: do_throw("head_dbg.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);