blob: 09d068d79d261a9c1747ef1af9a610926900c20e [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script>
var expectedScrollTop = 5;
var expectedScrollLeft = 3;
var pixelsPerWheelTick = 40;
var event;
var div;
jsTestIsAsync = true;
function dispatchWheelEvent()
{
if (!window.eventSender) {
finishJSTest();
return;
}
var overflowElement = document.getElementById("overflow");
if (overflowElement)
overflowElement.addEventListener("mousewheel", mousewheelHandler, false);
eventSender.mouseMoveTo(100, 110);
eventSender.monitorWheelEvents();
eventSender.mouseScrollBy(-expectedScrollLeft, -expectedScrollTop);
eventSender.callAfterScrollingCompletes(checkOffsets);
}
function checkOffsets()
{
div = document.getElementById("overflow");
shouldBe("div.scrollTop", "expectedScrollTop * pixelsPerWheelTick");
shouldBe("div.scrollLeft", "expectedScrollLeft * pixelsPerWheelTick");
finishJSTest();
}
function mousewheelHandler(e)
{
event = e;
shouldBe("event.wheelDeltaY", "expectedScrollTop * -120");
shouldBe("event.wheelDeltaX", "expectedScrollLeft * -120");
if (e.wheelDeltaY)
shouldBe("event.wheelDelta", "expectedScrollTop * -120");
else
shouldBe("event.wheelDelta", "expectedScrollLeft * -120");
}
window.addEventListener('load', () => {
setTimeout(dispatchWheelEvent, 0);
}, false);
</script>
</head>
<body style="margin:0">
<div id="overflow" style="border:2px solid black;overflow:auto;height:200px;width:200px;">
<div style="background-color:red;height:200px;width:400px;"></div>
<div style="background-color:green;height:200px;width:400px;"></div>
<div style="background-color:red;height:200px;width:400px;"></div>
</div>
<div id="console"></div>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>