summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/form-submission-cancelable.html
blob: 7379bdd48ceac5b6baa15d2812e1c4ddb972ffba (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
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<form method="GET" target="target" action="data:text/html,a">
      <input name="query" value="AAA" />
      <input type="submit" id="submitButton"/>
</form>
<form method="GET" target="target1" action="data:text/html,b">
      <input name="query1" value="AAA" />
      <input type="submit" id="submitButton1"/>
</form>
<iframe id="target" name="target"></iframe>
<iframe id="target1" name="target1"></iframe>
<script>
description('Test that form submit within onsubmit event handlers are not delayed and sends the form data when invoked');

document.forms[0].onsubmit = function (event) {
    document.forms[0].submit();
    document.forms[0].children.query.value = 'BBB';
    return false;
}

document.forms[1].onsubmit = function (event) {
    document.forms[1].submit();
    document.forms[1].children.query1.value = 'BBB';
    return true;
}

window.onload = function() {
    document.getElementById('target').onload = function(event) {
        // This should return back query AAA
        shouldBeEqualToString('event.target.contentWindow.location.search', '?query=AAA');
        document.getElementById('submitButton1').click();
    }

    document.getElementById('target1').onload = function(event) {
        // This should return back query BBB
        shouldBeEqualToString('event.target.contentWindow.location.search', '?query1=BBB');
        finishJSTest();
    }

    document.getElementById('submitButton').click();
}

if (window.testRunner)
    window.jsTestIsAsync = true;
</script>
</body>
</html>