summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/label/continous-click-on-label.html
blob: 620fe4fdd7899daef2d06cea2b108dee1b9d2f77 (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
<!DOCTYPE html>
<html>
<script src="../../../resources/js-test.js"></script>
<style>
span {
    display: inline-block;
    width: 15px;
    height: 15px;
    vertical-align: bottom;
    border: 1px solid #ccc;
    margin-right: 5px;
    background-color: #fff;
}
</style>

<label><input type="checkbox" id="checkbox"><span id="span"></span></label>

<script>
description('Test the continous checking and unchecking of checkbox when ' +
    'clicking on associated label');

var checkbox = document.getElementById('checkbox');
var span = document.getElementById('span');

shouldBeFalse('checkbox.checked');
debug('The checkbox should be checked after three clicks');
testWithContinousClick(span, 3);
shouldBeTrue('checkbox.checked');

debug('Checkbox should still be checked after ten clicks');
testWithContinousClick(span, 10);
shouldBeTrue('checkbox.checked');

checkbox.style.display = 'none';

function testWithContinousClick(element, number)
{
    eventSender.mouseMoveTo(element.offsetLeft, element.offsetTop);
    for (n = 0; n < number; ++n) {
        eventSender.mouseDown();
        eventSender.mouseUp();
    }
}
</script>
</html>