| OLD | NEW |
| 1 <script> | 1 <script> |
| 2 if (window.testRunner) { | 2 if (window.testRunner) { |
| 3 testRunner.waitUntilDone(); | 3 testRunner.waitUntilDone(); |
| 4 testRunner.dumpAsText(); | 4 testRunner.dumpAsText(); |
| 5 testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(true); | 5 testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(true); |
| 6 } | 6 } |
| 7 | 7 |
| 8 _confirmationDialogDisplayedOnce = false; | 8 _confirmationDialogDisplayedOnce = false; |
| 9 | 9 |
| 10 window.addEventListener("beforeunload", function() { | 10 window.onbeforeunload = function() { |
| 11 | 11 |
| 12 if (window._confirmationDialogDisplayedOnce) | 12 if (window._confirmationDialogDisplayedOnce) |
| 13 return "Click 'Leave Page'"; | 13 return "Click 'Leave Page'"; |
| 14 | 14 |
| 15 window.setTimeout(function() { | 15 window.setTimeout(function() { |
| 16 if (window.testRunner) | 16 if (window.testRunner) |
| 17 testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(false); | 17 testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(false); |
| 18 | 18 |
| 19 window.setTimeout(function() { | 19 window.setTimeout(function() { |
| 20 document.getElementById("console").innerHTML = "FAIL"; | 20 document.getElementById("console").innerHTML = "FAIL"; |
| 21 if (window.testRunner) | 21 if (window.testRunner) |
| 22 testRunner.notifyDone(); | 22 testRunner.notifyDone(); |
| 23 }, 1000); | 23 }, 1000); |
| 24 | 24 |
| 25 document.forms[0].submit(); | 25 document.forms[0].submit(); |
| 26 }, 0); | 26 }, 0); |
| 27 | 27 |
| 28 window._confirmationDialogDisplayedOnce = true; | 28 window._confirmationDialogDisplayedOnce = true; |
| 29 | 29 |
| 30 return "Click 'Stay on Page'"; | 30 return "Click 'Stay on Page'"; |
| 31 }); | 31 }; |
| 32 </script> | 32 </script> |
| 33 | 33 |
| 34 <p>This tests that submitting a form a second time after canceling the first sub
mission in a onbeforeunload handler is allowed. To test manually, follow the ins
tructions in the JavaScript confirmation dialogs.</p> | 34 <p>This tests that submitting a form a second time after canceling the first sub
mission in a onbeforeunload handler is allowed. To test manually, follow the ins
tructions in the JavaScript confirmation dialogs.</p> |
| 35 | 35 |
| 36 <div id="console"></div> | 36 <div id="console"></div> |
| 37 | 37 |
| 38 <form action="resources/pass-and-notify-done.html" method="POST"> | 38 <form action="resources/pass-and-notify-done.html" method="POST"> |
| 39 </form> | 39 </form> |
| 40 | 40 |
| 41 <script> | 41 <script> |
| 42 document.forms[0].submit(); | 42 document.forms[0].submit(); |
| 43 </script> | 43 </script> |
| OLD | NEW |