bug 576963 - executed string is written to the console output after executing it, r=dietrich

This commit is contained in:
Julian Viereck 2010-07-16 12:10:36 -03:00
Родитель fcbd30d2ec
Коммит 24f6b3b7d6
2 изменённых файлов: 36 добавлений и 3 удалений

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

@ -2192,18 +2192,20 @@ JSTerm.prototype = {
return this.context.get().QueryInterface(Ci.nsIDOMWindowInternal);
},
execute: function JST_execute()
execute: function JST_execute(aExecuteString)
{
// attempt to execute the content of the inputNode
var str = this.inputNode.value;
var str = aExecuteString || this.inputNode.value;
if (!str) {
this.console.log("no value to execute");
return;
}
this.writeOutput(str);
try {
var result =
Cu.evalInSandbox(str, this.sandbox, "default", "HUD Console", 1);
this.writeOutput(str);
if (result !== undefined) {
this.writeOutput(result);
@ -2236,6 +2238,15 @@ JSTerm.prototype = {
node.scrollIntoView(false);
},
clearOutput: function JST_clearOutput()
{
let outputNode = this.outputNode;
while (outputNode.firstChild) {
outputNode.removeChild(outputNode.firstChild);
}
},
keyDown: function JSTF_keyDown(aEvent)
{
var self = this;

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

@ -273,6 +273,27 @@ function testNet()
});
}
function testOutputOrder()
{
let HUD = HUDService.hudWeakReferences[hudId].get();
let jsterm = HUD.jsterm;
let outputNode = jsterm.outputNode;
jsterm.clearOutput();
jsterm.execute("console.log('foo', 'bar');");
is(outputNode.childNodes.length, 2, "Two children in output");
let outputChildren = outputNode.childNodes;
let executedStringFirst =
/console\.log\('foo', 'bar'\);/.test(outputChildren[0].childNodes[0].nodeValue);
let outputSecond =
/foo bar/.test(outputChildren[1].childNodes[0].nodeValue);
ok(executedStringFirst && outputSecond, "executed string comes first");
}
function testCreateDisplay() {
ok(typeof cs.consoleDisplays == "object",
"consoledisplays exist");
@ -452,6 +473,7 @@ function test() {
testRecordManyEntries();
testIteration();
testConsoleHistory();
testOutputOrder();
// testUnregister();
executeSoon(function () {