Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/events/middleClickAutoscroll-layoutObject.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/events/middleClickAutoscroll-layoutObject.html b/third_party/WebKit/LayoutTests/fast/events/middleClickAutoscroll-layoutObject.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4f0bf6b1899e616f868be576fbf2f6b3b29f184e |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/events/middleClickAutoscroll-layoutObject.html |
| @@ -0,0 +1,95 @@ |
| +<!DOCTYPE html> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<div id = "div" style="overflow: auto; width: 1400px"> |
| +<table style="height:2000px; width: 1800px"> |
| + <tbody> |
| + <tr style="height: 2000px"> |
| + <td id="td" style="width: 600px; height: 2000px"></td> |
| + <td id="iframe" style="width: 1200px; height: 2000px"> |
| + <iframe style="width: 1000px; height: 2000px" src="resources/middleClickAutoscroll-iframe.html"></iframe> |
| + </td> |
| + </tr> |
| + </tbody> |
| +</table> |
| +</div> |
| +<script> |
| +var testBubble = async_test("Tests that middleClickAutoscroll finds the correct ancestor layoutobject when starting in an unscrollable direction.") |
| +testBubble.step(function() { |
| + if (!window.eventSender) |
| + return; |
| + var td = document.getElementById("td"); |
| + // Start a downward middle-click-autoscroll in the left td element. |
| + var startx = td.getBoundingClientRect().left + 100; |
| + var starty = td.getBoundingClientRect().top + 100; |
| + var endx = startx; |
| + var endy = starty + 100; |
| + eventSender.mouseMoveTo(startx, starty); |
| + eventSender.mouseDown(1); |
| + eventSender.mouseMoveTo(endx, endy) |
| + |
| + var animationFrameCount = 0; |
| + var animation = function () { |
| + animationFrameCount++; |
| + if (animationFrameCount == 160) { |
| + testIFrame(); |
| + testBubble.done(); |
| + return; |
| + } |
| + if (animationFrameCount == 60) { |
| + var div = document.getElementById("div"); |
| + assert_not_equals(window.scrollX, 0); |
| + assert_equals(div.scrollLeft, 0); |
| + eventSender.mouseUp(1); |
| + } |
| + if (animationFrameCount == 30) { |
|
bokan
2016/11/11 19:48:45
Why do these constants have to be so high? Shouldn
|
| + assert_not_equals(window.scrollY, 0); |
| + // Change the direction of the middle-click-autoscroll to rightward. |
| + endx = startx + 100; |
| + endy = starty; |
| + eventSender.mouseMoveTo(endx, endy) |
| + } |
| + window.requestAnimationFrame(animation); |
| + }; |
| + window.requestAnimationFrame(animation); |
| +}); |
| + |
| +function testIFrame() { |
| +var testIFrame = async_test("Tests that middleClickAutoscroll finds the correct ancestor layoutobject when starting in an iframe, and the latching is correctly implemented.") |
| +testIFrame.step(function() { |
| + if (!window.eventSender) |
| + return; |
| + var iframe = document.getElementById("iframe"); |
| + // Start a rightward middle-click-autoscroll in the iframe inside the right |
| + // td element. |
| + var startx = Math.max(iframe.getBoundingClientRect().left, 10); |
| + var starty = Math.max(iframe.getBoundingClientRect().top, 500); |
| + var endx = startx + 100; |
| + var endy = starty; |
| + var pageScrollTop = window.scrollY; |
| + eventSender.mouseMoveTo(startx, starty); |
| + eventSender.mouseDown(1); |
| + eventSender.mouseMoveTo(endx, endy); |
| + |
| + var animationFrameCount = 0; |
| + var animation = function () { |
| + animationFrameCount++; |
| + if (animationFrameCount == 30) { |
| + var div = document.getElementById("div"); |
| + assert_not_equals(div.scrollLeft, 0); |
| + // Change the direction of the middle-click-autoscroll to upward. |
| + endx = startx; |
| + endy = starty - 100; |
| + eventSender.mouseMoveTo(endx, endy); |
| + } |
| + if (animationFrameCount == 60) { |
| + assert_equals(window.scrollY, pageScrollTop); |
| + testIFrame.done(); |
| + return; |
| + } |
| + window.requestAnimationFrame(animation); |
| + }; |
| + window.requestAnimationFrame(animation); |
| +}); |
| +} |
| +</script> |