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

This commit is contained in:
Mark Hammond 2015-01-09 09:53:34 +11:00
Родитель 423bc3e176
Коммит f19948b19d
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,