Bug 1492196 - fix browser_searchbar_openpopup.js so we don't accidentally try to drag content in the URL bar, r=florian

Differential Revision: https://phabricator.services.mozilla.com/D6180

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2018-09-19 10:15:46 +00:00
parent c5bf22cd9a
commit ba80b3c145
2 changed files with 11 additions and 0 deletions

View File

@ -460,6 +460,14 @@ add_task(async function dont_consume_clicks() {
// Dropping text to the searchbar should open the popup
add_task(async function drop_opens_popup() {
// The previous task leaves focus in the URL bar. However, in that case drags
// can be interpreted as being selection drags by the drag manager, which
// breaks the drag synthesis from EventUtils.js below. To avoid this, focus
// the browser content instead.
let focusEventPromise = BrowserTestUtils.waitForEvent(gBrowser.selectedBrowser, "focus");
gBrowser.selectedBrowser.focus();
await focusEventPromise;
let promise = promiseEvent(searchPopup, "popupshown");
// Use a source for the drop that is outside of the search bar area, to avoid
// it receiving a mousedown and causing the popup to sometimes open.

View File

@ -2613,6 +2613,9 @@ function synthesizeDragOver(aSrcElement, aDestElement, aDragData, aDropEffect, a
obs.removeObserver(trapDrag, "on-datatransfer-available");
var dataTransfer = sess.dataTransfer;
if (!dataTransfer) {
throw new Error("No data transfer object after synthesizing the mouse!");
}
// The EventStateManager will fire our dragenter event if it needs to.
var event = createDragEventObject("dragover", aDestElement, aDestWindow,