OLD | NEW |
1 description("This test performs a check that :valid/:invalid CSS psudo selectors
are lively applied."); | 1 description("This test performs a check that :valid/:invalid CSS psudo selectors
are lively applied."); |
2 | 2 |
3 // Setup for static elements. | 3 // Setup for static elements. |
4 var form = document.createElement('form'); | 4 var form = document.createElement('form'); |
5 document.body.appendChild(form); | 5 document.body.appendChild(form); |
6 var nonForm = document.createElement('div'); | 6 var nonForm = document.createElement('div'); |
7 document.body.appendChild(nonForm); | 7 document.body.appendChild(nonForm); |
8 | 8 |
9 function makeInvalid() { | 9 function makeInvalid() { |
10 var i = document.createElement('textarea'); | 10 var i = document.createElement('textarea'); |
11 i.name = 'foo'; | 11 i.name = 'foo'; |
12 i.required = true; | 12 i.required = true; |
13 i.value = ''; | 13 i.value = ''; |
14 form.appendChild(i); | 14 form.appendChild(i); |
15 return i; | 15 return i; |
16 } | 16 } |
17 | 17 |
18 function backgroundOf(el) { | 18 function backgroundOf(el) { |
19 return document.defaultView.getComputedStyle(el, null).getPropertyValue('bac
kground-color'); | 19 return document.defaultView.getComputedStyle(el, null).getPropertyValue('bac
kground-color'); |
20 } | 20 } |
21 | 21 |
22 var elBackground = 'backgroundOf(el)'; | 22 var elBackground = 'backgroundOf(el)'; |
23 var invalidColor = 'rgb(255, 0, 0)'; | 23 var invalidColor = 'rgb(255, 0, 0)'; |
24 var normalColor = 'rgb(255, 255, 255)'; | 24 var normalColor = 'rgb(255, 255, 255)'; |
25 var disabledColor = 'rgb(0, 0, 0)'; | 25 var disabledColor = 'rgb(0, 0, 0)'; |
26 var readOnlyColor = 'rgb(0, 255, 0)' | 26 var readOnlyColor = 'rgb(0, 255, 0)'; |
27 var validColor = 'rgb(0, 0, 255)'; | 27 var validColor = 'rgb(0, 0, 255)'; |
28 | 28 |
29 // -------------------------------- | 29 // -------------------------------- |
30 // willValidate change | 30 // willValidate change |
31 // -------------------------------- | 31 // -------------------------------- |
32 var el = makeInvalid(); | 32 var el = makeInvalid(); |
33 // Confirm this element is invalid. | 33 // Confirm this element is invalid. |
34 debug('Chheck the initial state:'); | 34 debug('Chheck the initial state:'); |
35 shouldBe(elBackground, 'invalidColor'); | 35 shouldBe(elBackground, 'invalidColor'); |
36 | 36 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 el.value = '1234567890'; | 94 el.value = '1234567890'; |
95 shouldBe(elBackground, 'validColor'); | 95 shouldBe(elBackground, 'validColor'); |
96 // Make the value dirty by deleting the last character. | 96 // Make the value dirty by deleting the last character. |
97 el.focus(); | 97 el.focus(); |
98 el.setSelectionRange(10, 10); | 98 el.setSelectionRange(10, 10); |
99 document.execCommand('delete'); | 99 document.execCommand('delete'); |
100 el.maxLength = 5; | 100 el.maxLength = 5; |
101 shouldBe(elBackground, 'invalidColor'); | 101 shouldBe(elBackground, 'invalidColor'); |
102 el.maxLength = 10; | 102 el.maxLength = 10; |
103 shouldBe(elBackground, 'validColor'); | 103 shouldBe(elBackground, 'validColor'); |
OLD | NEW |