зеркало из https://github.com/mozilla/pjs.git
bug 576963 - executed string is written to the console output after executing it, r=dietrich
This commit is contained in:
Родитель
fcbd30d2ec
Коммит
24f6b3b7d6
|
@ -2192,18 +2192,20 @@ JSTerm.prototype = {
|
||||||
return this.context.get().QueryInterface(Ci.nsIDOMWindowInternal);
|
return this.context.get().QueryInterface(Ci.nsIDOMWindowInternal);
|
||||||
},
|
},
|
||||||
|
|
||||||
execute: function JST_execute()
|
execute: function JST_execute(aExecuteString)
|
||||||
{
|
{
|
||||||
// attempt to execute the content of the inputNode
|
// attempt to execute the content of the inputNode
|
||||||
var str = this.inputNode.value;
|
var str = aExecuteString || this.inputNode.value;
|
||||||
if (!str) {
|
if (!str) {
|
||||||
this.console.log("no value to execute");
|
this.console.log("no value to execute");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.writeOutput(str);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var result =
|
var result =
|
||||||
Cu.evalInSandbox(str, this.sandbox, "default", "HUD Console", 1);
|
Cu.evalInSandbox(str, this.sandbox, "default", "HUD Console", 1);
|
||||||
this.writeOutput(str);
|
|
||||||
|
|
||||||
if (result !== undefined) {
|
if (result !== undefined) {
|
||||||
this.writeOutput(result);
|
this.writeOutput(result);
|
||||||
|
@ -2236,6 +2238,15 @@ JSTerm.prototype = {
|
||||||
node.scrollIntoView(false);
|
node.scrollIntoView(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearOutput: function JST_clearOutput()
|
||||||
|
{
|
||||||
|
let outputNode = this.outputNode;
|
||||||
|
|
||||||
|
while (outputNode.firstChild) {
|
||||||
|
outputNode.removeChild(outputNode.firstChild);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
keyDown: function JSTF_keyDown(aEvent)
|
keyDown: function JSTF_keyDown(aEvent)
|
||||||
{
|
{
|
||||||
var self = this;
|
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() {
|
function testCreateDisplay() {
|
||||||
ok(typeof cs.consoleDisplays == "object",
|
ok(typeof cs.consoleDisplays == "object",
|
||||||
"consoledisplays exist");
|
"consoledisplays exist");
|
||||||
|
@ -452,6 +473,7 @@ function test() {
|
||||||
testRecordManyEntries();
|
testRecordManyEntries();
|
||||||
testIteration();
|
testIteration();
|
||||||
testConsoleHistory();
|
testConsoleHistory();
|
||||||
|
testOutputOrder();
|
||||||
|
|
||||||
// testUnregister();
|
// testUnregister();
|
||||||
executeSoon(function () {
|
executeSoon(function () {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче