mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1617408 - Show top sites when the user clears the URL bar input. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D64053 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
7a072c5114
commit
5d3acf0d14
@ -1923,10 +1923,10 @@ class UrlbarInput {
|
||||
}
|
||||
this.removeAttribute("actiontype");
|
||||
|
||||
if (!this.view.isOpen || !value) {
|
||||
if (!this.view.isOpen) {
|
||||
this.view.clear();
|
||||
} else if (!value && !this.openViewOnFocus) {
|
||||
this.view.clear();
|
||||
}
|
||||
if (this.view.isOpen && !value) {
|
||||
this.view.close();
|
||||
return;
|
||||
}
|
||||
|
@ -18,10 +18,7 @@ add_task(async function test() {
|
||||
await promiseAutocompleteResultPopup("x", window, true);
|
||||
await checkResults();
|
||||
|
||||
// Backspace. The popup should close.
|
||||
await UrlbarTestUtils.promisePopupClose(window, () =>
|
||||
EventUtils.synthesizeKey("KEY_Backspace")
|
||||
);
|
||||
await deleteInput();
|
||||
|
||||
// Type "x". A new search should start. Don't use
|
||||
// promiseAutocompleteResultPopup, which has some logic that starts the search
|
||||
@ -34,18 +31,16 @@ add_task(async function test() {
|
||||
|
||||
// Now repeat the backspace + x two more times. Same thing should happen.
|
||||
for (let i = 0; i < 2; i++) {
|
||||
await UrlbarTestUtils.promisePopupClose(window, () =>
|
||||
EventUtils.synthesizeKey("KEY_Backspace")
|
||||
);
|
||||
await deleteInput();
|
||||
EventUtils.synthesizeKey("x");
|
||||
await UrlbarTestUtils.promiseSearchComplete(window);
|
||||
await checkResults();
|
||||
}
|
||||
|
||||
// Finally, backspace to close the popup.
|
||||
await UrlbarTestUtils.promisePopupClose(window, () =>
|
||||
EventUtils.synthesizeKey("KEY_Backspace")
|
||||
);
|
||||
await deleteInput();
|
||||
if (!gURLBar.openViewOnFocus) {
|
||||
gURLBar.view.close();
|
||||
}
|
||||
});
|
||||
|
||||
async function checkResults() {
|
||||
@ -57,3 +52,34 @@ async function checkResults() {
|
||||
Assert.equal(details.type, UrlbarUtils.RESULT_TYPE.URL);
|
||||
Assert.equal(details.url, "http://example.com/");
|
||||
}
|
||||
|
||||
async function deleteInput() {
|
||||
if (gURLBar.openViewOnFocus) {
|
||||
// The popup should remain open and show top sites.
|
||||
while (gURLBar.value.length) {
|
||||
EventUtils.synthesizeKey("KEY_Backspace");
|
||||
}
|
||||
Assert.ok(
|
||||
window.gURLBar.view.isOpen,
|
||||
"View should remain open when deleting all input text"
|
||||
);
|
||||
let queryContext = await UrlbarTestUtils.promiseSearchComplete(window);
|
||||
Assert.notEqual(
|
||||
queryContext.results.length,
|
||||
0,
|
||||
"View should show results when deleting all input text"
|
||||
);
|
||||
Assert.equal(
|
||||
queryContext.searchString,
|
||||
"",
|
||||
"Results should be for the empty search string (i.e. top sites) when deleting all input text"
|
||||
);
|
||||
} else {
|
||||
// Deleting all text should close the view.
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
while (gURLBar.value.length) {
|
||||
EventUtils.synthesizeKey("KEY_Backspace");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user