bug 576962 - console log/info etc. does handle multiple arguments + newline, r=dietrich

This commit is contained in:
Julian Viereck 2010-07-16 12:00:53 -03:00
Родитель 30283a41fd
Коммит fcbd30d2ec
4 изменённых файлов: 30 добавлений и 17 удалений

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

@ -1988,34 +1988,29 @@ function HUDConsole(aHeadsUpDisplay)
HUDConsole.prototype = {
created: null,
log: function console_log(aMessage)
log: function console_log()
{
this.message = aMessage;
this.sendToHUDService("log");
this.sendToHUDService("log", arguments);
},
info: function console_info(aMessage)
info: function console_info()
{
this.message = aMessage;
this.sendToHUDService("info");
this.sendToHUDService("info", arguments);
},
warn: function console_warn(aMessage)
warn: function console_warn()
{
this.message = aMessage;
this.sendToHUDService("warn");
this.sendToHUDService("warn", arguments);
},
error: function console_error(aMessage)
error: function console_error()
{
this.message = aMessage;
this.sendToHUDService("error");
this.sendToHUDService("error", arguments);
},
exception: function console_exception(aMessage)
exception: function console_exception()
{
this.message = aMessage;
this.sendToHUDService("exception");
this.sendToHUDService("exception", arguments);
},
timeStamp: function Console_timeStamp()
@ -2023,7 +2018,7 @@ HUDConsole.prototype = {
return ConsoleUtils.timeStamp(new Date());
},
sendToHUDService: function console_send(aLevel)
sendToHUDService: function console_send(aLevel, aArguments)
{
// check to see if logging is on for this level before logging!
var filterState = HUDService.getFilterState(this.hudId, aLevel);
@ -2041,8 +2036,13 @@ HUDConsole.prototype = {
messageNode.setAttribute("class", klass);
let argsArray = [];
for (var i = 0; i < aArguments.length; i++) {
argsArray.push(aArguments[i]);
}
let timestampedMessage =
this.chromeDocument.createTextNode(ts + ": " + this.message);
this.chromeDocument.createTextNode(ts + ": " + argsArray.join(" "));
messageNode.appendChild(timestampedMessage);
// need a constructor here to properly set all attrs

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

@ -226,6 +226,17 @@ function testConsoleLoggingAPI(aMethod)
ok(count == 0, aMethod + " logging tunred off, 0 messages logged");
HUDService.clearDisplay(hudId);
filterBox.value = "";
// test for multiple arguments.
HUDService.clearDisplay(hudId);
HUDService.setFilterState(hudId, aMethod, true);
browser.contentWindow.wrappedJSObject.console[aMethod]("foo", "bar");
let HUD = HUDService.hudWeakReferences[hudId].get();
let jsterm = HUD.jsterm;
let outputLogNode = jsterm.outputNode;
ok(/foo bar/.test(outputLogNode.childNodes[0].childNodes[0].nodeValue),
"Emitted both console arguments");
}
function testLogEntry(aOutputNode, aMatchString, aSuccessErrObj)

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

@ -57,6 +57,7 @@
.hud-output-node div {
-moz-user-select: text;
white-space: pre-wrap;
}
.hud-output-node .hud-network {

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

@ -57,6 +57,7 @@
.hud-output-node div {
-moz-user-select: text;
white-space: pre-wrap;
}
.hud-output-node .hud-network {