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