OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <style> | 2 <style> |
3 body { | 3 body { |
4 height: 2000px; | 4 height: 2000px; |
5 width: 2000px; | 5 width: 2000px; |
6 } | 6 } |
7 </style> | 7 </style> |
8 | 8 |
9 <div id='console'></div> | 9 <div id='console'></div> |
10 <script src="../../resources/js-test.js"></script> | 10 <script src="../../resources/js-test.js"></script> |
(...skipping 17 matching lines...) Expand all Loading... |
28 // 1. Create a history entry using pushState then scroll | 28 // 1. Create a history entry using pushState then scroll |
29 // 2. Create a history entry and replace it then scroll | 29 // 2. Create a history entry and replace it then scroll |
30 // 3-6. Repeat 1 & 2 with different option values | 30 // 3-6. Repeat 1 & 2 with different option values |
31 // 7. Navigate away and come back | 31 // 7. Navigate away and come back |
32 // 8-13. Verify 6 to 1 and keep navigating back | 32 // 8-13. Verify 6 to 1 and keep navigating back |
33 function handleNavigation() { | 33 function handleNavigation() { |
34 if (window.name !== 'verification phase') { | 34 if (window.name !== 'verification phase') { |
35 for (var key in tests) { | 35 for (var key in tests) { |
36 var test = tests[key]; | 36 var test = tests[key]; |
37 var args = [{key: key}, '', key]; | 37 var args = [{key: key}, '', key]; |
38 if ('options' in test) | |
39 args.push(test.options); | |
40 | 38 |
41 if (test.type == 'push') { | 39 if (test.type == 'push') { |
42 history.pushState.apply(history, args); | 40 history.pushState.apply(history, args); |
43 } else { | 41 } else { |
44 history.pushState(null, '', key); | 42 history.pushState(null, '', key); |
45 history.replaceState.apply(history, args); | 43 history.replaceState.apply(history, args); |
46 } | 44 } |
47 | 45 |
| 46 if ('options' in test) |
| 47 history.scrollRestoration = test.options.scrollRestoration; |
| 48 |
48 window.scrollBy(50, 100); | 49 window.scrollBy(50, 100); |
49 } | 50 } |
50 | 51 |
51 setTimeout(function() { | 52 setTimeout(function() { |
52 window.name = 'verification phase'; | 53 window.name = 'verification phase'; |
53 window.location.href = 'resources/empty-document-goes-back.html'; | 54 window.location.href = 'resources/empty-document-goes-back.html'; |
54 }, 0); | 55 }, 0); |
55 } else { | 56 } else { |
56 var key = location.hash, | 57 var key = location.hash, |
57 test = tests[key]; | 58 test = tests[key]; |
58 | 59 |
59 debug('verifying ' + key); | 60 debug('verifying ' + key); |
60 shouldBeEqualToString('history.state.key', '' + key); | 61 shouldBeEqualToString('history.state.key', '' + key); |
61 shouldBe('document.scrollingElement.scrollLeft', test.expectedScroll[0].toSt
ring()); | 62 shouldBe('document.scrollingElement.scrollLeft', test.expectedScroll[0].toSt
ring()); |
62 shouldBe('document.scrollingElement.scrollTop', test.expectedScroll[1].toStr
ing()); | 63 shouldBe('document.scrollingElement.scrollTop', test.expectedScroll[1].toStr
ing()); |
63 | 64 |
64 if (key !== '#1') { | 65 if (key !== '#1') { |
65 window.history.back(); | 66 window.history.back(); |
66 } else { | 67 } else { |
67 window.name = ''; | 68 window.name = ''; |
68 finishJSTest(); | 69 finishJSTest(); |
69 } | 70 } |
70 } | 71 } |
71 } | 72 } |
72 | 73 |
73 window.addEventListener('pageshow', handleNavigation); | 74 window.addEventListener('pageshow', handleNavigation); |
74 window.addEventListener('hashchange', handleNavigation); | 75 window.addEventListener('hashchange', handleNavigation); |
75 </script> | 76 </script> |
OLD | NEW |