OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 <style> | 5 <style> |
6 :invalid { background: rgb(255, 0, 0); } | 6 :invalid { background: rgb(255, 0, 0); } |
7 :valid { background: rgb(0, 255, 0); } | 7 :valid { background: rgb(0, 255, 0); } |
8 fieldset:invalid input[type=submit] { background-color: rgb(127, 0, 0); } | 8 fieldset:invalid input[type=submit] { background-color: rgb(127, 0, 0); } |
9 fieldset:valid input[type=submit] { background-color: rgb(0, 127, 0); } | 9 fieldset:valid input[type=submit] { background-color: rgb(0, 127, 0); } |
10 </style> | 10 </style> |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 var invalidColor = 'rgb(255, 0, 0)'; | 24 var invalidColor = 'rgb(255, 0, 0)'; |
25 var validColor = 'rgb(0, 255, 0)'; | 25 var validColor = 'rgb(0, 255, 0)'; |
26 var subInvalidColor = 'rgb(127, 0, 0)'; | 26 var subInvalidColor = 'rgb(127, 0, 0)'; |
27 var subValidColor = 'rgb(0, 127, 0)'; | 27 var subValidColor = 'rgb(0, 127, 0)'; |
28 | 28 |
29 var parent = document.createElement('div'); | 29 var parent = document.createElement('div'); |
30 document.body.appendChild(parent); | 30 document.body.appendChild(parent); |
31 | 31 |
32 debug('Removing and adding required text inputs and modifying ther value by a DO
M tree mutation:'); | 32 debug('Removing and adding required text inputs and modifying their value by a D
OM tree mutation:'); |
33 parent.innerHTML = '<fieldset id=fieldset1><input type=text id=input1 required><
input type=text id=input2 required value=a><input type=submit id=sub1></fieldset
>'; | 33 parent.innerHTML = '<fieldset id=fieldset1><input type=text id=input1 required><
input type=text id=input2 required value=a><input type=submit id=sub1></fieldset
>'; |
34 var fieldset1 = $('fieldset1'); | 34 var fieldset1 = $('fieldset1'); |
35 var input1 = $('input1'); | 35 var input1 = $('input1'); |
36 var input2 = $('input2'); | 36 var input2 = $('input2'); |
37 var sub1 = $('sub1'); | 37 var sub1 = $('sub1'); |
38 shouldBe('backgroundOf(fieldset1)', 'invalidColor'); | 38 shouldBe('backgroundOf(fieldset1)', 'invalidColor'); |
39 shouldBe('backgroundOf(sub1)', 'subInvalidColor'); | 39 shouldBe('backgroundOf(sub1)', 'subInvalidColor'); |
40 shouldBe('fieldset1.removeChild(input1); backgroundOf(fieldset1)', 'validColor')
; | 40 shouldBe('fieldset1.removeChild(input1); backgroundOf(fieldset1)', 'validColor')
; |
41 shouldBe('backgroundOf(sub1)', 'subValidColor'); | 41 shouldBe('backgroundOf(sub1)', 'subValidColor'); |
42 shouldBe('fieldset1.appendChild(input1); backgroundOf(fieldset1)', 'invalidColor
'); | 42 shouldBe('fieldset1.appendChild(input1); backgroundOf(fieldset1)', 'invalidColor
'); |
43 shouldBe('backgroundOf(sub1)', 'subInvalidColor'); | 43 shouldBe('backgroundOf(sub1)', 'subInvalidColor'); |
44 shouldBe('input1.setAttribute("value", "a"); backgroundOf(fieldset1)', 'validCol
or'); | 44 shouldBe('input1.setAttribute("value", "a"); backgroundOf(fieldset1)', 'validCol
or'); |
45 shouldBe('backgroundOf(sub1)', 'subValidColor'); | 45 shouldBe('backgroundOf(sub1)', 'subValidColor'); |
46 shouldBe('input2.setAttribute("value", ""); backgroundOf(fieldset1)', 'invalidCo
lor'); | 46 shouldBe('input2.setAttribute("value", ""); backgroundOf(fieldset1)', 'invalidCo
lor'); |
47 shouldBe('backgroundOf(sub1)', 'subInvalidColor'); | 47 shouldBe('backgroundOf(sub1)', 'subInvalidColor'); |
48 debug('') | 48 debug('') |
49 | 49 |
| 50 debug('Disabling and marking inputs readonly by a DOM tree mutation:'); |
| 51 parent.innerHTML = '<fieldset id=fieldset1><input type=text id=input1 required><
input type=text id=input2 required value=a><input type=submit id=sub1></fieldset
>'; |
| 52 var fieldset1 = $('fieldset1'); |
| 53 var input1 = $('input1'); |
| 54 var sub1 = $('sub1'); |
| 55 shouldBe('backgroundOf(fieldset1)', 'invalidColor'); |
| 56 shouldBe('backgroundOf(sub1)', 'subInvalidColor'); |
| 57 shouldBe('input1.disabled=1; backgroundOf(fieldset1)', 'validColor'); |
| 58 shouldBe('backgroundOf(sub1)', 'subValidColor'); |
| 59 shouldBe('input1.disabled=0; backgroundOf(fieldset1)', 'invalidColor'); |
| 60 shouldBe('backgroundOf(sub1)', 'subInvalidColor'); |
| 61 shouldBe('input1.setAttribute("readonly", "1"); backgroundOf(fieldset1)', 'valid
Color'); |
| 62 shouldBe('backgroundOf(sub1)', 'subValidColor'); |
| 63 debug('') |
| 64 |
50 debug('Adding a required text input that is not a direct child of the fieldset:'
); | 65 debug('Adding a required text input that is not a direct child of the fieldset:'
); |
51 parent.innerHTML = '<fieldset id=fieldset1></fieldset>'; | 66 parent.innerHTML = '<fieldset id=fieldset1></fieldset>'; |
52 var fieldset1 = $('fieldset1'); | 67 var fieldset1 = $('fieldset1'); |
53 shouldBe('backgroundOf(fieldset1)', 'validColor'); | 68 shouldBe('backgroundOf(fieldset1)', 'validColor'); |
54 var div1 = document.createElement('div'); | 69 var div1 = document.createElement('div'); |
55 var input1 = document.createElement('input'); | 70 var input1 = document.createElement('input'); |
56 input1.setAttribute('type', 'text'); | 71 input1.setAttribute('type', 'text'); |
57 input1.setAttribute('required', ''); | 72 input1.setAttribute('required', ''); |
58 fieldset1.appendChild(div1); | 73 fieldset1.appendChild(div1); |
59 shouldBe('div1.appendChild(input1); backgroundOf(fieldset1)', 'invalidColor'); | 74 shouldBe('div1.appendChild(input1); backgroundOf(fieldset1)', 'invalidColor'); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 var input1 = $('input1'); | 115 var input1 = $('input1'); |
101 shouldBe('backgroundOf(fieldset1)', 'invalidColor'); | 116 shouldBe('backgroundOf(fieldset1)', 'invalidColor'); |
102 shouldBeEqualToString('val', '0'); | 117 shouldBeEqualToString('val', '0'); |
103 shouldBeEqualToString('input1.checkValidity(); val', '1'); | 118 shouldBeEqualToString('input1.checkValidity(); val', '1'); |
104 debug(''); | 119 debug(''); |
105 | 120 |
106 parent.innerHTML = ''; | 121 parent.innerHTML = ''; |
107 </script> | 122 </script> |
108 </body> | 123 </body> |
109 </html> | 124 </html> |
OLD | NEW |