Bug 1249714 - Use jsterm.focus instead of inputNode.focus;r=linclark
MozReview-Commit-ID: 7LOW7S5rX5Y
--- a/devtools/client/debugger/test/mochitest/browser_dbg_split-console-keypress.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_split-console-keypress.js
@@ -49,17 +49,17 @@ function test() {
// Trigger script that stops at debugger statement
executeSoon(() => generateMouseClickInTab(gTab,
"content.document.getElementById('start')"));
yield waitForPause(gThreadClient);
// Focus the console and add event listener to track whether it loses focus
// (Must happen after generateMouseClickInTab() call)
let consoleLostFocus = false;
- jsterm.inputNode.focus();
+ jsterm.focus();
jsterm.inputNode.addEventListener('blur', () => {consoleLostFocus = true;});
is(gThreadClient.paused, true,
"Should be paused at debugger statement.");
// As long as we have test work to do..
for (let i = 0, thisTest; thisTest = stepTests[i]; i++) {
// First we send another key event if required by the test
while (thisTest.keyRepeat > 0) {
--- a/devtools/client/inspector/inspector-panel.js
+++ b/devtools/client/inspector/inspector-panel.js
@@ -1044,17 +1044,17 @@ InspectorPanel.prototype = {
* Show DOM properties
*/
showDOMProperties: function() {
this._toolbox.openSplitConsole().then(() => {
let panel = this._toolbox.getPanel("webconsole");
let jsterm = panel.hud.jsterm;
jsterm.execute("inspect($0)");
- jsterm.inputNode.focus();
+ jsterm.focus();
});
},
/**
* Use in Console.
*
* Takes the currently selected node in the inspector and assigns it to a
* temp variable on the content window. Also opens the split console and
--- a/devtools/client/webconsole/test/browser_console_history_persist.js
+++ b/devtools/client/webconsole/test/browser_console_history_persist.js
@@ -101,18 +101,17 @@ function* populateInputHistory(hud) {
}
/**
* Check pressing up results in history traversal like:
* [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
*/
function* testNaviatingHistoryInUI(hud) {
let jsterm = hud.jsterm;
- let {inputNode} = jsterm;
- inputNode.focus();
+ jsterm.focus();
// Count backwards from original input and make sure that pressing up
// restores this.
for (let i = INPUT_HISTORY_COUNT - 1; i >= 0; i--) {
EventUtils.synthesizeKey("VK_UP", {});
is(jsterm.getInputValue(), i, "Pressing up restores last input");
}
}
--- a/devtools/client/webconsole/test/browser_webconsole_bug_580001_closing_after_completion.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_580001_closing_after_completion.js
@@ -16,27 +16,25 @@ add_task(function* () {
let hud = yield openConsole();
yield testClosingAfterCompletion(hud, browser);
});
function testClosingAfterCompletion(hud, browser) {
let deferred = promise.defer();
- let inputNode = hud.jsterm.inputNode;
-
let errorWhileClosing = false;
function errorListener() {
errorWhileClosing = true;
}
browser.addEventListener("error", errorListener, false);
- // Focus the inputNode and perform the keycombo to close the WebConsole.
- inputNode.focus();
+ // Focus the jsterm and perform the keycombo to close the WebConsole.
+ hud.jsterm.focus();
gDevTools.once("toolbox-destroyed", function() {
browser.removeEventListener("error", errorListener, false);
is(errorWhileClosing, false, "no error while closing the WebConsole");
deferred.resolve();
});
if (Services.appinfo.OS == "Darwin") {
--- 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
@@ -20,17 +20,17 @@ add_task(function* () {
jsterm = inputNode = values = null;
});
function setup(HUD) {
jsterm = HUD.jsterm;
inputNode = jsterm.inputNode;
- inputNode.focus();
+ jsterm.focus();
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++) {
--- a/devtools/client/webconsole/test/browser_webconsole_split_escape_key.js
+++ b/devtools/client/webconsole/test/browser_webconsole_split_escape_key.js
@@ -25,17 +25,17 @@ function test() {
yield testCreateSplitConsoleAfterEscape();
yield showAutoCompletePopoup();
yield testHideAutoCompletePopupAfterEscape();
yield executeJS();
yield clickMessageAndShowVariablesView();
- jsterm.inputNode.focus();
+ jsterm.focus();
yield testHideVariablesViewAfterEscape();
yield clickMessageAndShowVariablesView();
yield startPropertyEditor();
yield testCancelPropertyEditorAfterEscape();
yield testHideVariablesViewAfterEscape();
@@ -139,17 +139,17 @@ function test() {
let deferred = promise.defer();
let popupPanel = jsterm.autocompletePopup._panel;
popupPanel.addEventListener("popupshown", function popupShown() {
popupPanel.removeEventListener("popupshown", popupShown, false);
deferred.resolve();
}, false);
- jsterm.inputNode.focus();
+ jsterm.focus();
jsterm.setInputValue("document.location.");
EventUtils.sendKey("TAB", hud.iframeWindow);
return deferred.promise;
}
function finish() {
toolbox.destroy().then(() => {
--- a/devtools/client/webconsole/webconsole.js
+++ b/devtools/client/webconsole/webconsole.js
@@ -572,29 +572,29 @@ WebConsoleFrame.prototype = {
/*
* Focus input line whenever the output area is clicked.
* Reusing _addMEssageLinkCallback since it correctly filters
* drag and select events.
*/
this._addFocusCallback(this.outputNode, (evt) => {
if ((evt.target.nodeName.toLowerCase() != "a") &&
(evt.target.parentNode.nodeName.toLowerCase() != "a")) {
- this.jsterm.inputNode.focus();
+ this.jsterm.focus();
}
});
// Toggle the timestamp on preference change
gDevTools.on("pref-changed", this._onToolboxPrefChanged);
this._onToolboxPrefChanged("pref-changed", {
pref: PREF_MESSAGE_TIMESTAMP,
newValue: Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP),
});
// focus input node
- this.jsterm.inputNode.focus();
+ this.jsterm.focus();
},
/**
* Resizes the output node to fit the output wrapped.
* We need this because it makes the layout a lot faster than
* using -moz-box-flex and 100% width. See Bug 1237368.
*/
resize: function() {
@@ -602,17 +602,17 @@ WebConsoleFrame.prototype = {
},
/**
* Sets the focus to JavaScript input field when the web console tab is
* selected or when there is a split console present.
* @private
*/
_onPanelSelected: function() {
- this.jsterm.inputNode.focus();
+ this.jsterm.focus();
},
/**
* Initialize the default filter preferences.
* @private
*/
_initDefaultFilterPrefs: function() {
let prefs = ["network", "networkinfo", "csserror", "cssparser", "csslog",
@@ -3085,19 +3085,18 @@ JSTerm.prototype = {
this.inputNode.addEventListener("focus", this._focusEventHandler, false);
}
this.hud.window.addEventListener("blur", this._blurEventHandler, false);
this.lastInputValue && this.setInputValue(this.lastInputValue);
},
focus: function() {
- let inputNode = this.inputNode;
- if (!inputNode.getAttribute("focused")) {
- inputNode.focus();
+ if (!this.inputNode.getAttribute("focused")) {
+ this.inputNode.focus();
}
},
/**
* The JavaScript evaluation response handler.
*
* @private
* @param function [callback]
@@ -3456,17 +3455,17 @@ JSTerm.prototype = {
let tag = event.target.nodeName;
if (event.keyCode != Ci.nsIDOMKeyEvent.DOM_VK_ESCAPE || event.shiftKey ||
event.altKey || event.ctrlKey || event.metaKey ||
["input", "textarea", "select", "textbox"].indexOf(tag) > -1) {
return;
}
this._sidebarDestroy();
- this.inputNode.focus();
+ this.focus();
event.stopPropagation();
},
/**
* Create a variables view instance.
*
* @private
* @param object options
@@ -3849,33 +3848,33 @@ JSTerm.prototype = {
// multiline text.
if (Services.appinfo.OS == "Darwin" &&
this.canCaretGoNext() &&
this.historyPeruse(HISTORY_FORWARD)) {
event.preventDefault();
// Ctrl-N is also used to focus the Network category button on
// MacOSX. The preventDefault() call doesn't prevent the focus
// from moving away from the input.
- inputNode.focus();
+ this.focus();
}
this.clearCompletion();
break;
case 112:
// Control-P differs from up arrow: it ignores autocomplete state.
// Note that we preserve the default 'up' navigation within
// multiline text.
if (Services.appinfo.OS == "Darwin" &&
this.canCaretGoPrevious() &&
this.historyPeruse(HISTORY_BACK)) {
event.preventDefault();
// Ctrl-P may also be used to focus some category button on MacOSX.
// The preventDefault() call doesn't prevent the focus from moving
// away from the input.
- inputNode.focus();
+ this.focus();
}
this.clearCompletion();
break;
default:
break;
}
return;
} else if (event.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_RETURN) {