summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/HTMLLabelElement/click-label.html
blob: b8dbfbd41f246f840a38ac035fd415111c029298 (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
<html>
<head>
<script>
var clickcount = 0;
function dispatchClickEvent(target) {
    // Create a click event and dispatch it
    var event = document.createEvent('UIEvents');
    event.initUIEvent('click', true, true, window, 1)
    target.dispatchEvent(event);                
}

function runTest() {
    if (window.layoutTestController)
        layoutTestController.dumpAsText();

    var label1 = document.getElementById('label1');
    dispatchClickEvent(label1);
    if (clickcount < 1)
        return;

    var label2 = document.getElementById('label2');
    dispatchClickEvent(label2);
    if (clickcount < 2)
        return;
    document.getElementById('result').innerHTML = 'SUCCESS'
}

function inc()
{
    clickcount++;
}
</script>
</head>
<body onload="runTest()">
This tests that the correct form control element is clicked when clicking on a label.
If the test is successful, the text "SUCCESS" should show below.<br>
<Label id="label1">label1<button onclick="inc();">inc</button></label><br>
<Label id="label2">label2<fieldset><legend><button onclick="inc();">inc</button></legend></fieldset></label><br>
<div id="result">FAILURE</div>

</body>
</html>