Bug 1111947 - Dropping text on the searchbar shouldn't search it immediately. r=mossop, a=lmandel
☠☠ backed out by a57cce6af02c ☠ ☠
authorFlorian Quèze <florian@queze.net>
Mon, 26 Jan 2015 15:41:05 +0100
changeset 249592 fb3d1ebbb61010fa3ed947c77eb99d88f2453acb
parent 249591 8061d4f8d716e828f80f62d0423cd2d33e923744
child 249593 b85afc7a726a69f6dfad86a7c80d85ae490751b4
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop, lmandel
bugs1111947
milestone37.0a2
Bug 1111947 - Dropping text on the searchbar shouldn't search it immediately. r=mossop, a=lmandel
browser/components/search/content/search.xml
browser/components/search/test/browser_426329.js
browser/components/search/test/browser_searchbar_openpopup.js
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -1250,16 +1250,16 @@
       <![CDATA[
         var dataTransfer = event.dataTransfer;
         var data = dataTransfer.getData("text/plain");
         if (!data)
           data = dataTransfer.getData("text/x-moz-text-internal");
         if (data) {
           event.preventDefault();
           this.value = data;
-          this.onTextEntered(event);
+          document.getBindingParent(this).openSuggestionsPanel();
         }
       ]]>
       </handler>
 
     </handlers>
   </binding>
 </bindings>
--- a/browser/components/search/test/browser_426329.js
+++ b/browser/components/search/test/browser_426329.js
@@ -66,17 +66,17 @@ function* countEntries(name, value) {
                         }
                       }
                     });
   return deferred.promise;
 }
 
 var searchBar;
 var searchButton;
-var searchEntries = ["test", "More Text", "Some Text"];
+var searchEntries = ["test"];
 function* promiseSetEngine() {
   let deferred = Promise.defer();
   var ss = Services.search;
 
   function observer(aSub, aTopic, aData) {
     switch (aData) {
       case "engine-added":
         var engine = ss.getEngineByName("Bug 426329");
@@ -222,43 +222,16 @@ add_task(function testShiftMiddleClick()
   is(gBrowser.tabs.length, preTabNo + 1, "Shift+MiddleClick added new tab");
   isnot(event.originalTarget, preSelectedBrowser.contentDocument,
         "Shift+MiddleClick loaded results in new tab");
   isnot(event.originalTarget, gBrowser.contentDocument,
         "Shift+MiddleClick loaded results in background tab");
   is(event.originalTarget.URL, expectedURL(searchBar.value), "testShiftMiddleClick opened correct search page");
 });
 
-add_task(function testDropText() {
-  yield prepareTest();
-  // drop on the search button so that we don't need to worry about the
-  // default handlers for textboxes.
-  let searchButton = document.getAnonymousElementByAttribute(searchBar, "anonid", "searchbar-search-button");
-  ChromeUtils.synthesizeDrop(searchButton, searchButton, [[ {type: "text/plain", data: "Some Text" } ]], "copy", window);
-  let event = yield promiseOnLoad();
-  is(event.originalTarget.URL, expectedURL(searchBar.value), "testDropText opened correct search page");
-  is(searchBar.value, "Some Text", "drop text/plain on searchbar");
-});
-
-add_task(function testDropInternalText() {
-  yield prepareTest();
-  let searchButton = document.getAnonymousElementByAttribute(searchBar, "anonid", "searchbar-search-button");
-  ChromeUtils.synthesizeDrop(searchButton, searchButton, [[ {type: "text/x-moz-text-internal", data: "More Text" } ]], "copy", window);
-  let event = yield promiseOnLoad();
-  is(event.originalTarget.URL, expectedURL(searchBar.value), "testDropInternalText opened correct search page");
-  is(searchBar.value, "More Text", "drop text/x-moz-text-internal on searchbar");
-
-  // testDropLink implicitly depended on testDropInternalText, so these two tests
-  // were merged so that if testDropInternalText failed it wouldn't cause testDropLink
-  // to fail unexplainably.
-  yield prepareTest();
-  ChromeUtils.synthesizeDrop(searchBar.searchButton, searchBar.searchButton, [[ {type: "text/uri-list", data: "http://www.mozilla.org" } ]], "copy", window);
-  is(searchBar.value, "More Text", "drop text/uri-list on searchbar shouldn't change anything");
-});
-
 add_task(function testRightClick() {
   preTabNo = gBrowser.tabs.length;
   content.location.href = "about:blank";
   simulateClick({ button: 2 }, searchButton);
   let deferred = Promise.defer();
   setTimeout(function() {
     is(gBrowser.tabs.length, preTabNo, "RightClick did not open new tab");
     is(gBrowser.currentURI.spec, "about:blank", "RightClick did nothing");
--- a/browser/components/search/test/browser_searchbar_openpopup.js
+++ b/browser/components/search/test/browser_searchbar_openpopup.js
@@ -1,10 +1,17 @@
 // Tests that the suggestion popup appears at the right times in response to
-// focus and clicks.
+// focus and user events (mouse, keyboard, drop).
+
+// Instead of loading ChromeUtils.js into the test scope in browser-test.js for all tests,
+// we only need ChromeUtils.js for a few files which is why we are using loadSubScript.
+var ChromeUtils = {};
+this._scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
+                     getService(Ci.mozIJSSubScriptLoader);
+this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js", ChromeUtils);
 
 const searchbar = document.getElementById("searchbar");
 const searchIcon = document.getAnonymousElementByAttribute(searchbar, "anonid", "searchbar-search-button");
 const goButton = document.getAnonymousElementByAttribute(searchbar, "anonid", "search-go-button");
 const textbox = searchbar._textbox;
 const searchPopup = document.getElementById("PopupSearchAutoComplete");
 
 const isWindows = Services.appinfo.OS == "WINNT";
@@ -364,8 +371,23 @@ add_task(function* dont_consume_clicks()
   promise = promiseEvent(searchPopup, "popuphidden");
   synthesizeNativeMouseClick(gURLBar);
   yield promise;
 
   is(Services.focus.focusedElement, gURLBar.inputField, "Should have focused the URL bar");
 
   textbox.value = "";
 });
+
+// Dropping text to the searchbar should open the popup
+add_task(function* drop_opens_popup() {
+  let promise = promiseEvent(searchPopup, "popupshown");
+  ChromeUtils.synthesizeDrop(searchIcon, textbox.inputField, [[ {type: "text/plain", data: "foo" } ]], "move", window);
+  yield promise;
+
+  isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup");
+  is(Services.focus.focusedElement, textbox.inputField, "Should have focused the search bar");
+  promise = promiseEvent(searchPopup, "popuphidden");
+  searchPopup.hidePopup();
+  yield promise;
+
+  textbox.value = "";
+});