blob: e78aad4ae5940b27ebfeab9657321439b010246f [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<head>
<style>
.verticalGallery {
width: 100vw;
height: 600vh;
margin: 0;
padding: 0;
scroll-snap-type: y mandatory;
}
.colorBox {
height: 100vh;
width: 100vw;
float: left;
scroll-snap-align: start;
}
#item0 { background-color: red; }
#item1 { background-color: green; }
#item2 { background-color: blue; }
#item3 { background-color: aqua; }
#item4 { background-color: yellow; }
#item5 { background-color: fuchsia; }
</style>
<script src="../../../resources/js-test.js"></script>
<script>
window.jsTestIsAsync = true;
var scrollingTarget;
var scrollPositionBeforeGlide;
var scrollPositionBeforeSnap;
function checkForScrollSnap()
{
// The div should have snapped back to the previous position
if (scrollingTarget.scrollTop != scrollPositionBeforeSnap)
testFailed(`div did not snap back to proper location. (${scrollingTarget.scrollTop} vs. ${scrollPositionBeforeSnap})`);
else
testPassed("div honored snap points.");
finishJSTest();
}
function scrollSnapTest()
{
scrollPositionBeforeSnap = scrollingTarget.scrollTop;
var startPosX = scrollingTarget.offsetLeft + 20;
var startPosY = scrollingTarget.offsetTop + 20;
eventSender.monitorWheelEvents();
eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
eventSender.callAfterScrollingCompletes(checkForScrollSnap);
}
function checkForScrollGlide()
{
// The div should have scrolled (glided) to the next snap point.
if (scrollingTarget.scrollTop == window.innerHeight)
testPassed("div scrolled to next window.");
else
testFailed(`div did not honor snap points. (${scrollingTarget.scrollTop} vs. ${window.innerHeight})`);
setTimeout(scrollSnapTest, 0);
}
function scrollGlideTest()
{
scrollPositionBeforeGlide = scrollingTarget.scrollTop;
var startPosX = scrollingTarget.offsetLeft + 20;
var startPosY = scrollingTarget.offsetTop + 20;
eventSender.monitorWheelEvents();
eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -4, 'none', 'continue');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
eventSender.callAfterScrollingCompletes(checkForScrollGlide);
}
function onLoad()
{
scrollingTarget = document.scrollingElement;
if (window.eventSender) {
internals.setPlatformMomentumScrollingPredictionEnabled(false);
setTimeout(scrollGlideTest, 0);
} else {
var messageLocation = document.getElementById('item0');
var message = document.createElement('div');
message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
+ "inside the red region at the top of the page, and then use the mouse wheel or a two-finger swipe to make a<br/>"
+ "small swipe gesture with some momentum.<br/><br/>"
+ "The region should scroll to show a green region.<br/><br/>"
+ "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
+ "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
+ "that the region is a single color.<br/><br/>"
+ "You should also be able to repeat these test steps for the vertical region below.</p>";
messageLocation.appendChild(message);
}
}
</script>
</head>
<body onload="onLoad();" class="verticalGallery">
<div id="item0" class="colorBox"><div id="console"></div></div>
<div id="item1" class="colorBox"></div>
<div id="item2" class="colorBox"></div>
<div id="item3" class="colorBox"></div>
<div id="item4" class="colorBox"></div>
<div id="item5" class="colorBox"></div>
</body>
</html>