blob: 6e51eebc3a172cdb999643d5a0c594b4075d4428 (
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
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
var cb = document.createElement("input");
document.body.appendChild(cb);
cb.type = "checkbox";
description("This tests that clicking on indeterminate checkbox flips both checked/indeterminate states and calling preventDefault restores them.");
debug("Test if clicking on unchecked indeterminate checkbox flips both checked/indeterminate states");
cb.checked = false;
cb.indeterminate = true;
cb.click();
shouldBeTrue('cb.checked');
shouldBeFalse('cb.indeterminate');
debug("Test if clicking on checked indeterminate checkbox flips both checked/indeterminate states");
cb.checked = true;
cb.indeterminate = true;
cb.click();
shouldBeFalse('cb.checked');
shouldBeFalse('cb.indeterminate');
debug("Test if preventDefault restores the checked/indeterminate states");
cb.checked = false;
cb.indeterminate = true;
cb.onclick = function(e) {
shouldBeTrue('cb.checked');
shouldBeFalse('cb.indeterminate');
e.preventDefault();
};
cb.click();
shouldBeFalse('cb.checked');
shouldBeTrue('cb.indeterminate');
</script>
</body>
</html>
|