OLD | NEW |
1 <script> | 1 <script> |
2 window.onload = function () | 2 window.onload = function () |
3 { | 3 { |
4 if (window.testRunner) { | 4 if (window.testRunner) { |
5 testRunner.dumpAsText(); | 5 testRunner.dumpAsText(); |
6 testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(true); | 6 testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(true); |
7 testRunner.waitUntilDone(); | 7 testRunner.waitUntilDone(); |
8 } | 8 } |
| 9 // JavaScript onbeforeunload dialogs require a user gesture. |
| 10 if (window.eventSender) { |
| 11 eventSender.mouseMoveTo(5, 5); |
| 12 eventSender.mouseDown(); |
| 13 eventSender.mouseUp(); |
| 14 } |
9 if (sessionStorage.fail) { | 15 if (sessionStorage.fail) { |
10 if (window.testRunner) | 16 if (window.testRunner) |
11 testRunner.notifyDone(); | 17 testRunner.notifyDone(); |
12 return; | 18 return; |
13 } | 19 } |
14 | 20 |
15 location = location.href + '?done'; | 21 location = location.href + '?done'; |
16 window.setTimeout(passTest, 0); | 22 window.setTimeout(passTest, 0); |
17 }; | 23 }; |
18 window.onbeforeunload = function () | 24 window.onbeforeunload = function () |
19 { | 25 { |
20 if (sessionStorage.fail) | 26 if (sessionStorage.fail) |
21 return; | 27 return; |
22 sessionStorage.fail = true; | 28 sessionStorage.fail = true; |
23 location.reload(); | 29 location.reload(); |
24 return ""; | 30 return ""; |
25 }; | 31 }; |
26 function passTest() | 32 function passTest() |
27 { | 33 { |
28 document.getElementById('status').textContent = 'PASS'; | 34 document.getElementById('status').textContent = 'PASS'; |
29 if (window.testRunner) | 35 if (window.testRunner) |
30 testRunner.notifyDone(); | 36 testRunner.notifyDone(); |
31 } | 37 } |
32 </script> | 38 </script> |
33 <body> | 39 <body> |
34 This test passes if the FAIL changes to PASS after clicking "Stay on this page". | 40 This test passes if the FAIL changes to PASS after clicking "Stay on this page". |
35 | 41 |
36 <div id="status">FAIL</div> | 42 <div id="status">FAIL</div> |
37 </body> | 43 </body> |
OLD | NEW |