Bug 1515307 - Opening the popup with up/down when a string is typed should search that string. r=mak
authorDão Gottwald <dao@mozilla.com>
Thu, 17 Jan 2019 18:43:32 +0000
changeset 514300 8b0f8227976b661e217e05f461bd7a86a80f0028
parent 514299 b5270d03a6d80a9e514035d3a81a7715aaa19ce6
child 514301 230f156b2393e214874269515b1c0059fe14431b
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1515307
milestone66.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 1515307 - Opening the popup with up/down when a string is typed should search that string. r=mak Differential Revision: https://phabricator.services.mozilla.com/D16861
browser/components/urlbar/UrlbarInput.jsm
browser/components/urlbar/tests/browser/browser_UrlbarInput_unit.js
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -343,33 +343,30 @@ class UrlbarInput {
       val = this.window.losslessDecodeURI(uri);
     }
     this.value = val;
   }
 
   /**
    * Starts a query based on the user input.
    *
-   * @param {string} [options.searchString]
-   *   The string the user entered in autocomplete.
    * @param {number} [options.lastKey]
    *   The last key the user entered (as a key code).
    */
   startQuery({
-    searchString = "",
     lastKey = null,
   } = {}) {
     this.controller.startQuery(new QueryContext({
       enableAutofill: UrlbarPrefs.get("autoFill"),
       isPrivate: this.isPrivate,
       lastKey,
       maxResults: UrlbarPrefs.get("maxRichResults"),
       muxer: "UnifiedComplete",
       providers: ["UnifiedComplete"],
-      searchString,
+      searchString: this.textValue,
     }));
   }
 
   typeRestrictToken(char) {
     this.inputField.value = char + " ";
 
     let event = this.document.createEvent("UIEvents");
     event.initUIEvent("input", true, false, this.window, 0);
@@ -660,31 +657,30 @@ class UrlbarInput {
       if (this.view.isOpen) {
         this.view.close();
       } else {
         this.startQuery();
       }
     }
   }
 
-  _on_input(event) {
-    let value = event.target.value;
+  _on_input() {
+    let value = this.textValue;
     this.valueIsTyped = true;
     this._untrimmedValue = value;
     this.window.gBrowser.userTypedValue = value;
 
     if (value) {
       this.setAttribute("usertyping", "true");
     } else {
       this.removeAttribute("usertyping");
     }
 
     // XXX Fill in lastKey, and add anything else we need.
     this.startQuery({
-      searchString: value,
       lastKey: null,
     });
   }
 
   _on_select(event) {
     if (!Services.clipboard.supportsSelectionClipboard()) {
       return;
     }
--- a/browser/components/urlbar/tests/browser/browser_UrlbarInput_unit.js
+++ b/browser/components/urlbar/tests/browser/browser_UrlbarInput_unit.js
@@ -94,20 +94,19 @@ add_task(async function setup() {
     panel,
     controller: fakeController,
   };
 
   input = new UrlbarInput(inputOptions);
 });
 
 add_task(function test_input_starts_query() {
+  input.inputField.value = "search";
   input.handleEvent({
-    target: {
-      value: "search",
-    },
+    target: input.inputField,
     type: "input",
   });
 
   checkStartQueryCall(fakeController.startQuery, {
     searchString: "search",
     isPrivate: false,
     maxResults: UrlbarPrefs.get("maxRichResults"),
   });
@@ -117,20 +116,19 @@ add_task(function test_input_starts_quer
 
 add_task(function test_input_with_private_browsing() {
   PrivateBrowsingUtils.isWindowPrivate.returns(true);
 
   // Rather than using the global input here, we create a new instance which
   // will use the updated return value of the private browsing stub.
   let privateInput = new UrlbarInput(inputOptions);
 
+  privateInput.inputField.value = "search";
   privateInput.handleEvent({
-    target: {
-      value: "search",
-    },
+    target: privateInput.inputField,
     type: "input",
   });
 
   checkStartQueryCall(fakeController.startQuery, {
     searchString: "search",
     isPrivate: true,
   });