Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / forms / submit-to-blank-multiple-times.html
1 <!DOCTYPE html>
2 <html>
3     <body>
4         <p>
5             Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=28633">Bug 28633 - Submitting a form with target=_blank works only once</a>
6         </p>
7         <p>
8             This test will click the first submit button twice, then press the space bar on the second submit button twice. Both should popup two blank windows.
9         </p>
10         <form action="resources/submit-to-blank-multiple-times-form-action.html" target="_blank">
11             <input name="nextOp" id="nextOp" type="hidden">
12             <input name="submit" id="submit" type="submit">
13         </form>
14         <form action="resources/submit-to-blank-multiple-times-form-action.html" target="_blank">
15             <input name="nextOp" id="nextOpKey" type="hidden">
16             <input name="submit" id="submitKey" type="submit">
17         </form>
18         <div id="console"></div>
19         <script type="text/javascript">
20         if (window.testRunner) {
21             testRunner.dumpAsText();
22             testRunner.setCanOpenWindows();
23             testRunner.waitUntilDone();
24         }
25         var numberTimesToClick = 2;
26         var numberTimesToSpace = 2;
27         window.onload = function() {
28             if (!window.testRunner || !window.eventSender)
29                 return;
30             
31             click();
32             // Set a timeout to notify done in case the test fails.
33             setTimeout(notifyDone, 2000);
34         };
35         function log(message) {
36             var span = document.createElement("span");
37             span.innerHTML = message + "<br>";
38             document.getElementById("console").appendChild(span);
39         }
40         function click() {
41             log("Clicking first button, should open new window");
42             var button = document.getElementById("submit");
43             var x = button.offsetLeft + button.offsetWidth/2;
44             var y = button.offsetTop + button.offsetHeight/2;
45             
46             numberTimesToClick--;
47             if (numberTimesToClick > 0)
48                 document.getElementById("nextOp").value = "click";
49             else
50                 document.getElementById("nextOp").value = "space";
51             eventSender.mouseMoveTo(x, y);
52             eventSender.mouseDown();
53             eventSender.mouseUp();
54         }
55         function pressSpace() {
56             log("Pressing space on second button, should open new window");
57             var button = document.getElementById("submitKey");
58             
59             numberTimesToSpace--;
60             if (numberTimesToSpace > 0)
61                 document.getElementById("nextOpKey").value = "space";
62             else
63                 document.getElementById("nextOpKey").value = "notifyDone";
64             button.focus();
65             eventSender.keyDown(' ');
66         }
67         function notifyDone() {
68             testRunner.setCloseRemainingWindowsWhenComplete();
69             testRunner.notifyDone();
70         }
71         </script>
72     </body>
73 </html>