4 <script src=
"../../../resources/js-test.js"></script>
8 description('Test for validationMessage IDL attribute for <input type=date>');
9 var parent
= document
.createElement('div');
10 document
.body
.appendChild(parent
);
11 parent
.innerHTML
= '<input type=date id=date maxlength=1 pattern=x>';
12 var input
= document
.getElementById('date');
15 function testIt(value
, min
, max
, step
)
17 input
.setAttribute("max", max
);
18 input
.setAttribute("min", min
);
19 input
.setAttribute("step", step
);
20 input
.setAttribute("value", value
);
21 return input
.validationMessage
;
25 shouldBeEqualToString('testIt("", "", "")', '');
27 debug('Value missing')
28 input
.setAttribute("required", "");
29 shouldBeEqualToString('testIt("", "", "")', 'Please fill out this field.');
30 input
.removeAttribute("required");
32 debug('Type mismatch');
33 shouldBeEqualToString('testIt("foo", "", "")', '');
35 debug('Range overflow')
36 shouldBeEqualToString('testIt("1982-11-02", "", "1970-12-31")', 'Value must be 12/31/1970 or earlier.');
38 debug('Range underflow')
39 shouldBeEqualToString('testIt("1982-11-02", "1990-05-25", "1990-12-24")', 'Value must be 05/25/1990 or later.');
41 debug('Step mismatch')
42 shouldBeEqualToString('testIt("1982-11-02", "1982-01-01", "", "123")', 'Please enter a valid value. The two nearest valid values are 09/04/1982 and 01/05/1983.');