Bug 1116708 - xpcshell tests now log console messages. r=chmanchester

This commit is contained in:
Mark Hammond 2015-01-09 10:00:05 +11:00
Родитель f0a3a7e379
Коммит bee2d8a0f5
1 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -111,6 +111,30 @@ try {
}
catch (e) { }
// Configure a console listener so messages sent to it are logged as part
// of the test.
try {
let levelNames = {}
for (let level of ["debug", "info", "warn", "error"]) {
levelNames[Components.interfaces.nsIConsoleMessage[level]] = level;
}
let listener = {
QueryInterface : function(iid) {
if (!iid.equals(Components.interfaces.nsISupports) &&
!iid.equals(Components.interfaces.nsIConsoleListener)) {
throw Components.results.NS_NOINTERFACE;
}
return this;
},
observe : function (msg) {
do_print("CONSOLE_MESSAGE: (" + levelNames[msg.logLevel] + ") " + msg.toString());
}
};
Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService)
.registerListener(listener);
} catch (e) {}
/**
* Date.now() is not necessarily monotonically increasing (insert sob story
* about times not being the right tool to use for measuring intervals of time,