Bug 1254091 - part 3: make sure this test passes on hidpi and when run in the mochitest frame, r=enndeakin
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 18 Mar 2016 18:29:56 +0000
changeset 313365 3dc5292ed66afbca801c33bff49c86154b3b3c24
parent 313364 3169edcea9d93557be4168312fb784e86706d944
child 313366 93955ff309b7710a910003b067433eb4e67aa742
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin
bugs1254091
milestone48.0a1
Bug 1254091 - part 3: make sure this test passes on hidpi and when run in the mochitest frame, r=enndeakin MozReview-Commit-ID: FF8GnesOR3Q
toolkit/content/tests/mochitest/test_mousecapture.xhtml
--- a/toolkit/content/tests/mochitest/test_mousecapture.xhtml
+++ b/toolkit/content/tests/mochitest/test_mousecapture.xhtml
@@ -51,17 +51,17 @@ function framesetCallback(adjustment)
 {
   var newWidth = frames[1].frames[0].document.documentElement.clientWidth;
   var expectedWidth = originalWidth + adjustment;
   if (adjustment == 0)
     expectedWidth = originalWidth - 12;
   else if (expectedWidth >= 4000)
     expectedWidth = originalWidth * 2 - 2;
 
-  is(newWidth, expectedWidth, "frameset after drag (" + adjustment + ")");
+  ok(Math.abs(newWidth - expectedWidth) <= 1, "frameset after drag (" + adjustment + "), new width " + newWidth + ", expected " + expectedWidth);
 }
 
 var otherWindow = null;
 
 function selectionScrollCheck()
 {
   var element = otherWindow.document.documentElement;
 
@@ -90,17 +90,17 @@ function selectionScrollCheck()
     }
     else {
       // now try again, but open the page in a new window
       loadInWindow = true;
       synthesizeMouse(document.getElementById("custom"), 2, 2, { type: "mousedown" });
 
       // check to ensure that selection dragging scrolls the right scrollable area
       otherWindow = window.open("data:text/html,<html><p>One</p><p style='margin-top: 200px;'>Two</p><p style='margin-top: 4000px'>This is some text</p></html>", "_blank", "width=200,height=200,scrollbars=yes");
-      otherWindow.addEventListener("load", function() { SimpleTest.waitForFocus(selectionScrollCheck, otherWindow); }, false);
+      SimpleTest.waitForFocus(selectionScrollCheck, otherWindow);
     }
   }
 
   SimpleTest.executeSoon(function () {
     disableNonTestMouseEvents(true);
     synthesizeMouse(element, 2, 2, { type: "mousedown" }, otherWindow);
     synthesizeMouse(element, 100, otherWindow.innerHeight + 20, { type: "mousemove" }, otherWindow);
     otherWindow.addEventListener("scroll", selectionScrollDone, false);
@@ -149,21 +149,24 @@ function runTests()
   synthesizeMouse(custom6, 2, 2, { type: "mousedown" });
   synthesizeMouseExpectEvent($("leftbox"), 2, 2, { type: "mousemove" },
                              $("leftbox"), "mousemove", "setCapture only works on elements in documents");
   synthesizeMouse(custom6, 2, 2, { type: "mouseup" });
 
   // test that mousedown on an image with setCapture followed by a big enough
   // mouse move does not start a drag (bug 517737)
   var image = document.getElementById("image");
+  image.scrollIntoView();
   synthesizeMouse(image, 2, 2, { type: "mousedown" });
   synthesizeMouseExpectEvent($("leftbox"), 2, 2, { type: "mousemove" },
                              image, "mousemove", "setCapture works on images");
   synthesizeMouse(image, 2, 2, { type: "mouseup" });
 
+  window.scroll(0,0);
+
   // save scroll
   var scrollX = parent ? parent.scrollX : 0;
   var scrollY = parent ? parent.scrollY : 0;
 
   var b = frames[0].document.getElementById("b");
 //  runCaptureTest(b, selectionCallback);
 
   // restore scroll
@@ -184,30 +187,33 @@ function runTests()
   previousWidth = frames[1].frames[0].document.documentElement.clientWidth;
   originalWidth = previousWidth;
   runCaptureTest(frames[1].document.documentElement.lastChild, framesetCallback);
 
   // ensure that clicking on an element where the frame disappears doesn't crash
   synthesizeMouse(frames[2].document.getElementById("input"), 8, 8, { type: "mousedown" }, frames[2]);
   synthesizeMouse(frames[2].document.getElementById("input"), 8, 8, { type: "mouseup" }, frames[2]);
 
+  var select = document.getElementById("select");
+  select.scrollIntoView();
+
   synthesizeMouse(document.getElementById("option3"), 2, 2, { type: "mousedown" });
   synthesizeMouse(document.getElementById("option3"), 2, 1000, { type: "mousemove" });
-  var select = document.getElementById("select");
   is(select.selectedIndex, 2, "scroll select");
   synthesizeMouse(document.getElementById("select"), 2, 2, { type: "mouseup" });
+  window.scroll(0, 0);
 
   synthesizeMouse(custom, 2, 2, { type: "mousedown" });
 
   // check to ensure that selection dragging scrolls the right scrollable area.
   // This should open the page in a new tab.
 
   var topPos = window.innerHeight;
   otherWindow = window.open("data:text/html,<html><p>One</p><p style='margin-top: " + topPos + "'>Two</p><p style='margin-top: 4000px'>This is some text</p></html>", "_blank");
-  otherWindow.addEventListener("load", function() { SimpleTest.waitForFocus(selectionScrollCheck, otherWindow); }, false);
+  SimpleTest.waitForFocus(selectionScrollCheck, otherWindow);
 }
 
 function runCaptureTest(element, callback)
 {
   var expectedTarget = null;
 
   var win = element.ownerDocument.defaultView;