Bug 1240014, enable test browser_newtab_bug723121 in e10s, r=adw
authorNeil Deakin <neil@mozilla.com>
Tue, 26 Jan 2016 08:16:10 -0500
changeset 304687 2b79f3d62e3fe76609867940f1ce2db7323496c7
parent 304686 bec26e4948a4587b7315562788b8a3fe0a8bbeff
child 304688 fcde120f53ec7beca1330f1237c2e4af72f20d0f
push id9214
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:25:21 +0000
treeherdermozilla-aurora@8849dd1a4a79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1240014, 723121
milestone47.0a1
Bug 1240014, enable test browser_newtab_bug723121 in e10s, r=adw
browser/base/content/test/newtab/browser_newtab_bug723121.js
browser/base/content/test/newtab/head.js
--- a/browser/base/content/test/newtab/browser_newtab_bug723121.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug723121.js
@@ -1,30 +1,42 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-function runTests() {
+add_task(function* () {
   yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
 
-  yield addNewTabPageTab();
-  checkGridLocked(false, "grid is unlocked");
+  yield* addNewTabPageTab();
 
-  let cell = getCell(0).node;
-  let site = getCell(0).site.node;
-  let link = site.querySelector(".newtab-link");
+  yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function*() {
+    let grid = content.gGrid;
+    let cell = grid.cells[0];
+    let site = cell.site.node;
+    let link = site.querySelector(".newtab-link");
 
-  sendDragEvent("dragstart", link);
-  checkGridLocked(true, "grid is now locked");
+    function checkGridLocked(aLocked, aMessage) {
+      is(grid.node.hasAttribute("locked"), aLocked, aMessage);
+    }
 
-  sendDragEvent("dragend", link);
-  checkGridLocked(false, "grid isn't locked anymore");
+    function sendDragEvent(aEventType, aTarget) {
+      let dataTransfer = new content.DataTransfer(aEventType, false);
+      let event = content.document.createEvent("DragEvents");
+      event.initDragEvent(aEventType, true, true, content, 0, 0, 0, 0, 0,
+                          false, false, false, false, 0, null, dataTransfer);
+      aTarget.dispatchEvent(event);
+    }
 
-  sendDragEvent("dragstart", cell);
-  checkGridLocked(false, "grid isn't locked - dragstart was ignored");
+    checkGridLocked(false, "grid is unlocked");
 
-  sendDragEvent("dragstart", site);
-  checkGridLocked(false, "grid isn't locked - dragstart was ignored");
-}
+    sendDragEvent("dragstart", link);
+    checkGridLocked(true, "grid is now locked");
+
+    sendDragEvent("dragend", link);
+    checkGridLocked(false, "grid isn't locked anymore");
 
-function checkGridLocked(aLocked, aMessage) {
-  is(getGrid().node.hasAttribute("locked"), aLocked, aMessage);
-}
+    sendDragEvent("dragstart", cell.node);
+    checkGridLocked(false, "grid isn't locked - dragstart was ignored");
+
+    sendDragEvent("dragstart", site);
+    checkGridLocked(false, "grid isn't locked - dragstart was ignored");
+  });
+});
--- a/browser/base/content/test/newtab/head.js
+++ b/browser/base/content/test/newtab/head.js
@@ -695,20 +695,17 @@ function synthesizeNativeMouseEvent(aEle
 
 /**
  * Sends a custom drag event to a given DOM element.
  * @param aEventType The drag event's type.
  * @param aTarget The DOM element that the event is dispatched to.
  * @param aData The event's drag data (optional).
  */
 function sendDragEvent(aEventType, aTarget, aData) {
-  let event = createDragEvent(aEventType, aData);
-  let ifaceReq = getContentWindow().QueryInterface(Ci.nsIInterfaceRequestor);
-  let windowUtils = ifaceReq.getInterface(Ci.nsIDOMWindowUtils);
-  windowUtils.dispatchDOMEventViaPresShell(aTarget, event, true);
+  aTarget.dispatchEvent(createDragEvent(aEventType, aData));
 }
 
 /**
  * Creates a custom drag event.
  * @param aEventType The drag event's type.
  * @param aData The event's drag data (optional).
  * @return The drag event.
  */