Bug 1521494 - Close the results view if something is typed, then deleted. r=Standard8
authorDão Gottwald <dao@mozilla.com>
Sun, 17 Feb 2019 20:26:51 +0000
changeset 459723 8ef512bad00f054b006b6e47b0a6218e3d19b8b0
parent 459722 ed02c658796563ba9763598052ca3d53841bec69
child 459724 fce0d0927739b6e65f022cc00fe5c4719fdedea3
child 459745 ac7e1f872d25d9c9e74b0bc2d3b5c26e7cd5daeb
push id35569
push useropoprus@mozilla.com
push dateMon, 18 Feb 2019 09:44:27 +0000
treeherdermozilla-central@8ef512bad00f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs1521494
milestone67.0a1
first release with
nightly linux32
8ef512bad00f / 67.0a1 / 20190218094427 / files
nightly linux64
8ef512bad00f / 67.0a1 / 20190218094427 / files
nightly mac
8ef512bad00f / 67.0a1 / 20190218094427 / files
nightly win32
8ef512bad00f / 67.0a1 / 20190218094427 / files
nightly win64
8ef512bad00f / 67.0a1 / 20190218094427 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521494 - Close the results view if something is typed, then deleted. r=Standard8 Differential Revision: https://phabricator.services.mozilla.com/D20090
browser/components/urlbar/UrlbarInput.jsm
browser/components/urlbar/tests/browser/browser_urlbar_empty_search.js
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -967,16 +967,21 @@ class UrlbarInput {
 
     if (value) {
       this.setAttribute("usertyping", "true");
     } else {
       this.removeAttribute("usertyping");
     }
     this.removeAttribute("actiontype");
 
+    if (!value && this.view.isOpen) {
+      this.view.close();
+      return;
+    }
+
     // XXX Fill in lastKey, and add anything else we need.
     this.startQuery({
       lastKey: null,
     });
   }
 
   _on_select(event) {
     if (!Services.clipboard.supportsSelectionClipboard()) {
--- a/browser/components/urlbar/tests/browser/browser_urlbar_empty_search.js
+++ b/browser/components/urlbar/tests/browser/browser_urlbar_empty_search.js
@@ -39,9 +39,18 @@ add_task(async function test_empty() {
     let length = await UrlbarTestUtils.getResultCount(window);
     Assert.equal(length, results.length, "Comparing results count");
     for (let i = 1; i < length; ++i) {
       Assert.deepEqual(await UrlbarTestUtils.getDetailsOfResultAt(window, i),
                         results[i],
                        `Comparing result at index ${i}`);
     }
   }
+  await UrlbarTestUtils.promisePopupClose(window);
 });
+
+add_task(async function test_backspace_empty() {
+  info("Testing that deleting the input value via backspace closes the popup");
+  await promiseAutocompleteResultPopup(" ", window, true);
+  await UrlbarTestUtils.promisePopupClose(window, () => {
+    EventUtils.synthesizeKey("KEY_Backspace");
+  });
+});