OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 body { |
| 4 height: 2000px; |
| 5 width: 2000px; |
| 6 } |
| 7 |
| 8 #fragment { |
| 9 position: absolute; |
| 10 top: 800px; |
| 11 background-color: #faa; |
| 12 display: block; |
| 13 height: 100px; |
| 14 width: 100px; |
| 15 } |
| 16 </style> |
| 17 |
| 18 <body> |
| 19 <a id="fragment" name="fragment" class='box'></a> |
| 20 </body> |
| 21 |
| 22 <script src="../../../resources/testharness.js"></script> |
| 23 <script src="../../../resources/testharnessreport.js"></script> |
| 24 <script type="text/javascript"> |
| 25 'use strict'; |
| 26 |
| 27 async_test(function(t) { |
| 28 history.scrollRestoration = 'manual'; |
| 29 assert_equals(history.scrollRestoration, 'manual'); |
| 30 |
| 31 location.hash = '#fragment'; |
| 32 assert_equals(window.scrollY, 800, 'new navigations should scroll to fragmen
t'); |
| 33 |
| 34 // create a new entry and reset the scroll before verification |
| 35 history.pushState(null, null, '#done'); |
| 36 window.scrollTo(0, 0); |
| 37 assert_equals(window.scrollY, 0, 'should reset scroll before verification'); |
| 38 |
| 39 setTimeout(function() { |
| 40 // setup verification |
| 41 window.addEventListener('hashchange', t.step_func(function() { |
| 42 assert_equals(location.hash, '#fragment'); |
| 43 assert_equals(history.scrollRestoration, 'manual'); |
| 44 // navigating back should give precedent to history restoration which is
'manual' |
| 45 assert_equals(window.scrollX, 0, 'should not scroll to fragment'); |
| 46 assert_equals(window.scrollY, 0, 'should not scroll to fragment'); |
| 47 t.done(); |
| 48 })); |
| 49 // kick off verification |
| 50 window.history.back(); |
| 51 }, 0); |
| 52 |
| 53 }, 'scrollRestoration takes precedent over scrolling to fragment'); |
| 54 </script> |
OLD | NEW |