mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
* Bug 1557302 - Enter on a fully typed @alias should move the caret at the end. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D34908 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
fad31878d9
commit
c91a3fe44a
@ -460,13 +460,11 @@ class UrlbarInput {
|
||||
}
|
||||
case UrlbarUtils.RESULT_TYPE.SEARCH: {
|
||||
if (result.payload.isKeywordOffer) {
|
||||
if (result.autofill) {
|
||||
// The user confirmed an autofilled alias, so just move the caret
|
||||
// to the end of it. Because there's a trailing space in the value,
|
||||
// the user can directly start typing a query string at that point.
|
||||
let value = result.autofill.value;
|
||||
this.selectionStart = this.selectionEnd = value.length;
|
||||
}
|
||||
// The user confirmed a token alias, so just move the caret
|
||||
// to the end of it. Because there's a trailing space in the value,
|
||||
// the user can directly start typing a query string at that point.
|
||||
this.selectionStart = this.selectionEnd = this.value.length;
|
||||
|
||||
// Picking a keyword offer just fills it in the input and doesn't
|
||||
// visit anything. The user can then type a search string. Also
|
||||
// start a new search so that the offer appears in the view by itself
|
||||
|
@ -311,29 +311,28 @@ add_task(async function enterAndFillAlias() {
|
||||
// Pressing enter on an @ alias autofill should fill it in the urlbar input
|
||||
// with a trailing space and move the caret at the end.
|
||||
add_task(async function enterAutofillsAlias() {
|
||||
// Do a search for a partial "@" alias.
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
waitForFocus,
|
||||
value: ALIAS.substring(0, ALIAS.length - 1),
|
||||
selectionStart: ALIAS.length - 1,
|
||||
selectionEnd: ALIAS.length - 1,
|
||||
});
|
||||
let details = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
|
||||
Assert.ok(details.autofill);
|
||||
|
||||
// Press Enter.
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
await waitForAutocompleteResultAt(0);
|
||||
|
||||
// The urlbar input value should be the alias followed by a space so that it's
|
||||
// ready for the user to start typing.
|
||||
let expectedString = `${ALIAS} `;
|
||||
Assert.equal(gURLBar.textValue, expectedString);
|
||||
Assert.equal(gURLBar.selectionStart, expectedString.length);
|
||||
Assert.equal(gURLBar.selectionEnd, expectedString.length);
|
||||
await assertAlias(true);
|
||||
for (let value of [ALIAS.substring(0, ALIAS.length - 1), ALIAS]) {
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
waitForFocus,
|
||||
value,
|
||||
selectionStart: value.length,
|
||||
selectionEnd: value.length,
|
||||
});
|
||||
await waitForAutocompleteResultAt(0);
|
||||
|
||||
// Press Enter.
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
await waitForAutocompleteResultAt(0);
|
||||
|
||||
// The urlbar input value should be the alias followed by a space so that it's
|
||||
// ready for the user to start typing.
|
||||
Assert.equal(gURLBar.textValue, expectedString);
|
||||
Assert.equal(gURLBar.selectionStart, expectedString.length);
|
||||
Assert.equal(gURLBar.selectionEnd, expectedString.length);
|
||||
await assertAlias(true);
|
||||
}
|
||||
await UrlbarTestUtils.promisePopupClose(window,
|
||||
() => EventUtils.synthesizeKey("KEY_Escape"));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user