Bug 1498379 - browser_homeDrop.js and head.js rely on EventUtils.js to dispatch artificial mouseup after dnd, r=gijs
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Mon, 15 Oct 2018 22:33:05 -0400
changeset 489758 39df6098355c40854c6f54077f897f645fac9cbe
parent 489757 2c7473068da142246c65c671387eaa8108c04ae3
child 489759 9b3d9022cce8093be3f745fb023f1d47132dacda
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersgijs
bugs1498379
milestone64.0a1
Bug 1498379 - browser_homeDrop.js and head.js rely on EventUtils.js to dispatch artificial mouseup after dnd, r=gijs
browser/base/content/test/general/browser_homeDrop.js
browser/base/content/test/tabs/head.js
browser/components/customizableui/test/head.js
--- a/browser/base/content/test/general/browser_homeDrop.js
+++ b/browser/base/content/test/general/browser_homeDrop.js
@@ -14,16 +14,18 @@ add_task(async function() {
   ok(dragSrcElement, "Downloads button exists");
   let homeButton = document.getElementById("home-button");
   ok(homeButton, "home button present");
 
   async function drop(dragData, homepage) {
     let setHomepageDialogPromise = BrowserTestUtils.domWindowOpened();
 
     EventUtils.synthesizeDrop(dragSrcElement, homeButton, dragData, "copy", window);
+    // Ensure dnd suppression is cleared.
+    EventUtils.synthesizeMouseAtCenter(homeButton, { type: "mouseup" }, window);
 
     let setHomepageDialog = await setHomepageDialogPromise;
     ok(true, "dialog appeared in response to home button drop");
     await BrowserTestUtils.waitForEvent(setHomepageDialog, "load", false);
 
     let setHomepagePromise = new Promise(function(resolve) {
       let observer = {
         QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),
@@ -63,16 +65,18 @@ add_task(async function() {
       });
 
       executeSoon(function() {
         info("Attempting second drop, of a javascript: URI");
         // The drop handler throws an exception when dragging URIs that inherit
         // principal, e.g. javascript:
         expectUncaughtException();
         EventUtils.synthesizeDrop(dragSrcElement, homeButton, [[{type: "text/plain", data: "javascript:8888"}]], "copy", window);
+        // Ensure dnd suppression is cleared.
+        EventUtils.synthesizeMouseAtCenter(homeButton, { type: "mouseup" }, window);
       });
     });
   }
 
   await drop([[{type: "text/plain",
                  data: "http://mochi.test:8888/"}]],
               "http://mochi.test:8888/");
   await drop([[{type: "text/plain",
--- a/browser/base/content/test/tabs/head.js
+++ b/browser/base/content/test/tabs/head.js
@@ -169,16 +169,18 @@ async function dragAndDrop(tab1, tab2, c
   if (destWindow != window) {
     // Make sure that both tab1 and tab2 are visible
     window.focus();
     window.moveTo(rect.left, rect.top + rect.height * 3);
   }
 
   let originalTPos = tab1._tPos;
   EventUtils.synthesizeDrop(tab1, tab2, null, copy ? "copy" : "move", window, destWindow, event);
+  // Ensure dnd suppression is cleared.
+  EventUtils.synthesizeMouseAtCenter(tab2, { type: "mouseup" }, destWindow);
   if (!copy && destWindow == window) {
     await BrowserTestUtils.waitForCondition(() => tab1._tPos != originalTPos,
       "Waiting for tab position to be updated");
   } else if (destWindow != window) {
     await BrowserTestUtils.waitForCondition(() => tab1.closing,
       "Waiting for tab closing");
   }
 }
--- a/browser/components/customizableui/test/head.js
+++ b/browser/components/customizableui/test/head.js
@@ -18,17 +18,17 @@ Services.scriptloader.loadSubScript("chr
 /**
  * Instance of CustomizableUITestUtils for the current browser window.
  */
 var gCUITestUtils = new CustomizableUITestUtils(window);
 
 Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
 registerCleanupFunction(() => Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck"));
 
-var {synthesizeDragStart, synthesizeDrop} = EventUtils;
+var {synthesizeDragStart, synthesizeDrop, synthesizeMouseAtCenter} = EventUtils;
 
 const kNSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 const kForceOverflowWidthPx = 300;
 
 function createDummyXULButton(id, label, win = window) {
   let btn = document.createElementNS(kNSXUL, "toolbarbutton");
   btn.id = id;
@@ -184,16 +184,18 @@ function simulateItemDrag(aToDrag, aTarg
       ev = {clientX: bounds.right - 2, clientY: bounds.bottom - 2};
     } else {
       ev = {clientX: bounds.left + 2, clientY: bounds.top + 2};
     }
   }
   ev._domDispatchOnly = true;
   synthesizeDrop(aToDrag.parentNode, aTarget, null, null,
                  aToDrag.ownerGlobal, aTarget.ownerGlobal, ev);
+  // Ensure dnd suppression is cleared.
+  synthesizeMouseAtCenter(aTarget, { type: "mouseup" }, aTarget.ownerGlobal);
 }
 
 function endCustomizing(aWindow = window) {
   if (aWindow.document.documentElement.getAttribute("customizing") != "true") {
     return true;
   }
   return new Promise(resolve => {
     function onCustomizationEnds() {