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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=885359
-->
<head>
<title>Test for Bug 885359</title>
<script type="text/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=885359">Mozilla Bug 343444</a>
<p id="display"></p>
<form>
<input type="radio" id='radio1'/><br/>
<input type="radio" id="g1radio1" name="group1"/>
<input type="radio" id="g1radio2" name="group1"/></br>
<input type="radio" id="g1radio3" name="group1"/></br>
<input type="radio" id="g2radio1" name="group2"/>
<input type="radio" id="g2radio2" name="group2" checked/></br>
</form>
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
var radio1 = document.getElementById("radio1");
var g1radio1 = document.getElementById("g1radio1");
var g1radio2 = document.getElementById("g1radio2");
var g1radio3 = document.getElementById("g1radio3");
var g2radio1 = document.getElementById("g2radio1");
var g2radio2 = document.getElementById("g2radio2");
SimpleTest.waitForFocus(function() {
test();
SimpleTest.finish();
});
function verifyIndeterminateState(aElement, aIsIndeterminate, aMessage) {
is(aElement.mozMatchesSelector(':indeterminate'), aIsIndeterminate, aMessage);
}
function test() {
// Initial State.
verifyIndeterminateState(radio1, true,
"Unchecked radio in its own group (no name attribute)");
verifyIndeterminateState(g1radio1, true, "No selected radio in its group");
verifyIndeterminateState(g1radio2, true, "No selected radio in its group");
verifyIndeterminateState(g1radio3, true, "No selected radio in its group");
verifyIndeterminateState(g2radio1, false, "Selected radio in its group");
verifyIndeterminateState(g2radio2, false, "Selected radio in its group");
// Selecting radio buttion.
g1radio1.checked = true;
verifyIndeterminateState(g1radio1, false,
"Selecting a radio should affect all radios in the group");
verifyIndeterminateState(g1radio2, false,
"Selecting a radio should affect all radios in the group");
verifyIndeterminateState(g1radio3, false,
"Selecting a radio should affect all radios in the group");
// Changing the selected radio button.
g1radio3.checked = true;
verifyIndeterminateState(g1radio1, false,
"Selecting a radio should affect all radios in the group");
verifyIndeterminateState(g1radio2, false,
"Selecting a radio should affect all radios in the group");
verifyIndeterminateState(g1radio3, false,
"Selecting a radio should affect all radios in the group");
// Deselecting radio button.
g2radio2.checked = false;
verifyIndeterminateState(g2radio1, true,
"Deselecting a radio should affect all radios in the group");
verifyIndeterminateState(g2radio2, true,
"Deselecting a radio should affect all radios in the group");
// Move a selected radio button to another group.
g1radio3.name = "group2";
// The radios' state in the original group becomes indeterminated.
verifyIndeterminateState(g1radio1, true,
"Removing a radio from a group should affect all radios in the group");
verifyIndeterminateState(g1radio2, true,
"Removing a radio from a group should affect all radios in the group");
// The radios' state in the new group becomes determinated.
verifyIndeterminateState(g1radio3, false,
"Adding a radio from a group should affect all radios in the group");
verifyIndeterminateState(g2radio1, false,
"Adding a radio from a group should affect all radios in the group");
verifyIndeterminateState(g2radio2, false,
"Adding a radio from a group should affect all radios in the group");
// Change input type to 'text'.
g1radio3.type = "text";
verifyIndeterminateState(g1radio3, false,
"Input type text does not have an indeterminate state");
verifyIndeterminateState(g2radio1, true,
"Changing input type should affect all radios in the group");
verifyIndeterminateState(g2radio2, true,
"Changing input type should affect all radios in the group");
}
</script>
</pre>
</body>
</html>
|