1description('valueMissing tests for radio buttons');
2
3var parent = document.createElement('div');
4document.body.appendChild(parent);
5
6debug('Without form element');
7parent.innerHTML = '<input name=victim type=radio required/>'
8 + '<input name=victim type=radio/>';
9var inputs = document.getElementsByName('victim');
10debug('No checked button:');
11shouldBeTrue('inputs[0].validity.valueMissing');
12// The following result should be false because the element does not have
13// "required". It conforms to HTML5, and this behavior has no practical
14// problems.
15shouldBeFalse('inputs[1].validity.valueMissing');
16debug('The first button has been checked:');
17inputs[0].checked = true;
18shouldBeFalse('inputs[0].validity.valueMissing');
19shouldBeFalse('inputs[1].validity.valueMissing');
20debug('The second button has been checked:');
21inputs[1].checked = true;
22shouldBeFalse('inputs[0].validity.valueMissing');
23shouldBeFalse('inputs[1].validity.valueMissing');
24
25debug('With form element');
26parent.innerHTML = '<form>'
27 + '<input name=victim type=radio required/>'
28 + '<input name=victim type=radio/>'
29 + '</form>';
30inputs = document.getElementsByName('victim');
31debug('No checked button:');
32shouldBeTrue('inputs[0].validity.valueMissing');
33// The following result should be false.
34shouldBeFalse('inputs[1].validity.valueMissing');
35debug('The first button has been checked:');
36inputs[0].checked = true;
37shouldBeFalse('inputs[0].validity.valueMissing');
38shouldBeFalse('inputs[1].validity.valueMissing');
39debug('The second button has been checked:');
40inputs[1].checked = true;
41shouldBeFalse('inputs[0].validity.valueMissing');
42shouldBeFalse('inputs[1].validity.valueMissing');
43
44var successfullyParsed = true;