87 lines
2.0 KiB
HTML
87 lines
2.0 KiB
HTML
<!-- webkit-test-runner [ UsesBackForwardCache=true ] -->
|
|
<head>
|
|
<style>
|
|
html {
|
|
font-size: 32pt;
|
|
}
|
|
</style>
|
|
<script src="resources/swipe-test.js"></script>
|
|
<script>
|
|
|
|
function didBeginSwipeCallback()
|
|
{
|
|
log("didBeginSwipe");
|
|
|
|
completeSwipeGesture();
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
function updateContent()
|
|
{
|
|
document.body.innerHTML = isFirstPage() ? "first" : "second";
|
|
}
|
|
|
|
window.onload = function () {
|
|
if (!window.eventSender || !window.testRunner) {
|
|
document.body.innerHTML = "This test must be run in WebKitTestRunner.";
|
|
return;
|
|
}
|
|
|
|
updateContent();
|
|
|
|
initializeSwipeTest();
|
|
|
|
testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
|
|
testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
|
|
testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
|
|
testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback);
|
|
|
|
testRunner.dumpAsText();
|
|
testRunner.waitUntilDone();
|
|
|
|
window.addEventListener("popstate", function(e) {
|
|
updateContent();
|
|
});
|
|
|
|
setTimeout(function () {
|
|
history.pushState(null, null, "/second");
|
|
updateContent();
|
|
|
|
setTimeout(function () {
|
|
startSwipeGesture();
|
|
}, 0);
|
|
}, 0);
|
|
};
|
|
</script>
|
|
</head>
|
|
<body>
|
|
</body>
|