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");
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>
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.