Bug 1060888 - Autocomplete drop down list item should not be copied to the search fields when mouse over the list item. r=MattN, a=sledru
authorDrew Willcoxon <adw@mozilla.com>
Wed, 17 Sep 2014 09:11:06 -0700
changeset 216786 6975bbd6c73a
parent 216785 44cc9f25426d
child 216787 515fa121e700
push id3910
push userryanvm@gmail.com
push date2014-09-18 14:48 +0000
treeherdermozilla-beta@af1dbe183e3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, sledru
bugs1060888
milestone33.0
Bug 1060888 - Autocomplete drop down list item should not be copied to the search fields when mouse over the list item. r=MattN, a=sledru
browser/base/content/searchSuggestionUI.js
browser/base/content/test/general/browser_searchSuggestionUI.js
browser/base/content/test/general/searchSuggestionUI.js
--- a/browser/base/content/searchSuggestionUI.js
+++ b/browser/base/content/searchSuggestionUI.js
@@ -211,23 +211,16 @@ SearchSuggestionUIController.prototype =
   _onFocus: function () {
     this._speculativeConnect();
   },
 
   _onBlur: function () {
     this._hideSuggestions();
   },
 
-  _onMousemove: function (event) {
-    // It's important to listen for mousemove, not mouseover or mouseenter.  The
-    // latter two are triggered when the user is typing and the mouse happens to
-    // be over the suggestions popup.
-    this.selectedIndex = this._indexOfTableRowOrDescendent(event.target);
-  },
-
   _onMousedown: function (event) {
     let idx = this._indexOfTableRowOrDescendent(event.target);
     let suggestion = this.suggestionAtIndex(idx);
     this._stickyInputValue = suggestion;
     this.input.value = suggestion;
     this._hideSuggestions();
     if (this.onClick) {
       this.onClick.call(null);
@@ -293,17 +286,16 @@ SearchSuggestionUIController.prototype =
     }
   },
 
   _makeTableRow: function (type, suggestionStr, currentRow, searchWords) {
     let row = document.createElementNS(HTML_NS, "tr");
     row.classList.add("searchSuggestionRow");
     row.classList.add(type);
     row.setAttribute("role", "presentation");
-    row.addEventListener("mousemove", this);
     row.addEventListener("mousedown", this);
 
     let entry = document.createElementNS(HTML_NS, "td");
     entry.classList.add("searchSuggestionEntry");
     entry.setAttribute("role", "option");
     entry.id = this._idPrefix + SUGGESTION_ID_PREFIX + currentRow;
     entry.setAttribute("aria-selected", "false");
 
--- a/browser/base/content/test/general/browser_searchSuggestionUI.js
+++ b/browser/base/content/test/general/browser_searchSuggestionUI.js
@@ -97,24 +97,16 @@ add_task(rightArrowOrReturn("VK_RIGHT"))
 add_task(rightArrowOrReturn("VK_RETURN"));
 
 add_task(function* mouse() {
   yield setUp();
 
   let state = yield msg("key", { key: "x", waitForSuggestions: true });
   checkState(state, "x", ["xfoo", "xbar"], -1);
 
-  // Mouse over the first suggestion.
-  state = yield msg("mousemove", 0);
-  checkState(state, "xfoo", ["xfoo", "xbar"], 0);
-
-  // Mouse over the second suggestion.
-  state = yield msg("mousemove", 1);
-  checkState(state, "xbar", ["xfoo", "xbar"], 1);
-
   // Click the second suggestion.  This should make it sticky.  To make sure it
   // sticks, trigger suggestions again and cycle through them by pressing Down
   // until nothing is selected again.
   state = yield msg("mousedown", 1);
   checkState(state, "xbar", [], -1);
 
   state = yield msg("key", { key: "VK_DOWN", waitForSuggestions: true });
   checkState(state, "xbar", ["xbarfoo", "xbarbar"], -1);
--- a/browser/base/content/test/general/searchSuggestionUI.js
+++ b/browser/base/content/test/general/searchSuggestionUI.js
@@ -32,43 +32,16 @@ let messageHandlers = {
     ack();
   },
 
   blur: function () {
     gController.input.blur();
     ack();
   },
 
-  mousemove: function (suggestionIdx) {
-    // Copied from widget/tests/test_panel_mouse_coords.xul and
-    // browser/base/content/test/newtab/head.js
-    let row = gController._table.children[suggestionIdx];
-    let rect = row.getBoundingClientRect();
-    let left = content.mozInnerScreenX + rect.left;
-    let x = left + rect.width / 2;
-    let y = content.mozInnerScreenY + rect.top + rect.height / 2;
-
-    let utils = content.SpecialPowers.getDOMWindowUtils(content);
-    let scale = utils.screenPixelsPerCSSPixel;
-
-    let widgetToolkit = content.SpecialPowers.
-                        Cc["@mozilla.org/xre/app-info;1"].
-                        getService(content.SpecialPowers.Ci.nsIXULRuntime).
-                        widgetToolkit;
-    let nativeMsg = widgetToolkit == "cocoa" ? 5 : // NSMouseMoved
-                    widgetToolkit == "windows" ? 1 : // MOUSEEVENTF_MOVE
-                    3; // GDK_MOTION_NOTIFY
-
-    row.addEventListener("mousemove", function onMove() {
-      row.removeEventListener("mousemove", onMove);
-      ack();
-    });
-    utils.sendNativeMouseEvent(x * scale, y * scale, nativeMsg, 0, null);
-  },
-
   mousedown: function (suggestionIdx) {
     gController.onClick = () => {
       gController.onClick = null;
       ack();
     };
     let row = gController._table.children[suggestionIdx];
     content.sendMouseEvent({ type: "mousedown" }, row);
   },