Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: LayoutTests/fast/forms/script-tests/ValidityState-valueMissing-radio.js

Issue 9805002: Revert 105710 - Introduce RadioButtonGroup class to keep track of the group members and required st… (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1025/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 description('valueMissing tests for radio buttons'); 1 description('valueMissing tests for radio buttons');
2 2
3 var parent = document.createElement('div'); 3 var parent = document.createElement('div');
4 document.body.appendChild(parent); 4 document.body.appendChild(parent);
5 5
6 debug('Without form element'); 6 debug('Without form element');
7 parent.innerHTML = '<input name=victim type=radio required>' 7 parent.innerHTML = '<input name=victim type=radio required>'
8 + '<input name=victim type=radio>' 8 + '<input name=victim type=radio>'
9 + '<input name=victim type=radio>'; 9 + '<input name=victim type=radio>';
10 var inputs = document.getElementsByName('victim'); 10 var inputs = document.getElementsByName('victim');
11 debug('No checked button:'); 11 debug('No checked button:');
12 shouldBeTrue('inputs[0].validity.valueMissing'); 12 shouldBeTrue('inputs[0].validity.valueMissing');
13 shouldBeTrue('inputs[1].validity.valueMissing'); 13 // The following result should be false because the element does not have
14 shouldBeTrue('inputs[2].validity.valueMissing'); 14 // "required". It conforms to HTML5, and this behavior has no practical
15 // problems.
16 shouldBeFalse('inputs[1].validity.valueMissing');
17 shouldBeFalse('inputs[2].validity.valueMissing');
15 debug('The second button has been checked:'); 18 debug('The second button has been checked:');
16 inputs[1].checked = true; 19 inputs[1].checked = true;
17 shouldBeFalse('inputs[0].validity.valueMissing'); 20 shouldBeFalse('inputs[0].validity.valueMissing');
18 shouldBeFalse('inputs[1].validity.valueMissing'); 21 shouldBeFalse('inputs[1].validity.valueMissing');
19 shouldBeFalse('inputs[2].validity.valueMissing'); 22 shouldBeFalse('inputs[2].validity.valueMissing');
20 debug('The first button has been checked:'); 23 debug('The first button has been checked:');
21 inputs[0].checked = true; 24 inputs[0].checked = true;
22 shouldBeFalse('inputs[0].validity.valueMissing'); 25 shouldBeFalse('inputs[0].validity.valueMissing');
23 shouldBeFalse('inputs[1].validity.valueMissing'); 26 shouldBeFalse('inputs[1].validity.valueMissing');
24 shouldBeFalse('inputs[2].validity.valueMissing'); 27 shouldBeFalse('inputs[2].validity.valueMissing');
25 debug('The third button has been checked:'); 28 debug('The third button has been checked:');
26 inputs[2].checked = true; 29 inputs[2].checked = true;
27 shouldBeFalse('inputs[0].validity.valueMissing'); 30 shouldBeFalse('inputs[0].validity.valueMissing');
28 shouldBeFalse('inputs[1].validity.valueMissing'); 31 shouldBeFalse('inputs[1].validity.valueMissing');
29 shouldBeFalse('inputs[2].validity.valueMissing'); 32 shouldBeFalse('inputs[2].validity.valueMissing');
30 33
31 debug('');
32 debug('With form element'); 34 debug('With form element');
33 parent.innerHTML = '<form>' 35 parent.innerHTML = '<form>'
34 + '<input name=victim type=radio required>' 36 + '<input name=victim type=radio required>'
35 + '<input name=victim type=radio>' 37 + '<input name=victim type=radio>'
36 + '<input name=victim type=radio>' 38 + '<input name=victim type=radio>'
37 + '</form>'; 39 + '</form>';
38 inputs = document.getElementsByName('victim'); 40 inputs = document.getElementsByName('victim');
39 debug('No checked button:'); 41 debug('No checked button:');
40 shouldBeTrue('inputs[0].validity.valueMissing'); 42 shouldBeTrue('inputs[0].validity.valueMissing');
41 shouldBeTrue('inputs[1].validity.valueMissing'); 43 // The following result should be false.
42 shouldBeTrue('inputs[2].validity.valueMissing'); 44 shouldBeFalse('inputs[1].validity.valueMissing');
45 shouldBeFalse('inputs[2].validity.valueMissing');
43 debug('The first button has been checked:'); 46 debug('The first button has been checked:');
44 inputs[0].checked = true; 47 inputs[0].checked = true;
45 shouldBeFalse('inputs[0].validity.valueMissing'); 48 shouldBeFalse('inputs[0].validity.valueMissing');
46 shouldBeFalse('inputs[1].validity.valueMissing'); 49 shouldBeFalse('inputs[1].validity.valueMissing');
47 shouldBeFalse('inputs[2].validity.valueMissing'); 50 shouldBeFalse('inputs[2].validity.valueMissing');
48 debug('The second button has been checked:'); 51 debug('The second button has been checked:');
49 inputs[1].checked = true; 52 inputs[1].checked = true;
50 shouldBeFalse('inputs[0].validity.valueMissing'); 53 shouldBeFalse('inputs[0].validity.valueMissing');
51 shouldBeFalse('inputs[1].validity.valueMissing'); 54 shouldBeFalse('inputs[1].validity.valueMissing');
52 shouldBeFalse('inputs[2].validity.valueMissing'); 55 shouldBeFalse('inputs[2].validity.valueMissing');
53 debug('The third button has been checked:'); 56 debug('The third button has been checked:');
54 inputs[2].checked = true; 57 inputs[2].checked = true;
55 shouldBeFalse('inputs[0].validity.valueMissing'); 58 shouldBeFalse('inputs[0].validity.valueMissing');
56 shouldBeFalse('inputs[1].validity.valueMissing'); 59 shouldBeFalse('inputs[1].validity.valueMissing');
57 shouldBeFalse('inputs[2].validity.valueMissing'); 60 shouldBeFalse('inputs[2].validity.valueMissing');
58
59 debug('');
60 debug('Not in a radio button group');
61 var requiredButton = document.createElement('input');
62 requiredButton.type = 'radio';
63 requiredButton.name = 'victim';
64 requiredButton.required = true;
65 shouldBeFalse('requiredButton.validity.valueMissing');
66
67 parent.innerHTML = '<input name=victim type=radio required><input name=victim ty pe=radio>';
68 requiredButton = document.getElementsByName('victim')[0];
69 var button = document.getElementsByName('victim')[1];
70 shouldBeTrue('requiredButton.validity.valueMissing');
71 shouldBeTrue('button.validity.valueMissing');
72 parent.removeChild(button);
73 shouldBeFalse('button.validity.valueMissing');
74 parent.removeChild(requiredButton);
75 shouldBeFalse('requiredButton.validity.valueMissing');
76
OLDNEW
« no previous file with comments | « LayoutTests/fast/forms/radio/radio-live-validation-style-expected.txt ('k') | LayoutTests/perf/adding-radio-buttons.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698