Chromium Code Reviews| Index: LayoutTests/http/tests/navigation/same-document-scroll-position-restore-pushstate.html |
| diff --git a/LayoutTests/http/tests/navigation/same-document-scroll-position-restore-pushstate.html b/LayoutTests/http/tests/navigation/same-document-scroll-position-restore-pushstate.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1b1a816bfe5a544947e2745bfa7ecabf2ff7b772 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/navigation/same-document-scroll-position-restore-pushstate.html |
| @@ -0,0 +1,53 @@ |
| +<body> |
| +<script src="../../../resources/js-test.js"></script> |
| +<div style="height: 1100px">scroll down...</div> |
| +<button id="a">Push State</button> |
| +<button id="b">Back</button> |
| +<div id="log"></div> |
| +<script> |
| +if (window.testRunner) { |
| + testRunner.dumpAsText(); |
| + testRunner.waitUntilDone(); |
| +} |
| + |
| +function pushBrowserState() |
| +{ |
| + history.pushState({}, '', window.location.href.split("#")[0] + "#a"); |
| +} |
| + |
| +function back() |
| +{ |
| + scrollOffsetY = window.scrollY; |
| + history.back(); |
| + setTimeout(function() { |
| + document.getElementById('log').innerHTML = 'scrollY should be ' + scrollOffsetY + ': ' + (window.scrollY == scrollOffsetY ? "PASS" : "FAIL"); |
| + if (window.testRunner) |
| + testRunner.notifyDone(); |
| + }, 10); |
|
Nate Chapin
2015/04/06 17:17:15
Is the 10ms delay required here? Could we get away
Abhijeet Kandalkar Slow
2015/04/07 08:14:49
Done. Code is removed.
|
| +} |
| + |
| +window.onload = function() { |
| + if (window.eventSender) { |
| + var ele = document.getElementById("a"); |
| + ele.addEventListener('click', pushBrowserState, false); |
| + window.scrollBy(0, 1000); |
| + |
| + // Click 'Push State' button twice |
|
Nate Chapin
2015/04/06 17:17:15
Does this test work with direct history.pushState(
Abhijeet Kandalkar Slow
2015/04/07 08:14:49
Done. eventSender dependency is removed.
|
| + var rect = ele.getBoundingClientRect(); |
| + eventSender.mouseMoveTo(rect.left + 2, rect.top + 2); |
| + eventSender.mouseDown(); |
| + eventSender.mouseUp(); |
| + eventSender.mouseDown(); |
| + eventSender.mouseUp(); |
| + |
| + // Click 'Back' button |
| + ele = document.getElementById("b"); |
| + ele.addEventListener('click', back, false); |
| + rect = ele.getBoundingClientRect(); |
| + eventSender.mouseMoveTo(rect.left + 2, rect.top + 2); |
| + eventSender.mouseDown(); |
| + eventSender.mouseUp(); |
| + } |
| +}; |
| +</script> |
| +</body> |