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('input'); | 10 var i = document.createElement('input'); |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 debug('Change step:'); | 107 debug('Change step:'); |
108 el = makeInvalid(); | 108 el = makeInvalid(); |
109 el.value = '1'; | 109 el.value = '1'; |
110 el.type = 'number'; | 110 el.type = 'number'; |
111 shouldBe(elBackground, 'validColor'); | 111 shouldBe(elBackground, 'validColor'); |
112 el.step = '2'; | 112 el.step = '2'; |
113 shouldBe(elBackground, 'invalidColor'); | 113 shouldBe(elBackground, 'invalidColor'); |
114 el.step = '0.5'; | 114 el.step = '0.5'; |
115 shouldBe(elBackground, 'validColor'); | 115 shouldBe(elBackground, 'validColor'); |
OLD | NEW |