зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1557324 - Fix JSTerm keyboard navigation in old input. r=Honza.
Hitting Ctrl+ArrowRight didn't have any effect on windows/linux. The patch fixes this and add a test to make sure a user can navigate from word to word using Ctrl (or Alt on OSX) and Arrow Left/Right keys. Differential Revision: https://phabricator.services.mozilla.com/D34312 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5b709c20cd
Коммит
37c48f52e6
|
@ -947,7 +947,6 @@ class JSTerm extends Component {
|
|||
event.preventDefault();
|
||||
}
|
||||
this.clearCompletion();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// control-enter should execute the current input if codeMirror
|
||||
|
|
|
@ -19,17 +19,18 @@ const TEST_URI = `data:text/html;charset=utf-8,<head><script>
|
|||
add_task(async function() {
|
||||
// Run test with legacy JsTerm
|
||||
await pushPref("devtools.webconsole.jsterm.codeMirror", false);
|
||||
await performTests();
|
||||
await performTests(true);
|
||||
// And then run it with the CodeMirror-powered one.
|
||||
await pushPref("devtools.webconsole.jsterm.codeMirror", true);
|
||||
await performTests();
|
||||
});
|
||||
|
||||
async function performTests() {
|
||||
async function performTests(oldJsterm) {
|
||||
const hud = await openNewTabAndConsole(TEST_URI);
|
||||
const { jsterm } = hud;
|
||||
const { autocompletePopup: popup } = jsterm;
|
||||
|
||||
await checkWordNavigation(hud, oldJsterm);
|
||||
await checkArrowLeftDismissPopup(hud);
|
||||
await checkArrowLeftDismissCompletion(hud);
|
||||
await checkArrowRightAcceptCompletion(hud);
|
||||
|
@ -179,3 +180,51 @@ async function checkArrowRightAcceptCompletion(hud) {
|
|||
}
|
||||
setInputValue(hud, "");
|
||||
}
|
||||
|
||||
async function checkWordNavigation(hud, oldJsterm) {
|
||||
const accelKey = Services.appinfo.OS == "Darwin"
|
||||
? "altKey"
|
||||
: "ctrlKey";
|
||||
const goLeft = () => EventUtils.synthesizeKey("KEY_ArrowLeft", {[accelKey]: true});
|
||||
const goRight = () => EventUtils.synthesizeKey("KEY_ArrowRight", {[accelKey]: true});
|
||||
const isWindowsAndOldJsTerm = Services.appinfo.OS == "WINNT" && oldJsterm;
|
||||
|
||||
setInputValue(hud, "aa bb cc dd");
|
||||
checkInputValueAndCursorPosition(hud, "aa bb cc dd|");
|
||||
|
||||
goRight();
|
||||
checkInputValueAndCursorPosition(hud, "aa bb cc dd|");
|
||||
|
||||
goLeft();
|
||||
checkInputValueAndCursorPosition(hud, "aa bb cc |dd");
|
||||
|
||||
goLeft();
|
||||
checkInputValueAndCursorPosition(hud, "aa bb |cc dd");
|
||||
|
||||
goLeft();
|
||||
checkInputValueAndCursorPosition(hud, "aa |bb cc dd");
|
||||
|
||||
goLeft();
|
||||
checkInputValueAndCursorPosition(hud, "|aa bb cc dd");
|
||||
|
||||
goLeft();
|
||||
checkInputValueAndCursorPosition(hud, "|aa bb cc dd");
|
||||
|
||||
goRight();
|
||||
// Windows differ from other platforms, going to the start of the next string.
|
||||
let expectedInput = isWindowsAndOldJsTerm ? "aa |bb cc dd" : "aa| bb cc dd";
|
||||
checkInputValueAndCursorPosition(hud, expectedInput);
|
||||
|
||||
goRight();
|
||||
expectedInput = isWindowsAndOldJsTerm ? "aa bb |cc dd" : "aa bb| cc dd";
|
||||
checkInputValueAndCursorPosition(hud, expectedInput);
|
||||
|
||||
goRight();
|
||||
expectedInput = isWindowsAndOldJsTerm ? "aa bb cc |dd" : "aa bb cc| dd";
|
||||
checkInputValueAndCursorPosition(hud, expectedInput);
|
||||
|
||||
goRight();
|
||||
checkInputValueAndCursorPosition(hud, "aa bb cc dd|");
|
||||
|
||||
setInputValue(hud, "");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче