| Index: LayoutTests/fast/loader/scroll-position-not-restored-for-history-api.html
|
| diff --git a/LayoutTests/fast/loader/scroll-position-not-restored-for-history-api.html b/LayoutTests/fast/loader/scroll-position-not-restored-for-history-api.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5b331fba1288790f2f98cc86be79fa24899eb070
|
| --- /dev/null
|
| +++ b/LayoutTests/fast/loader/scroll-position-not-restored-for-history-api.html
|
| @@ -0,0 +1,51 @@
|
| +<!DOCTYPE html>
|
| +<style>
|
| +body {
|
| + height: 2000px;
|
| + width: 2000px;
|
| +}
|
| +</style>
|
| +
|
| +<div id='console'></div>
|
| +<script src="../../resources/js-test.js"></script>
|
| +<script>
|
| +window.jsTestIsAsync = true;
|
| +description('This test verifies that navigating to entries created by ' +
|
| + 'pushState or replaceState does not restore scroll position.');
|
| +
|
| +// Navigation steps:
|
| +// 1. Create a history entry using pushState then scroll
|
| +// 2. Create a history entry and replace it then scroll
|
| +// 3. Navigate away and come back to #2 and verify
|
| +// 4. Navigate back one more time to #1 and verify
|
| +function handleNavigation() {
|
| + if (window.name !== 'verification phase') {
|
| + history.pushState({}, "", "#1");
|
| + window.scrollBy(50, 100);
|
| +
|
| + history.pushState({}, "", "#2");
|
| + history.replaceState({foo: 'bar'}, "", "#2");
|
| + window.scrollBy(50, 100);
|
| +
|
| + setTimeout(function() {
|
| + window.name = 'verification phase';
|
| + window.location.href = 'resources/empty-document-goes-back.html';
|
| + }, 0);
|
| + } else {
|
| + // The scroll position should not be restored
|
| + debug('verifying ' + location.hash);
|
| + shouldBe('document.body.scrollTop', '0');
|
| + shouldBe('document.body.scrollLeft', '0');
|
| +
|
| + if (location.hash === '#2') {
|
| + window.history.back();
|
| + } else {
|
| + window.name = "";
|
| + finishJSTest();
|
| + }
|
| + }
|
| +}
|
| +
|
| +window.addEventListener('pageshow', handleNavigation);
|
| +window.addEventListener('hashchange', handleNavigation);
|
| +</script>
|
|
|