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. r=nhnt11
authorPrathiksha <prathikshaprasadsuman@gmail.com>
Fri, 15 Sep 2017 22:08:12 +0530
changeset 679111 e029590936c56ac269d68610ab389ab25887b6e1
parent 679110 8d5cc47b248f5b6c995fc836b076a3c0d1655313
child 679112 aae33bcfef8b4d7e66478d9f54ae2f66d8aaf201
push id84141
push userbmo:schien@mozilla.com
push dateThu, 12 Oct 2017 11:13:04 +0000
reviewersnhnt11
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. r=nhnt11 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();