OLD | NEW |
1 <script> | 1 <script> |
2 onload = function() { | 2 onload = function() { |
3 setTimeout(function() { | 3 setTimeout(function() { |
4 // Start to go back (runs asynchonously) | 4 // Start to go back (runs asynchonously) |
5 history.back(); | 5 history.back(); |
6 // But immediately cancel that load of a history item and navigate to | 6 // But immediately cancel that load of a history item and navigate to |
7 // a fragment on the page instead. We should remain on this page and | 7 // a fragment on the page instead. We should remain on this page and |
8 // a history item should be added (with past ones not being affected) | 8 // a history item should be added (with past ones not being affected) |
9 setTimeout(function(){window.location = '#foo'}, 0); | 9 setTimeout(function(){window.location = '#foo'}, 0); |
10 }, 0); | 10 }, 0); |
11 } | 11 } |
12 | 12 |
13 onhashchange = function() { | 13 onhashchange = function() { |
14 setTimeout(done, 100); | 14 setTimeout(done, 100); |
15 } | 15 } |
16 | 16 |
17 function done() { | 17 function done() { |
18 delete sessionStorage.didNavigate; | 18 delete sessionStorage.didNavigate; |
19 console.log('Visited fragment and waited.'); | 19 console.log('Visited fragment and waited.'); |
20 if (window.layoutTestController) { | 20 if (window.layoutTestController) { |
21 layoutTestController.notifyDone(); | 21 layoutTestController.notifyDone(); |
22 } | 22 } |
23 } | 23 } |
24 </script> | 24 </script> |
25 PASS | 25 PASS |
OLD | NEW |