зеркало из https://github.com/mozilla/pjs.git
Bug 583816 - Tab should move to the page when there's nothing to complete in the Web Console r=sdwilsh a=dietrich
This commit is contained in:
Родитель
161fca6c35
Коммит
b7ac4108ef
|
@ -4286,20 +4286,19 @@ JSTerm.prototype = {
|
|||
// If there are more than one possible completion, pressing tab
|
||||
// means taking the next completion, shift_tab means taking
|
||||
// the previous completion.
|
||||
var completionResult;
|
||||
if (aEvent.shiftKey) {
|
||||
self.complete(self.COMPLETE_BACKWARD);
|
||||
completionResult = self.complete(self.COMPLETE_BACKWARD);
|
||||
}
|
||||
else {
|
||||
self.complete(self.COMPLETE_FORWARD);
|
||||
completionResult = self.complete(self.COMPLETE_FORWARD);
|
||||
}
|
||||
var bool = aEvent.cancelable;
|
||||
if (bool) {
|
||||
if (completionResult) {
|
||||
if (aEvent.cancelable) {
|
||||
aEvent.preventDefault();
|
||||
}
|
||||
else {
|
||||
// noop
|
||||
}
|
||||
aEvent.target.focus();
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
// backspace key
|
||||
|
@ -4410,7 +4409,8 @@ JSTerm.prototype = {
|
|||
* the inputNode.value is set to this value and the selection is set
|
||||
* from the current cursor position to the end of the completed text.
|
||||
*
|
||||
* @returns void
|
||||
* @returns boolean true if there existed a completion for the current input,
|
||||
* or false otherwise.
|
||||
*/
|
||||
complete: function JSTF_complete(type)
|
||||
{
|
||||
|
@ -4418,7 +4418,7 @@ JSTerm.prototype = {
|
|||
let inputValue = inputNode.value;
|
||||
// If the inputNode has no value, then don't try to complete on it.
|
||||
if (!inputValue) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
let selStart = inputNode.selectionStart, selEnd = inputNode.selectionEnd;
|
||||
|
||||
|
@ -4432,7 +4432,7 @@ JSTerm.prototype = {
|
|||
// Only complete if the selection is at the end of the input.
|
||||
if (selEnd != inputValue.length) {
|
||||
this.lastCompletion = null;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove the selected text from the inputValue.
|
||||
|
@ -4460,7 +4460,7 @@ JSTerm.prototype = {
|
|||
// Look up possible completion values.
|
||||
let completion = this.propertyProvider(this.sandbox.window, inputValue);
|
||||
if (!completion) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
matches = completion.matches;
|
||||
matchIndexToUse = 0;
|
||||
|
@ -4500,7 +4500,11 @@ JSTerm.prototype = {
|
|||
else {
|
||||
inputNode.setSelectionRange(selEnd, selEnd);
|
||||
}
|
||||
|
||||
return completionStr ? true : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ _BROWSER_TEST_FILES = \
|
|||
browser_webconsole_bug_582201_duplicate_errors.js \
|
||||
browser_webconsole_bug_580454_timestamp_l10n.js \
|
||||
browser_webconsole_netlogging.js \
|
||||
browser_webconsole_bug_583816_tab_focus.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mihai Șucan <mihai.sucan@gmail.com>
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console.html";
|
||||
|
||||
let inputNode;
|
||||
|
||||
function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
waitForFocus(function() {
|
||||
openConsole();
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
HUD = HUDService.hudWeakReferences[hudId].get();
|
||||
|
||||
let display = HUDService.getOutputNodeById(hudId);
|
||||
inputNode = display.querySelector(".jsterm-input-node");
|
||||
|
||||
inputNode.focus();
|
||||
executeSoon(function() {
|
||||
is(inputNode.getAttribute("focused"), "true", "inputNode is focused");
|
||||
HUD.jsterm.setInputValue("doc");
|
||||
inputNode.addEventListener("keyup", firstTab, false);
|
||||
EventUtils.synthesizeKey("VK_TAB", {});
|
||||
});
|
||||
}, content);
|
||||
}
|
||||
|
||||
function firstTab(aEvent) {
|
||||
this.removeEventListener(aEvent.type, arguments.callee, false);
|
||||
|
||||
is(inputNode.getAttribute("focused"), "true", "inputNode is still focused");
|
||||
isnot(this.value, "doc", "input autocompleted");
|
||||
|
||||
HUD.jsterm.setInputValue("foobarbaz" + Date.now());
|
||||
|
||||
EventUtils.synthesizeKey("VK_TAB", {});
|
||||
|
||||
executeSoon(secondTab);
|
||||
}
|
||||
|
||||
function secondTab() {
|
||||
isnot(inputNode.getAttribute("focused"), "true",
|
||||
"inputNode is no longer focused");
|
||||
|
||||
HUD = inputNode = null;
|
||||
HUDService.deactivateHUDForContext(gBrowser.selectedTab);
|
||||
executeSoon(finish);
|
||||
}
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", tabLoad, true);
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче