toolkit/devtools/pretty-fast/tests/unit/head_pretty-fast.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 "use strict";
michael@0 2 const Cc = Components.classes;
michael@0 3 const Ci = Components.interfaces;
michael@0 4 const Cu = Components.utils;
michael@0 5 const Cr = Components.results;
michael@0 6
michael@0 7 const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
michael@0 8 const { require } = devtools;
michael@0 9
michael@0 10 this.sourceMap = require("source-map");
michael@0 11 this.acorn = require("acorn/acorn");
michael@0 12 this.prettyFast = require("devtools/pretty-fast");
michael@0 13 const { console } = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
michael@0 14
michael@0 15 // Register a console listener, so console messages don't just disappear
michael@0 16 // into the ether.
michael@0 17 let errorCount = 0;
michael@0 18 let listener = {
michael@0 19 observe: function (aMessage) {
michael@0 20 errorCount++;
michael@0 21 try {
michael@0 22 // If we've been given an nsIScriptError, then we can print out
michael@0 23 // something nicely formatted, for tools like Emacs to pick up.
michael@0 24 var scriptError = aMessage.QueryInterface(Ci.nsIScriptError);
michael@0 25 dump(aMessage.sourceName + ":" + aMessage.lineNumber + ": " +
michael@0 26 scriptErrorFlagsToKind(aMessage.flags) + ": " +
michael@0 27 aMessage.errorMessage + "\n");
michael@0 28 var string = aMessage.errorMessage;
michael@0 29 } catch (x) {
michael@0 30 // Be a little paranoid with message, as the whole goal here is to lose
michael@0 31 // no information.
michael@0 32 try {
michael@0 33 var string = "" + aMessage.message;
michael@0 34 } catch (x) {
michael@0 35 var string = "<error converting error message to string>";
michael@0 36 }
michael@0 37 }
michael@0 38
michael@0 39 do_throw("head_pretty-fast.js got console message: " + string + "\n");
michael@0 40 }
michael@0 41 };
michael@0 42
michael@0 43 let consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
michael@0 44 consoleService.registerListener(listener);
michael@0 45

mercurial