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