<html>
<body>
<p>Clone a checked radio box, the radio box being cloned should still be checked till the clone is inserted into the dom tree.</p>
<div>
<input id="radio" type="radio" name="radiotest" checked="checked" />
</div>
<div id="msgs">
</div>
<script>
var lc = window.testRunner;
if (lc) {
lc.dumpAsText();
}
var msgs = [];
var oldEl = document.getElementById('radio');
var newEl = oldEl.cloneNode(true);
function checked (input) {
return input.checked ? "true" : "false";
}
function expect (result, expected) {
msgs.push([ result, (result == expected ? "SUCCESS" : "FAIL") ].join(" "));
}
// test 1
expect(oldEl.checked, true);
expect(newEl.checked, true);
oldEl.parentNode.appendChild(newEl);
// test 2
expect(oldEl.checked, false);
expect(newEl.checked, true);
document.getElementById("msgs").innerHTML = msgs.join("<br/>");
</script>
</body>
</html>