blob: a44f80fb342f72fcc01102becd17a9fd07cd7b84 [file] [edit]
<!-- webkit-test-runner [ UsesBackForwardCache=true ] -->
<head>
<style>
html {
font-size: 32pt;
}
</style>
<script src="resources/swipe-test.js"></script>
<script>
async function runTest()
{
// The first swipe should fail because we're scrolled to the middle of the document
// and this is all a single gesture. We can only start swipes if we *begin*
// pinned to the edge.
await startSwipeGesture();
await completeSwipeGesture();
window.localStorage["hasFinishedFirstSwipe"] = "YES";
// The second swipe should succeed because we are now scrolled to the left edge.
await startSwipeGesture();
await completeSwipeGesture();
}
function didBeginSwipeCallback()
{
if (window.localStorage["hasFinishedFirstSwipe"] == "YES")
log("didBeginSwipe");
else
log("Failure. Should not begin a swipe, because we were in the middle of a scrolling gesture that started when the main frame was not pinned to the left.");
}
function willEndSwipeCallback()
{
log("willEndSwipe");
shouldBe(false, isFirstPage(), "The swipe should not yet have navigated away from the second page.");
}
function didEndSwipeCallback()
{
log("didEndSwipe");
startMeasuringDuration("snapshotRemoval");
}
function didRemoveSwipeSnapshotCallback()
{
log("didRemoveSwipeSnapshot");
shouldBe(true, isFirstPage(), "The swipe should have navigated back to the first page.");
measuredDurationShouldBeLessThan("snapshotRemoval", 1000, "Because we're using the page cache, it shouldn't be long between the gesture completing and the snapshot being removed.")
testComplete();
}
function isFirstPage()
{
return window.location.href.indexOf("second") == -1;
}
window.onload = async function () {
if (!window.eventSender || !window.testRunner) {
document.getElementById("large").innerHTML = "This test must be run in WebKitTestRunner.";
return;
}
document.getElementById("large").innerHTML = isFirstPage() ? "first" : "second";
if (window.testRunner) {
testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback);
}
if (isFirstPage()) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
await initializeSwipeTest();
window.localStorage["hasFinishedFirstSwipe"] = "NO";
setTimeout(function () {
window.location.href = window.location.href + "?second";
}, 0);
return;
}
// Second page loaded.
window.scrollTo(100, 0);
await runTest();
};
</script>
</head>
<body>
<div id="large" style="width: 2000px; height: 2000px;"></div>
</body>