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

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

mercurial