summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/multiple-form-submission-protection-mouse.html
blob: e88f6e5798547ae6cbc2380edaa7f2a169213d38 (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
<html>
<head>
<script>

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.setCanOpenWindows();
    testRunner.waitUntilDone();
}

addEventListener('message', function(e) {
    simulateClick('button2');
}, false);

function runTest()
{
    if (!eventSender)
        return;

    simulateClick('button1');
}

function simulateClick(id)
{
    var rect = document.getElementById(id).getBoundingClientRect();
    eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
    eventSender.mouseDown();
    eventSender.mouseUp();
}

function submitTo(target)
{
    document.test.target = target;
    document.test.submit();
}

</script>
</head>
<body onload="runTest()">
<p>This test ensures that multiple form submission protection is correctly reset on mouse events. To test manually:
<ol>
<li>Click on "Click 1" to submit form to a new window. The window will close immediately.
<li>Click on "Click 2" to submit form to this window. Single word "SUCCESS" should replace the contents of this document.
</ol>
<p>If either event doesn't occur, the test has failed.
<form method="post" name="test" action="data:text/html,<script>if (opener) { opener.postMessage('trololo', '*'); window.close(); } else { document.write('SUCCESS'); window.testRunner && testRunner.notifyDone(); }</script>">
<input type="button" id="button1" value="Click 1" onclick="submitTo('_new')">
<input type="button" id="button2" value="Click 2" onclick="submitTo('_self')">
</form>
</body>
</html>