OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 #content { |
| 4 height: 2000px; |
| 5 width: 2000px; |
| 6 } |
| 7 </style> |
| 8 |
| 9 <div id='console'></div> |
| 10 <div id='content'></div> |
| 11 |
| 12 <script src="../../resources/js-test.js"></script> |
| 13 <script> |
| 14 jsTestIsAsync = true; |
| 15 setPrintTestResultsLazily(); |
| 16 description('Test ensures that frame scroll position is only restored during ' + |
| 17 'the navigation process but does not occur after navigation is ' + |
| 18 'complete for same document navigations.'); |
| 19 |
| 20 window.scrollTo(100, 100); |
| 21 history.pushState(null, null, '#test'); |
| 22 |
| 23 window.addEventListener('hashchange', _ => { |
| 24 // after back navigation scroll position should be restored to 100,100. |
| 25 debug('Verify that scroll position restored correctly during navigation.'); |
| 26 shouldBe('document.scrollingElement.scrollLeft', '100'); |
| 27 shouldBe('document.scrollingElement.scrollTop', '100'); |
| 28 |
| 29 // trigger a content size change that should cause the scroll position |
| 30 // to get clamped to 0,0. |
| 31 document.getElementById('content').style.display = 'none'; |
| 32 shouldBe('document.scrollingElement.scrollLeft', '0'); |
| 33 shouldBe('document.scrollingElement.scrollTop', '0'); |
| 34 |
| 35 // trigger another content size change and verify that scroll position is |
| 36 // not restored. |
| 37 debug('Verify that scroll position is not restored again after navigation is c
omplete.'); |
| 38 document.getElementById('content').style.display = 'block'; |
| 39 shouldBe('document.scrollingElement.scrollLeft', '0'); |
| 40 shouldBe('document.scrollingElement.scrollTop', '0'); |
| 41 |
| 42 finishJSTest(); |
| 43 }); |
| 44 |
| 45 setTimeout(_ => { |
| 46 window.scrollTo(0, 0); |
| 47 shouldBe('document.scrollingElement.scrollLeft', '0'); |
| 48 shouldBe('document.scrollingElement.scrollTop', '0'); |
| 49 history.back(); |
| 50 }, 0); |
| 51 </script> |
OLD | NEW |