зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1117001 - xpcshell tests now log console messages. r=chmanchester
This commit is contained in:
Родитель
423bc3e176
Коммит
f19948b19d
|
@ -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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче