Bug 1240196 - Replace instances of console jsterm inputNode.value with a getInputValue function;r=linclark

--HG--
extra : commitid : FWPV5hCdMuC
This commit is contained in:
Brian Grinstead 2016-01-20 14:42:36 -08:00
parent a3b5261a21
commit dc4568effd
9 changed files with 114 additions and 101 deletions

View File

@ -113,6 +113,6 @@ function* testNaviatingHistoryInUI(hud) {
// restores this.
for (let i = INPUT_HISTORY_COUNT - 1; i >= 0; i--) {
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, i, "Pressing up restores last input");
is(jsterm.getInputValue(), i, "Pressing up restores last input");
}
}

View File

@ -71,23 +71,23 @@ function consoleOpened(HUD) {
WebConsoleUtils.usageCount = 0;
updateEditUIVisibility();
let oldVal = jsterm.inputNode.value;
let oldVal = jsterm.getInputValue();
goDoCommand("cmd_paste");
let notificationbox = jsterm.hud.document.getElementById("webconsole-notificationbox");
let notification = notificationbox.getNotificationWithValue("selfxss-notification");
ok(notification, "Self-xss notification shown");
is(oldVal, jsterm.inputNode.value, "Paste blocked by self-xss prevention");
is(oldVal, jsterm.getInputValue(), "Paste blocked by self-xss prevention");
// Allow pasting
jsterm.inputNode.value = "allow pasting";
jsterm.setInputValue("allow pasting");
let evt = document.createEvent("KeyboardEvent");
evt.initKeyEvent("keyup", true, true, window,
0, 0, 0, 0,
0, " ".charCodeAt(0));
jsterm.inputNode.dispatchEvent(evt);
jsterm.inputNode.value = "";
jsterm.setInputValue("");
goDoCommand("cmd_paste");
isnot("", jsterm.inputNode.value, "Paste works");
isnot("", jsterm.getInputValue(), "Paste works");
}
function onClipboardPaste() {
ok(!jsterm.completeNode.value, "no completion value after paste");

View File

@ -88,7 +88,7 @@ var consoleOpened = Task.async(function*(aHud) {
"Index of the first item from bottom is selected.");
EventUtils.synthesizeKey("VK_DOWN", {});
let prefix = jsterm.inputNode.value.replace(/[\S]/g, " ");
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
is(popup.selectedIndex, 0, "index 0 is selected");
is(popup.selectedItem.label, "watch", "watch is selected");
@ -149,7 +149,7 @@ function popupHideAfterTab() {
// At this point the completion suggestion should be accepted.
ok(!popup.isOpen, "popup is not open");
is(inputNode.value, "window.foobarBug585991.watch",
is(jsterm.getInputValue(), "window.foobarBug585991.watch",
"completion was successful after VK_TAB");
ok(!completeNode.value, "completeNode is empty");
@ -164,7 +164,7 @@ function popupHideAfterTab() {
is(popup.selectedIndex, 18, "First index from bottom is selected");
EventUtils.synthesizeKey("VK_DOWN", {});
let prefix = jsterm.inputNode.value.replace(/[\S]/g, " ");
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
is(popup.selectedIndex, 0, "index 0 is selected");
is(popup.selectedItem.label, "watch", "watch is selected");
@ -176,7 +176,7 @@ function popupHideAfterTab() {
ok(!popup.isOpen, "popup is not open after VK_ESCAPE");
is(inputNode.value, "window.foobarBug585991.",
is(jsterm.getInputValue(), "window.foobarBug585991.",
"completion was cancelled");
ok(!completeNode.value, "completeNode is empty");
@ -212,7 +212,7 @@ function testReturnKey() {
is(popup.selectedIndex, 18, "First index from bottom is selected");
EventUtils.synthesizeKey("VK_DOWN", {});
let prefix = jsterm.inputNode.value.replace(/[\S]/g, " ");
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
is(popup.selectedIndex, 0, "index 0 is selected");
is(popup.selectedItem.label, "watch", "watch is selected");
@ -231,7 +231,7 @@ function testReturnKey() {
ok(!popup.isOpen, "popup is not open after VK_RETURN");
is(inputNode.value, "window.foobarBug585991.valueOf",
is(jsterm.getInputValue(), "window.foobarBug585991.valueOf",
"completion was successful after VK_RETURN");
ok(!completeNode.value, "completeNode is empty");
@ -324,7 +324,7 @@ function testReturnWithNoSelection() {
function popupHideAfterReturnWithNoSelection() {
ok(!popup.isOpen, "popup is not open after VK_RETURN");
is(inputNode.value, "", "inputNode is empty after VK_RETURN");
is(jsterm.getInputValue(), "", "inputNode is empty after VK_RETURN");
is(completeNode.value, "", "completeNode is empty");
is(jsterm.history[jsterm.history.length - 1], "window.testBug",
"jsterm history is correct");
@ -369,7 +369,7 @@ function testCompletionInText() {
function popupHideAfterCompletionInText() {
// At this point the completion suggestion should be accepted.
ok(!popup.isOpen, "popup is not open");
is(inputNode.value, "dump(window.testBug873250b)",
is(jsterm.getInputValue(), "dump(window.testBug873250b)",
"completion was successful after VK_TAB");
is(inputNode.selectionStart, 26, "cursor location is correct");
is(inputNode.selectionStart, inputNode.selectionEnd,

View File

@ -10,7 +10,7 @@
"use strict";
var inputNode, values;
var jsterm, inputNode, values;
var TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
"bug 594497 and bug 619598";
@ -23,31 +23,33 @@ add_task(function* () {
setup(hud);
performTests();
inputNode = values = null;
jsterm = inputNode = values = null;
});
function setup(HUD) {
inputNode = HUD.jsterm.inputNode;
jsterm = HUD.jsterm;
inputNode = jsterm.inputNode;
inputNode.focus();
ok(!inputNode.value, "inputNode.value is empty");
ok(!jsterm.getInputValue(), "jsterm.getInputValue() is empty");
values = ["document", "window", "document.body"];
values.push(values.join(";\n"), "document.location");
// Execute each of the values;
for (let i = 0; i < values.length; i++) {
HUD.jsterm.setInputValue(values[i]);
HUD.jsterm.execute();
jsterm.setInputValue(values[i]);
jsterm.execute();
}
}
function performTests() {
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, values[4],
"VK_UP: inputNode.value #4 is correct");
is(jsterm.getInputValue(), values[4],
"VK_UP: jsterm.getInputValue() #4 is correct");
ok(inputNode.selectionStart == values[4].length &&
inputNode.selectionStart == inputNode.selectionEnd,
@ -55,8 +57,8 @@ function performTests() {
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, values[3],
"VK_UP: inputNode.value #3 is correct");
is(jsterm.getInputValue(), values[3],
"VK_UP: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == values[3].length &&
inputNode.selectionStart == inputNode.selectionEnd,
@ -67,17 +69,17 @@ function performTests() {
EventUtils.synthesizeKey("VK_UP", {});
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, values[3],
"VK_UP two times: inputNode.value #3 is correct");
is(jsterm.getInputValue(), values[3],
"VK_UP two times: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == inputNode.value.indexOf("\n") &&
ok(inputNode.selectionStart == jsterm.getInputValue().indexOf("\n") &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, values[3],
"VK_UP again: inputNode.value #3 is correct");
is(jsterm.getInputValue(), values[3],
"VK_UP again: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == 0 &&
inputNode.selectionStart == inputNode.selectionEnd,
@ -85,18 +87,18 @@ function performTests() {
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, values[2],
"VK_UP: inputNode.value #2 is correct");
is(jsterm.getInputValue(), values[2],
"VK_UP: jsterm.getInputValue() #2 is correct");
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, values[1],
"VK_UP: inputNode.value #1 is correct");
is(jsterm.getInputValue(), values[1],
"VK_UP: jsterm.getInputValue() #1 is correct");
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, values[0],
"VK_UP: inputNode.value #0 is correct");
is(jsterm.getInputValue(), values[0],
"VK_UP: jsterm.getInputValue() #0 is correct");
ok(inputNode.selectionStart == values[0].length &&
inputNode.selectionStart == inputNode.selectionEnd,
@ -104,8 +106,8 @@ function performTests() {
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value, values[1],
"VK_DOWN: inputNode.value #1 is correct");
is(jsterm.getInputValue(), values[1],
"VK_DOWN: jsterm.getInputValue() #1 is correct");
ok(inputNode.selectionStart == values[1].length &&
inputNode.selectionStart == inputNode.selectionEnd,
@ -113,13 +115,13 @@ function performTests() {
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value, values[2],
"VK_DOWN: inputNode.value #2 is correct");
is(jsterm.getInputValue(), values[2],
"VK_DOWN: jsterm.getInputValue() #2 is correct");
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value, values[3],
"VK_DOWN: inputNode.value #3 is correct");
is(jsterm.getInputValue(), values[3],
"VK_DOWN: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == values[3].length &&
inputNode.selectionStart == inputNode.selectionEnd,
@ -130,17 +132,17 @@ function performTests() {
EventUtils.synthesizeKey("VK_DOWN", {});
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value, values[3],
"VK_DOWN two times: inputNode.value #3 is correct");
is(jsterm.getInputValue(), values[3],
"VK_DOWN two times: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart > inputNode.value.lastIndexOf("\n") &&
ok(inputNode.selectionStart > jsterm.getInputValue().lastIndexOf("\n") &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value, values[3],
"VK_DOWN again: inputNode.value #3 is correct");
is(jsterm.getInputValue(), values[3],
"VK_DOWN again: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == values[3].length &&
inputNode.selectionStart == inputNode.selectionEnd,
@ -148,11 +150,11 @@ function performTests() {
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value, values[4],
"VK_DOWN: inputNode.value #4 is correct");
is(jsterm.getInputValue(), values[4],
"VK_DOWN: jsterm.getInputValue() #4 is correct");
EventUtils.synthesizeKey("VK_DOWN", {});
ok(!inputNode.value,
"VK_DOWN: inputNode.value is empty");
ok(!jsterm.getInputValue(),
"VK_DOWN: jsterm.getInputValue() is empty");
}

View File

@ -20,7 +20,7 @@ add_task(function* () {
// Test select all with Control + A.
EventUtils.synthesizeKey("a", { ctrlKey: true });
let inputLength = inputNode.selectionEnd - inputNode.selectionStart;
is(inputLength, inputNode.value.length, "Select all of input");
is(inputLength, jsterm.getInputValue().length, "Select all of input");
// Test do nothing on Control + E.
jsterm.setInputValue("Ignore These Four Words");

View File

@ -31,7 +31,7 @@ add_task(function* () {
function doTests(HUD) {
jsterm = HUD.jsterm;
inputNode = jsterm.inputNode;
ok(!jsterm.inputNode.value, "inputNode.value is empty");
ok(!jsterm.getInputValue(), "jsterm.getInputValue() is empty");
is(jsterm.inputNode.selectionStart, 0);
is(jsterm.inputNode.selectionEnd, 0);
@ -96,10 +96,10 @@ function testMultiLineInputNavNoHistory() {
jsterm.setInputValue("");
// simulate shift-return
for (let i = 0; i < lineValues.length; i++) {
jsterm.setInputValue(inputNode.value + lineValues[i]);
jsterm.setInputValue(jsterm.getInputValue() + lineValues[i]);
EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true });
}
let inputValue = inputNode.value;
let inputValue = jsterm.getInputValue();
is(inputNode.selectionStart, inputNode.selectionEnd);
is(inputNode.selectionStart, inputValue.length,
"caret at end of multiline input");
@ -111,36 +111,36 @@ function testMultiLineInputNavNoHistory() {
// Ok, test navigating within the multi-line string!
EventUtils.synthesizeKey("VK_UP", {});
let expectedStringAfterCarat = lineValues[5] + newlineString;
is(inputNode.value.slice(inputNode.selectionStart), expectedStringAfterCarat,
is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat,
"up arrow from end of multiline");
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value.slice(inputNode.selectionStart), "",
is(jsterm.getInputValue().slice(inputNode.selectionStart), "",
"down arrow from within multiline");
// navigate up through input lines
EventUtils.synthesizeKey("p", { ctrlKey: true });
is(inputNode.value.slice(inputNode.selectionStart), expectedStringAfterCarat,
is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat,
"ctrl-p from end of multiline");
for (let i = 4; i >= 0; i--) {
EventUtils.synthesizeKey("p", { ctrlKey: true });
expectedStringAfterCarat = lineValues[i] + newlineString +
expectedStringAfterCarat;
is(inputNode.value.slice(inputNode.selectionStart),
is(jsterm.getInputValue().slice(inputNode.selectionStart),
expectedStringAfterCarat, "ctrl-p from within line " + i +
" of multiline input");
}
EventUtils.synthesizeKey("p", { ctrlKey: true });
is(inputNode.selectionStart, 0, "reached start of input");
is(inputNode.value, inputValue,
is(jsterm.getInputValue(), inputValue,
"no change to multiline input on ctrl-p from beginning of multiline");
// navigate to end of first line
EventUtils.synthesizeKey("e", { ctrlKey: true });
let caretPos = inputNode.selectionStart;
let expectedStringBeforeCarat = lineValues[0];
is(inputNode.value.slice(0, caretPos), expectedStringBeforeCarat,
is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat,
"ctrl-e into multiline input");
EventUtils.synthesizeKey("e", { ctrlKey: true });
is(inputNode.selectionStart, caretPos,
@ -152,13 +152,13 @@ function testMultiLineInputNavNoHistory() {
EventUtils.synthesizeKey("a", { ctrlKey: true });
caretPos = inputNode.selectionStart;
expectedStringBeforeCarat += newlineString;
is(inputNode.value.slice(0, caretPos), expectedStringBeforeCarat,
is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat,
"ctrl-a to beginning of line " + (i + 1) + " in multiline input");
EventUtils.synthesizeKey("e", { ctrlKey: true });
caretPos = inputNode.selectionStart;
expectedStringBeforeCarat += lineValues[i];
is(inputNode.value.slice(0, caretPos), expectedStringBeforeCarat,
is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat,
"ctrl-e to end of line " + (i + 1) + "in multiline input");
}
}
@ -195,27 +195,27 @@ function testNavWithHistory() {
// single-line inputs will update from history from end of line
EventUtils.synthesizeKey("p", { ctrlKey: true });
}
is(inputNode.value, values[i - 1],
is(jsterm.getInputValue(), values[i - 1],
"ctrl-p updates inputNode from backwards history values[" + i - 1 + "]");
}
let inputValue = inputNode.value;
let inputValue = jsterm.getInputValue();
EventUtils.synthesizeKey("p", { ctrlKey: true });
is(inputNode.selectionStart, 0,
"ctrl-p at beginning of history moves caret location to beginning " +
"of line");
is(inputNode.value, inputValue,
is(jsterm.getInputValue(), inputValue,
"no change to input value on ctrl-p from beginning of line");
// Navigate forwards history with ctrl-n
for (let i = 1; i < values.length; i++) {
EventUtils.synthesizeKey("n", { ctrlKey: true });
is(inputNode.value, values[i],
is(jsterm.getInputValue(), values[i],
"ctrl-n updates inputNode from forwards history values[" + i + "]");
is(inputNode.selectionStart, values[i].length,
"caret location correct at end of history input for values[" + i + "]");
}
EventUtils.synthesizeKey("n", { ctrlKey: true });
ok(!inputNode.value, "ctrl-n at end of history updates to empty input");
ok(!jsterm.getInputValue(), "ctrl-n at end of history updates to empty input");
// Simulate editing multi-line
inputValue = "one\nlinebreak";
@ -223,11 +223,11 @@ function testNavWithHistory() {
// Attempt nav within input
EventUtils.synthesizeKey("p", { ctrlKey: true });
is(inputNode.value, inputValue,
is(jsterm.getInputValue(), inputValue,
"ctrl-p from end of multi-line does not trigger history");
EventUtils.synthesizeKey("a", { ctrlKey: true });
EventUtils.synthesizeKey("p", { ctrlKey: true });
is(inputNode.value, values[values.length - 1],
is(jsterm.getInputValue(), values[values.length - 1],
"ctrl-p from start of multi-line triggers history");
}

View File

@ -28,36 +28,36 @@ add_task(function* () {
function testEditedInputHistory(HUD) {
let jsterm = HUD.jsterm;
let inputNode = jsterm.inputNode;
ok(!inputNode.value, "inputNode.value is empty");
ok(!jsterm.getInputValue(), "jsterm.getInputValue() is empty");
is(inputNode.selectionStart, 0);
is(inputNode.selectionEnd, 0);
jsterm.setInputValue('"first item"');
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, '"first item"', "null test history up");
is(jsterm.getInputValue(), '"first item"', "null test history up");
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value, '"first item"', "null test history down");
is(jsterm.getInputValue(), '"first item"', "null test history down");
jsterm.execute();
is(inputNode.value, "", "cleared input line after submit");
is(jsterm.getInputValue(), "", "cleared input line after submit");
jsterm.setInputValue('"editing input 1"');
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, '"first item"', "test history up");
is(jsterm.getInputValue(), '"first item"', "test history up");
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value, '"editing input 1"',
is(jsterm.getInputValue(), '"editing input 1"',
"test history down restores in-progress input");
jsterm.setInputValue('"second item"');
jsterm.execute();
jsterm.setInputValue('"editing input 2"');
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, '"second item"', "test history up");
is(jsterm.getInputValue(), '"second item"', "test history up");
EventUtils.synthesizeKey("VK_UP", {});
is(inputNode.value, '"first item"', "test history up");
is(jsterm.getInputValue(), '"first item"', "test history up");
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value, '"second item"', "test history down");
is(jsterm.getInputValue(), '"second item"', "test history down");
EventUtils.synthesizeKey("VK_DOWN", {});
is(inputNode.value, '"editing input 2"',
is(jsterm.getInputValue(), '"editing input 2"',
"test history down restores new in-progress input again");
}

View File

@ -57,7 +57,7 @@ add_task(function*() {
info("Waiting for input to be set");
yield onceInputSet;
is(hud.jsterm.inputNode.value, "temp0", "Input was set");
is(hud.jsterm.getInputValue(), "temp0", "Input was set");
let executedResult = yield hud.jsterm.execute();
ok(executedResult.textContent.includes("{ baz: 1 }"),

View File

@ -3252,7 +3252,7 @@ JSTerm.prototype = {
*
* @param string [executeString]
* The string you want to execute. If this is not provided, the current
* user input is used - taken from |this.inputNode.value|.
* user input is used - taken from |this.getInputValue()|.
* @param function [callback]
* Optional function to invoke when the result is displayed.
* This is deprecated - please use the promise return value instead.
@ -3270,7 +3270,7 @@ JSTerm.prototype = {
}
// attempt to execute the content of the inputNode
executeString = executeString || this.inputNode.value;
executeString = executeString || this.getInputValue();
if (!executeString) {
return;
}
@ -3863,16 +3863,25 @@ JSTerm.prototype = {
this.emit("set-input-value");
},
/**
* Gets the value from the input field
* @returns string
*/
getInputValue: function()
{
return this.inputNode.value || "";
},
/**
* The inputNode "input" and "keyup" event handler.
* @private
*/
_inputEventHandler: function JST__inputEventHandler()
{
if (this.lastInputValue != this.inputNode.value) {
if (this.lastInputValue != this.getInputValue()) {
this.resizeInput();
this.complete(this.COMPLETE_HINT_ONLY);
this.lastInputValue = this.inputNode.value;
this.lastInputValue = this.getInputValue();
this._inputChanged = true;
}
},
@ -3897,6 +3906,7 @@ JSTerm.prototype = {
_keyPress: function JST__keyPress(event)
{
let inputNode = this.inputNode;
let inputValue = this.getInputValue();
let inputUpdated = false;
if (event.ctrlKey) {
@ -3906,12 +3916,12 @@ JSTerm.prototype = {
if (Services.appinfo.OS == "WINNT") {
break;
}
let lineEndPos = inputNode.value.length;
let lineEndPos = inputValue.length;
if (this.hasMultilineInput()) {
// find index of closest newline >= cursor
for (let i = inputNode.selectionEnd; i<lineEndPos; i++) {
if (inputNode.value.charAt(i) == "\r" ||
inputNode.value.charAt(i) == "\n") {
if (inputValue.charAt(i) == "\r" ||
inputValue.charAt(i) == "\n") {
lineEndPos = i;
break;
}
@ -4060,7 +4070,7 @@ JSTerm.prototype = {
if (this.autocompletePopup.isOpen) {
this.autocompletePopup.selectedIndex = 0;
event.preventDefault();
} else if (this.inputNode.value.length <= 0) {
} else if (inputValue.length <= 0) {
this.hud.outputNode.parentNode.scrollTop = 0;
event.preventDefault();
}
@ -4070,7 +4080,7 @@ JSTerm.prototype = {
if (this.autocompletePopup.isOpen) {
this.autocompletePopup.selectedIndex = this.autocompletePopup.itemCount - 1;
event.preventDefault();
} else if (this.inputNode.value.length <= 0) {
} else if (inputValue.length <= 0) {
this.hud.outputNode.parentNode.scrollTop = this.hud.outputNode.parentNode.scrollHeight;
event.preventDefault();
}
@ -4086,7 +4096,7 @@ JSTerm.prototype = {
let cursorAtTheEnd = this.inputNode.selectionStart ==
this.inputNode.selectionEnd &&
this.inputNode.selectionStart ==
this.inputNode.value.length;
inputValue.length;
let haveSuggestion = this.autocompletePopup.isOpen ||
this.lastCompletion.value;
let useCompletion = cursorAtTheEnd || this._autocompletePopupNavigated;
@ -4154,7 +4164,7 @@ JSTerm.prototype = {
// Note: this code does not store changes to items that are already in
// history.
if (this.historyPlaceHolder+1 == this.historyIndex) {
this.history[this.historyIndex] = this.inputNode.value || "";
this.history[this.historyIndex] = this.getInputValue() || "";
}
this.setInputValue(inputVal);
@ -4183,7 +4193,7 @@ JSTerm.prototype = {
*/
hasMultilineInput: function JST_hasMultilineInput()
{
return /[\r\n]/.test(this.inputNode.value);
return /[\r\n]/.test(this.getInputValue());
},
/**
@ -4253,7 +4263,7 @@ JSTerm.prototype = {
* completion and the input value stayed the same compared to the
* last time this function was called, then the same completion is
* used again. If there is only one possible completion, then
* the inputNode.value is set to this value and the selection is set
* the this.getInputValue() is set to this value and the selection is set
* from the current cursor position to the end of the completed text.
* @param function callback
* Optional function invoked when the autocomplete properties are
@ -4264,7 +4274,7 @@ JSTerm.prototype = {
complete: function JSTF_complete(type, callback)
{
let inputNode = this.inputNode;
let inputValue = inputNode.value;
let inputValue = this.getInputValue();
let frameActor = this.getFrameActor(this.SELECTED_FRAME);
// If the inputNode has no value, then don't try to complete on it.
@ -4328,13 +4338,14 @@ JSTerm.prototype = {
function JST__updateCompletionResult(type, callback)
{
let frameActor = this.getFrameActor(this.SELECTED_FRAME);
if (this.lastCompletion.value == this.inputNode.value && frameActor == this._lastFrameActorId) {
if (this.lastCompletion.value == this.getInputValue() &&
frameActor == this._lastFrameActorId) {
return;
}
let requestId = gSequenceId();
let cursor = this.inputNode.selectionStart;
let input = this.inputNode.value.substring(0, cursor);
let input = this.getInputValue().substring(0, cursor);
let cache = this._autocompleteCache;
// If the current input starts with the previous input, then we already
@ -4404,7 +4415,7 @@ JSTerm.prototype = {
function JST__receiveAutocompleteProperties(requestId, callback, message)
{
let inputNode = this.inputNode;
let inputValue = inputNode.value;
let inputValue = this.getInputValue();
if (this.lastCompletion.value == inputValue ||
requestId != this.lastCompletion.requestId) {
return;
@ -4441,7 +4452,7 @@ JSTerm.prototype = {
};
if (items.length > 1 && !popup.isOpen) {
let str = this.inputNode.value.substr(0, this.inputNode.selectionStart);
let str = this.getInputValue().substr(0, this.inputNode.selectionStart);
let offset = str.length - (str.lastIndexOf("\n") + 1) - lastPart.length;
let x = offset * this.hud._inputCharWidth;
popup.openPopup(inputNode, x + this.hud._chevronWidth);
@ -4475,7 +4486,7 @@ JSTerm.prototype = {
onAutocompleteSelect: function JSTF_onAutocompleteSelect()
{
// Render the suggestion only if the cursor is at the end of the input.
if (this.inputNode.selectionStart != this.inputNode.value.length) {
if (this.inputNode.selectionStart != this.getInputValue().length) {
return;
}
@ -4521,7 +4532,7 @@ JSTerm.prototype = {
let suffix = currentItem.label.substring(this.lastCompletion.
matchProp.length);
let cursor = this.inputNode.selectionStart;
let value = this.inputNode.value;
let value = this.getInputValue();
this.setInputValue(value.substr(0, cursor) + suffix + value.substr(cursor));
let newCursor = cursor + suffix.length;
this.inputNode.selectionStart = this.inputNode.selectionEnd = newCursor;
@ -4542,7 +4553,7 @@ JSTerm.prototype = {
updateCompleteNode: function JSTF_updateCompleteNode(suffix)
{
// completion prefix = input, with non-control chars replaced by spaces
let prefix = suffix ? this.inputNode.value.replace(/[\S]/g, " ") : "";
let prefix = suffix ? this.getInputValue().replace(/[\S]/g, " ") : "";
this.completeNode.value = prefix + suffix;
},