diff --git a/devtools/client/webconsole/test/browser_console_history_persist.js b/devtools/client/webconsole/test/browser_console_history_persist.js index a6eccd9a1c84..d196b4b7f694 100644 --- a/devtools/client/webconsole/test/browser_console_history_persist.js +++ b/devtools/client/webconsole/test/browser_console_history_persist.js @@ -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"); } } diff --git a/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js b/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js index d1c4c1bb98fe..de2d04db7913 100644 --- a/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js +++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js @@ -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"); diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js b/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js index 58340a94f34f..b79f1dad0171 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js @@ -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, diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_594497_history_arrow_keys.js b/devtools/client/webconsole/test/browser_webconsole_bug_594497_history_arrow_keys.js index 749004ca884d..afed473fe380 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_594497_history_arrow_keys.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_594497_history_arrow_keys.js @@ -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"); } diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_623749_ctrl_a_select_all_winnt.js b/devtools/client/webconsole/test/browser_webconsole_bug_623749_ctrl_a_select_all_winnt.js index 5ddc43653125..0c607e660bc1 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_623749_ctrl_a_select_all_winnt.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_623749_ctrl_a_select_all_winnt.js @@ -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"); diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_804845_ctrl_key_nav.js b/devtools/client/webconsole/test/browser_webconsole_bug_804845_ctrl_key_nav.js index 2b505c9bf6c9..e34b42daa410 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_804845_ctrl_key_nav.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_804845_ctrl_key_nav.js @@ -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"); } diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_817834_add_edited_input_to_history.js b/devtools/client/webconsole/test/browser_webconsole_bug_817834_add_edited_input_to_history.js index c3288461384f..1b45621ed3f7 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_817834_add_edited_input_to_history.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_817834_add_edited_input_to_history.js @@ -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"); } diff --git a/devtools/client/webconsole/test/browser_webconsole_context_menu_store_as_global.js b/devtools/client/webconsole/test/browser_webconsole_context_menu_store_as_global.js index eaaf9a8fe66f..4cac45d1e40d 100644 --- a/devtools/client/webconsole/test/browser_webconsole_context_menu_store_as_global.js +++ b/devtools/client/webconsole/test/browser_webconsole_context_menu_store_as_global.js @@ -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 }"), diff --git a/devtools/client/webconsole/webconsole.js b/devtools/client/webconsole/webconsole.js index b3ddc3094add..999baaa9a703 100644 --- a/devtools/client/webconsole/webconsole.js +++ b/devtools/client/webconsole/webconsole.js @@ -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 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; },