Bug 1538158 - Clicking the history dropmarker should initiate an empty search instead of searching for the loaded URL. r=adw
authorDão Gottwald <dao@mozilla.com>
Thu, 28 Mar 2019 16:18:50 +0000
changeset 466608 98fddb0a076a6e1654352a189e3d4f999597f06f
parent 466607 ed607a3b988e1514ea2b18d02b68bced50042f93
child 466609 76fd580f28620e5a6f56856d5c2bfea2ab11539e
push id81699
push userdgottwald@mozilla.com
push dateThu, 28 Mar 2019 16:20:06 +0000
treeherderautoland@98fddb0a076a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1538158
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1538158 - Clicking the history dropmarker should initiate an empty search instead of searching for the loaded URL. r=adw Differential Revision: https://phabricator.services.mozilla.com/D25059
browser/components/urlbar/UrlbarInput.jsm
browser/components/urlbar/tests/UrlbarTestUtils.jsm
browser/components/urlbar/tests/browser/browser.ini
browser/components/urlbar/tests/browser/browser_dropmarker.js
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -532,17 +532,18 @@ class UrlbarInput {
       return;
     }
 
     if (resetSearchState) {
       this._resetSearchState();
     }
 
     if (!searchString) {
-      searchString = this.textValue;
+      searchString = (this.getAttribute("pageproxystate") == "valid") ?
+                     "" : this.textValue;
     } else if (!this.textValue.startsWith(searchString)) {
       throw new Error("The current value doesn't start with the search string");
     }
     this._lastSearchString = searchString;
 
     // TODO (Bug 1522902): This promise is necessary for tests, because some
     // tests are not listening for completion when starting a query through
     // other methods than startQuery (input events for example).
--- a/browser/components/urlbar/tests/UrlbarTestUtils.jsm
+++ b/browser/components/urlbar/tests/UrlbarTestUtils.jsm
@@ -47,16 +47,18 @@ var UrlbarTestUtils = {
     let restoreAnimationsFn = urlbar.disableAnimations();
     await new Promise(resolve => waitForFocus(resolve, win));
     let lastSearchString = urlbar.lastSearchString;
     urlbar.focus();
     urlbar.value = inputText;
     if (fireInputEvent) {
       // This is necessary to get the urlbar to set gBrowser.userTypedValue.
       urlbar.fireInputEvent();
+    } else {
+      win.gURLBar.setAttribute("pageproxystate", "invalid");
     }
     // An input event will start a new search, with a couple of exceptions, so
     // be careful not to call startSearch if we fired an input event since that
     // would start two searches.  The first exception is when the new search and
     // old search are the same.  Many tests do consecutive searches with the
     // same string and expect new searches to start, so call startSearch
     // directly then.  The second exception is when searching with the legacy
     // urlbar and an empty string.
@@ -335,16 +337,17 @@ class UrlbarAbstraction {
     }
 
     return this.oneOffSearchButtons.style.display != "none";
   }
 
   startSearch(text) {
     if (this.quantumbar) {
       this.urlbar.value = text;
+      this.urlbar.setAttribute("pageproxystate", "invalid");
       this.urlbar.startQuery();
     } else {
       // Force the controller to do consecutive searches for the same string by
       // calling resetInternalState.
       this.urlbar.controller.resetInternalState();
       this.urlbar.controller.startSearch(text);
     }
   }
--- a/browser/components/urlbar/tests/browser/browser.ini
+++ b/browser/components/urlbar/tests/browser/browser.ini
@@ -28,16 +28,17 @@ skip-if = os != "mac" # Mac only feature
 [browser_autoFill_caretNotAtEnd.js]
 [browser_autoFill_placeholder.js]
 [browser_autoFill_preserve.js]
 [browser_autoFill_trimURLs.js]
 [browser_autoFill_typed.js]
 [browser_canonizeURL.js]
 [browser_caret_navigation.js]
 [browser_dragdropURL.js]
+[browser_dropmarker.js]
 [browser_keepStateAcrossTabSwitches.js]
 [browser_keyword_override.js]
 [browser_keyword_select_and_type.js]
 [browser_keyword.js]
 support-files =
   print_postdata.sjs
 [browser_locationBarCommand.js]
 [browser_locationBarExternalLoad.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/urlbar/tests/browser/browser_dropmarker.js
@@ -0,0 +1,19 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+"use strict";
+
+add_task(async function() {
+  await BrowserTestUtils.withNewTab({ gBrowser, url: "http://example.com/" }, async () => {
+    await UrlbarTestUtils.promisePopupOpen(window, () => {
+      let historyDropMarker =
+        window.document.getAnonymousElementByAttribute(gURLBar.textbox, "anonid", "historydropmarker");
+      EventUtils.synthesizeMouseAtCenter(historyDropMarker, {}, window);
+    });
+    let queryContext = await gURLBar.lastQueryContextPromise;
+    is(queryContext.searchString, "",
+       "Clicking the history dropmarker should initiate an empty search instead of searching for the loaded URL");
+    await UrlbarTestUtils.promisePopupClose(window);
+  });
+});