65 lines
1.6 KiB
HTML
65 lines
1.6 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
<style>
|
|
body {
|
|
height: 2000px;
|
|
width: 2000px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
var jsTestIsAsync = true;
|
|
|
|
description("Tests that history.scrollRestoration works for same-document navigations");
|
|
|
|
if (window.testRunner)
|
|
testRunner.clearBackForwardList();
|
|
|
|
shouldBeTrue("'scrollRestoration' in history");
|
|
|
|
// Can't create history entries inside the onload handler.
|
|
window.setTimeout(testAutoScrollRestoration, 0);
|
|
|
|
function testAutoScrollRestoration()
|
|
{
|
|
history.scrollRestoration = 'auto';
|
|
shouldBeEqualToString('history.scrollRestoration', 'auto');
|
|
|
|
window.scrollTo(123, 456);
|
|
history.pushState(null, '', '#1');
|
|
window.scrollTo(0, 0);
|
|
history.back();
|
|
|
|
window.setTimeout(function () {
|
|
shouldBe('window.scrollX', '123');
|
|
shouldBe('window.scrollY', '456');
|
|
|
|
testManualScrollRestoration();
|
|
}, 0);
|
|
}
|
|
|
|
function testManualScrollRestoration()
|
|
{
|
|
history.scrollRestoration = 'manual';
|
|
shouldBeEqualToString('history.scrollRestoration', 'manual');
|
|
|
|
window.scrollTo(234, 567);
|
|
history.pushState(null, '', '#2');
|
|
window.scrollTo(333, 555);
|
|
history.back();
|
|
|
|
window.setTimeout(function() {
|
|
shouldBe('window.scrollX', '333');
|
|
shouldBe('window.scrollY', '555');
|
|
window.scrollTo(0, 0);
|
|
finishJSTest();
|
|
}, 0);
|
|
}
|
|
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|