summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/submit-to-blank-multiple-times.html
blob: 6d82177966a91d6615f6c283797c9bff32fbb082 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
    <body>
        <p>
            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>
        </p>
        <p>
            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.
        </p>
        <form action="resources/submit-to-blank-multiple-times-form-action.html" target="_blank">
            <input name="nextOp" id="nextOp" type="hidden">
            <input name="submit" id="submit" type="submit">
        </form>
        <form action="resources/submit-to-blank-multiple-times-form-action.html" target="_blank">
            <input name="nextOp" id="nextOpKey" type="hidden">
            <input name="submit" id="submitKey" type="submit">
        </form>
        <div id="console"></div>
        <script type="text/javascript">
        if (window.testRunner) {
            testRunner.dumpAsText();
            testRunner.setCanOpenWindows();
            testRunner.waitUntilDone();
        }
        var numberTimesToClick = 2;
        var numberTimesToSpace = 2;
        window.onload = function() {
            if (!window.testRunner || !window.eventSender)
                return;
            
            click();
            // Set a timeout to notify done in case the test fails.
            setTimeout(notifyDone, 2000);
        };
        function log(message) {
            var span = document.createElement("span");
            span.innerHTML = message + "<br>";
            document.getElementById("console").appendChild(span);
        }
        function click() {
            log("Clicking first button, should open new window");
            var button = document.getElementById("submit");
            var x = button.offsetLeft + button.offsetWidth/2;
            var y = button.offsetTop + button.offsetHeight/2;
            
            numberTimesToClick--;
            if (numberTimesToClick > 0)
                document.getElementById("nextOp").value = "click";
            else
                document.getElementById("nextOp").value = "space";
            eventSender.mouseMoveTo(x, y);
            eventSender.mouseDown();
            eventSender.mouseUp();
        }
        function pressSpace() {
            log("Pressing space on second button, should open new window");
            var button = document.getElementById("submitKey");
            
            numberTimesToSpace--;
            if (numberTimesToSpace > 0)
                document.getElementById("nextOpKey").value = "space";
            else
                document.getElementById("nextOpKey").value = "notifyDone";
            button.focus();
            eventSender.keyDown(' ');
        }
        function notifyDone() {
            testRunner.setCloseRemainingWindowsWhenComplete();
            testRunner.notifyDone();
        }
        </script>
    </body>
</html>