| OLD | NEW |
| 1 var invalidStyleColor = 'rgb(255, 0, 0)'; | 1 var invalidStyleColor = 'rgb(255, 0, 0)'; |
| 2 var input; | 2 var input; |
| 3 var quiet = true; | 3 var quiet = true; |
| 4 | 4 |
| 5 function colorOf(el) { | 5 function colorOf(el) { |
| 6 return document.defaultView.getComputedStyle(el, null).getPropertyValue('bac
kground-color'); | 6 return document.defaultView.getComputedStyle(el, null).getPropertyValue('bac
kground-color'); |
| 7 } | 7 } |
| 8 function testBadInput(type) { | 8 function testBadInput(type) { |
| 9 if (!window.eventSender) { | 9 if (!window.eventSender) { |
| 10 debug('Needs to run this on DRT/WTR.'); | 10 debug('Needs to run this on DRT/WTR.'); |
| 11 return; | 11 return; |
| 12 } | 12 } |
| 13 description('A ' + type + ' input fields with a bad user input should make v
alidity.badInput true and have :invalid style.'); | 13 description('A ' + type + ' input fields with a bad user input should make v
alidity.badInput true and have :invalid style.'); |
| 14 input = document.createElement('input'); | 14 input = document.createElement('input'); |
| 15 input.type = type; | 15 input.type = type; |
| 16 document.body.appendChild(input); | 16 document.body.appendChild(input); |
| 17 input.focus(); | 17 input.focus(); |
| 18 | 18 |
| 19 debug('Initial state. The elment has no value.'); | 19 debug('Initial state. The elment has no value.'); |
| 20 shouldNotBe('colorOf(input)', 'invalidStyleColor'); | 20 shouldNotBe('colorOf(input)', 'invalidStyleColor'); |
| 21 shouldBeFalse('input.validity.badInput'); | 21 shouldBeFalse('input.validity.badInput'); |
| 22 | 22 |
| 23 debug('Set a value to the first sub-field. The element becomes badInput.'); | 23 debug('Set a value to the first sub-field. The element becomes badInput.'); |
| 24 eventSender.keyDown('upArrow'); | 24 eventSender.keyDown('ArrowUp'); |
| 25 shouldBe('colorOf(input)', 'invalidStyleColor'); | 25 shouldBe('colorOf(input)', 'invalidStyleColor'); |
| 26 shouldBeTrue('input.validity.badInput'); | 26 shouldBeTrue('input.validity.badInput'); |
| 27 | 27 |
| 28 if (type === 'date' || type === 'datetime' || type === 'datetime-local') { | 28 if (type === 'date' || type === 'datetime' || type === 'datetime-local') { |
| 29 debug('Set an invalid date, 2012-02-31.'); | 29 debug('Set an invalid date, 2012-02-31.'); |
| 30 if (type == 'date') | 30 if (type == 'date') |
| 31 input.value = '2012-02-01'; | 31 input.value = '2012-02-01'; |
| 32 else if (type == 'datetime') | 32 else if (type == 'datetime') |
| 33 input.value = '2012-02-01T03:04Z'; | 33 input.value = '2012-02-01T03:04Z'; |
| 34 else | 34 else |
| 35 input.value = '2012-02-01T03:04'; | 35 input.value = '2012-02-01T03:04'; |
| 36 shouldNotBe('colorOf(input)', 'invalidStyleColor', quiet); | 36 shouldNotBe('colorOf(input)', 'invalidStyleColor', quiet); |
| 37 shouldBeFalse('input.validity.badInput'); | 37 shouldBeFalse('input.validity.badInput'); |
| 38 eventSender.keyDown('rightArrow'); // -> 02/[01]/2012 ... | 38 eventSender.keyDown('ArrowRight'); // -> 02/[01]/2012 ... |
| 39 eventSender.keyDown('downArrow'); // -> 02/[31]/2012 ... | 39 eventSender.keyDown('ArrowDown'); // -> 02/[31]/2012 ... |
| 40 shouldBeEqualToString('input.value', ''); | 40 shouldBeEqualToString('input.value', ''); |
| 41 shouldBeTrue('input.validity.badInput'); | 41 shouldBeTrue('input.validity.badInput'); |
| 42 shouldBe('colorOf(input)', 'invalidStyleColor'); | 42 shouldBe('colorOf(input)', 'invalidStyleColor'); |
| 43 } | 43 } |
| 44 } | 44 } |
| OLD | NEW |