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 289591 3dc5292ed66afbca801c33bff49c86154b3b3c24
parent 289590 3169edcea9d93557be4168312fb784e86706d944
child 289592 93955ff309b7710a910003b067433eb4e67aa742
push id30107
push usercbook@mozilla.com
push dateTue, 22 Mar 2016 10:00:23 +0000
treeherdermozilla-central@3587b25bae30 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin
bugs1254091
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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;