5 <script src=
"../../resources/js-test.js"></script>
11 <input type=
"radio" name=
"type1" value=
"value1">
12 <input type=
"radio" name=
"type1" value=
"value2">
13 <input type=
"radio" name=
"type2" value=
"value4">
14 <input type=
"radio" name=
"type2" value=
"value5">
17 <input type=
"checkbox" name=
"chkbox" value=
"chkboxvalue">
20 <div id=
"external-elements">
21 <input type=
"radio" form=
"testForm" name=
"type1" value=
"value3">
22 <input type=
"radio" form=
"testForm" name=
"type2" value=
"value6">
25 <div id=
"console"></div>
28 description("RadioNodeList should be rooted at form itself if detached from dom tree");
30 var owner
= document
.getElementById('testForm');
31 var radioNodeList1
= owner
.elements
['type1'];
32 var radioNodeList2
= owner
.elements
['type2'];
33 var container
= document
.getElementById('container');
35 function testRadioNodeList(expectedNumberOfItems
) {
36 shouldBe('radioNodeList1.length', expectedNumberOfItems
+ '');
37 shouldBe('radioNodeList2.length', expectedNumberOfItems
+ '');
39 shouldBe('radioNodeList1[0].value', "'value1'");
40 shouldBe('radioNodeList1[1].value', "'value2'");
41 if (expectedNumberOfItems
== 3)
42 shouldBe('radioNodeList1[2].value', "'value3'");
43 shouldBe('radioNodeList2[0].value', "'value4'");
44 shouldBe('radioNodeList2[1].value', "'value5'");
45 if (expectedNumberOfItems
== 3)
46 shouldBe('radioNodeList2[2].value', "'value6'");
49 debug("form in dom tree");
52 debug("Check RadioNodeList.value");
53 shouldBe('radioNodeList1.value', '""');
54 shouldBe('radioNodeList2.value', '""');
55 shouldBe('radioNodeList1[2].checked = true; radioNodeList1.value', "'value3'");
57 container
.removeChild(owner
);
60 debug("form detached from dom tree");
63 debug("Check RadioNodeList.value");
64 shouldBe('radioNodeList1[1].checked = true; radioNodeList1.value', "'value2'");
66 container
.appendChild(owner
);
67 var externalElements
= document
.getElementById('external-elements');
68 externalElements
.parentNode
.removeChild(externalElements
);
69 container
.appendChild(externalElements
);
72 debug("form again added to dom tree");
75 container
.parentNode
.removeChild(container
);
78 debug("form's ancestor detached from dom tree");
81 debug("Check RadioNodeList.value");
82 shouldBe('radioNodeList1[1].checked = true; radioNodeList1.value', "'value2'");
84 document
.body
.appendChild(container
);
87 debug("form again added to dom tree");
90 container
.parentNode
.removeChild(container
);