Bug 1111947 - Dropping text on the searchbar shouldn't search it immediately. r=mossop

This commit is contained in:
Florian Quèze 2015-01-26 15:41:05 +01:00
parent b308b6c8ab
commit 527fa74db7
3 changed files with 25 additions and 30 deletions

View File

@ -1261,7 +1261,7 @@
if (data) {
event.preventDefault();
this.value = data;
this.onTextEntered(event);
document.getBindingParent(this).openSuggestionsPanel();
}
]]>
</handler>

View File

@ -71,7 +71,7 @@ function* countEntries(name, value) {
var searchBar;
var searchButton;
var searchEntries = ["test", "More Text", "Some Text"];
var searchEntries = ["test"];
function* promiseSetEngine() {
let deferred = Promise.defer();
var ss = Services.search;
@ -227,33 +227,6 @@ add_task(function testShiftMiddleClick() {
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";

View File

@ -1,5 +1,12 @@
// 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");
@ -412,6 +419,21 @@ add_task(function* dont_consume_clicks() {
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 = "";
});
// Moving the caret using the cursor keys should not close the popup.
add_task(function* dont_rollup_oncaretmove() {
gURLBar.focus();