OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../js-test-resources/js-test.js"></script> | 4 <script src="../../js-test-resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <p id="description"></p> | 7 <p id="description"></p> |
8 <div id="console"></div> | 8 <div id="console"></div> |
9 | 9 |
10 <script> | 10 <script> |
11 description('Tests that popstate events fire when going back, even when there ar
e resource requests pending.'); | 11 description('Tests that popstate events fire when going back, even when there ar
e resource requests pending.'); |
12 | 12 |
13 onpopstate = function(event) | 13 window.onload = function() |
14 { | 14 { |
15 if (event.state) { | |
16 shouldBe('event.state', '"newState1"'); | |
17 // Stop the pending image request, otherwise the DRT doesn't consider th
e | |
18 // test over. | |
19 window.stop(); | |
20 finishJSTest(); | |
21 return; | |
22 } | |
23 | |
24 debug('Starting slow image request'); | 15 debug('Starting slow image request'); |
25 | 16 |
26 var slowImage = document.createElement('img'); | 17 var slowImage = document.createElement('img'); |
27 slowImage.src = 'resources/slow-image.php'; | 18 slowImage.src = 'resources/slow-image.php'; |
28 document.body.appendChild(slowImage); | 19 document.body.appendChild(slowImage); |
29 | 20 |
30 debug('Pushing newState1'); | 21 debug('Pushing newState1'); |
31 history.pushState('newState1', null, '?newState1'); | 22 history.pushState('newState1', null, '?newState1'); |
32 | 23 |
33 setTimeout(function() { | 24 setTimeout(function() { |
34 debug('Current search: ' + location.search); | 25 debug('Current search: ' + location.search); |
35 | 26 |
36 debug('Pushing newState2'); | 27 debug('Pushing newState2'); |
37 history.pushState('newState2', null, '?newState2'); | 28 history.pushState('newState2', null, '?newState2'); |
38 setTimeout(function() { | 29 setTimeout(function() { |
39 debug('Current search: ' + location.search); | 30 debug('Current search: ' + location.search); |
40 debug('Going back'); | 31 debug('Going back'); |
41 history.back(); | 32 history.back(); |
42 }, 0); | 33 }, 0); |
43 }, 0); | 34 }, 0); |
44 } | 35 } |
45 | 36 |
| 37 window.onpopstate = function(event) |
| 38 { |
| 39 shouldBe('event.state', '"newState1"'); |
| 40 // Stop the pending image request, otherwise the DRT doesn't consider the |
| 41 // test over. |
| 42 window.stop(); |
| 43 finishJSTest(); |
| 44 } |
46 | 45 |
47 var jsTestIsAsync = true; | 46 var jsTestIsAsync = true; |
48 </script> | 47 </script> |
49 | 48 |
50 </body> | 49 </body> |
51 </html> | 50 </html> |
OLD | NEW |