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
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=617528
-->
<head>
<title>Test for Bug 617528</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=617528">Mozilla Bug 617528</a>
<p id="display"></p>
<div id="content">
<menu>
<menuitem id="checkbox" type="checkbox" label="Checkbox" checked></menuitem>
<menuitem id="radio1" type="radio" label="Radio1" checked></menuitem>
<menuitem id="radio2" type="radio" label="Radio2"></menuitem>
</menu>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 617528 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
function click(element, preventDefault, checked) {
function handleClick(event) {
is(this.checked, checked,
"checking .checked (" + this.id + ")");
if (preventDefault)
event.preventDefault();
}
element.addEventListener("click", handleClick);
element.click();
element.removeEventListener("click", handleClick);
}
function verify(elements, data) {
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
is(element.checked, data[i*2],
"checking .checked (" + element.id + ")");
is(element.defaultChecked, data[i*2+1],
'checking .defaultChecked (' + element.id + ")");
}
}
var checkbox = document.getElementById("checkbox");
click(checkbox, false, false);
verify([checkbox], [false, true]);
click(checkbox, true, true);
verify([checkbox], [false, true]);
var radio1 = document.getElementById("radio1");
var radio2 = document.getElementById("radio2");
click(radio2, false, true);
verify([radio1, radio2], [false, true,
true, false]);
click(radio1, true, true);
verify([radio1, radio2], [false, true,
true, false]);
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>
|