Bug 1357523 - Make about:home and about:newtab search box search for the value in the search textbox when we use non-default search engines. draft
authorPrathiksha <prathikshaprasadsuman@gmail.com>
Fri, 15 Sep 2017 22:08:12 +0530
changeset 677109 4fefc1f0c92634832f0981d0a3a4b73e23027574
parent 676713 613f64109bdef590b9748355441b3c620efa7be5
child 735121 dec7800479d5b9e149fc629b0496a8893c858fad
push id83697
push userbmo:prathikshaprasadsuman@gmail.com
push dateTue, 10 Oct 2017 04:37:00 +0000
bugs1357523
milestone58.0a1
Bug 1357523 - Make about:home and about:newtab search box search for the value in the search textbox when we use non-default search engines. MozReview-Commit-ID: CdgqghkmXau
browser/base/content/contentSearchUI.js
browser/base/content/test/general/browser_contentSearchUI.js
--- a/browser/base/content/contentSearchUI.js
+++ b/browser/base/content/contentSearchUI.js
@@ -473,16 +473,18 @@ ContentSearchUIController.prototype = {
     }
     this.input.removeAttribute("keepfocus");
     this._hideSuggestions();
   },
 
   _onMousemove(event) {
     let idx = this._indexOfTableItem(event.target);
     if (idx >= this.numSuggestions) {
+      // Deselect any search suggestion that has been selected.
+      this.selectedIndex = -1;
       this.selectedButtonIndex = idx - this.numSuggestions;
       return;
     }
     this.selectedIndex = idx;
   },
 
   _onMouseup(event) {
     if (event.button == 2) {
--- a/browser/base/content/test/general/browser_contentSearchUI.js
+++ b/browser/base/content/test/general/browser_contentSearchUI.js
@@ -295,38 +295,38 @@ add_task(async function mouse() {
 
   state = await msg("mousemove", 0);
   checkState(state, "x", ["xfoo", "xbar"], 0);
 
   state = await msg("mousemove", 1);
   checkState(state, "x", ["xfoo", "xbar"], 1);
 
   state = await msg("mousemove", 2);
-  checkState(state, "x", ["xfoo", "xbar"], 1, 0);
+  checkState(state, "x", ["xfoo", "xbar"], 2, 0);
 
   state = await msg("mousemove", 3);
-  checkState(state, "x", ["xfoo", "xbar"], 1, 1);
+  checkState(state, "x", ["xfoo", "xbar"], 3, 1);
 
   state = await msg("mousemove", -1);
-  checkState(state, "x", ["xfoo", "xbar"], 1);
+  checkState(state, "x", ["xfoo", "xbar"], -1);
 
   await msg("reset");
   await setUp();
 
   state = await msg("key", { key: "x", waitForSuggestions: true });
   checkState(state, "x", ["xfoo", "xbar"], -1);
 
   state = await msg("mousemove", 0);
   checkState(state, "x", ["xfoo", "xbar"], 0);
 
   state = await msg("mousemove", 2);
-  checkState(state, "x", ["xfoo", "xbar"], 0, 0);
+  checkState(state, "x", ["xfoo", "xbar"], 2, 0);
 
   state = await msg("mousemove", -1);
-  checkState(state, "x", ["xfoo", "xbar"], 0);
+  checkState(state, "x", ["xfoo", "xbar"], -1);
 
   await msg("reset");
 });
 
 add_task(async function formHistory() {
   await setUp();
 
   // Type an X and add it to form history.
@@ -505,42 +505,26 @@ add_task(async function search() {
   eventData.engineName = TEST_ENGINE_PREFIX + " " + TEST_ENGINE_2_BASENAME;
   delete eventData.selection;
   SimpleTest.isDeeply(eventData, mesg, "Search event data");
 
   await promiseTab();
   await setUp();
 
   // Test selecting a suggestion, then clicking a one-off without deselecting the
-  // suggestion.
-  await msg("key", { key: "x", waitForSuggestions: true });
-  p = msg("waitForSearch");
-  await msg("mousemove", 1);
-  await msg("mousemove", 3);
-  await msg("click", { eltIdx: 3, modifiers });
-  mesg = await p;
-  eventData.searchString = "xfoo"
-  eventData.selection = {
-    index: 1,
-    kind: "mouse",
-  };
-  SimpleTest.isDeeply(eventData, mesg, "Search event data");
-
-  await promiseTab();
-  await setUp();
-
-  // Same as above, but with the keyboard.
+  // suggestion, using the keyboard.
   delete modifiers.button;
   await msg("key", { key: "x", waitForSuggestions: true });
   p = msg("waitForSearch");
   await msg("key", "VK_DOWN");
   await msg("key", "VK_DOWN");
   await msg("key", "VK_TAB");
   await msg("key", { key: "VK_RETURN", modifiers });
   mesg = await p;
+  eventData.searchString = "xfoo";
   eventData.selection = {
     index: 1,
     kind: "key",
   };
   SimpleTest.isDeeply(eventData, mesg, "Search event data");
 
   await promiseTab();
   await setUp();