summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/events/submit-reset-nested-bubble.html
blob: d2a251412eadb23084d37c1ff36c6392016a4294 (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
74
75
76
77
78
79
80
81
82
<html>
    <head>
        <script>
        function window_listener(evt)
        {
            var str = phaseString(evt.eventPhase);
            log("window " + evt.type + " " + str);
        }

        function reg_listener(evt) {
            var str = phaseString(evt.eventPhase);
            log(evt.currentTarget.id + " " + evt.type + " " + str);
            return false;
        }

        function phaseString(phase)
        {
            var str;
            if (phase == 1)
                str = "capture";
            else if (phase == 2)
                str = "target";
            else if (phase == 3)
                str = "bubble";
            return str;
        }

        function test()
        {
            if (window.testRunner)
                testRunner.dumpAsText();
                
            window.addEventListener("submit", window_listener, true); 
            document.getElementById('outer_form').addEventListener("submit", reg_listener, true); 
            document.getElementById('inner_form').addEventListener("submit", reg_listener, true); 
            document.getElementById('div').addEventListener("submit", reg_listener, true); 

            window.addEventListener("submit", window_listener, false); 
            document.getElementById('outer_form').addEventListener("submit", reg_listener, false); 
            document.getElementById('inner_form').addEventListener("submit", reg_listener, false); 
            document.getElementById('div').addEventListener("submit", reg_listener, false);

            window.addEventListener("reset", window_listener, true); 
            document.getElementById('outer_form').addEventListener("reset", reg_listener, true); 
            document.getElementById('inner_form').addEventListener("reset", reg_listener, true); 
            document.getElementById('div').addEventListener("reset", reg_listener, true); 

            window.addEventListener("reset", window_listener, false); 
            document.getElementById('outer_form').addEventListener("reset", reg_listener, false); 
            document.getElementById('inner_form').addEventListener("reset", reg_listener, false); 
            document.getElementById('div').addEventListener("reset", reg_listener, false);

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

        function log(msg)
        {
            var res = document.getElementById('res');
            res.innerHTML = res.innerHTML + msg + "<br>";
        }

        </script>
    </head>
    <body onload="test()">
    This tests that we stop propagation when bubbling a submit or reset event to more than one form.  This matches Firefox behavior<br>
    This can only occur when misnested tags cause forms to be nested.<br>
    <br>
    You can manually test the submit event, but this automated test will only test the reset event.
    <br><br>
    <form id="outer_form">
        <div id="div">
        <table>
        </form>
        </table>
            <form id="inner_form">
                <input type=submit id="bt_submit" value="Submit"></input>
                <input type=reset id="bt_reset" value="Reset"></input>
            </form>
        </div>
        <div id="res"></div>
    </body>
</html>