4 <script src=
"../../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description('Test HTMLInputElement::valueAsDate binding.');
12 var input
= document
.createElement('input');
14 debug('Unsuppported type:');
16 shouldBe('input.valueAsDate', 'null');
17 shouldThrow('input.valueAsDate = date');
20 debug('Supported type:');
22 input
.value
= '2009-12';
23 var valueAsDate
= input
.valueAsDate
;
24 shouldBeTrue('valueAsDate != null');
25 shouldBe('typeof valueAsDate', '"object"');
26 shouldBe('valueAsDate.constructor.name', '"Date"');
28 debug('Sets an Epoch Date:');
29 var date
= new Date();
31 input
.valueAsDate
= date
;
32 shouldBe('input.value', '"1970-01"');
33 shouldBe('input.valueAsDate.getTime()', '0');
34 debug('Sets a number 0:');
35 input
.valueAsDate
= 0;
36 shouldBe('input.value', '"1970-01"');
37 shouldBe('input.valueAsDate.getTime()', '0');
38 debug('Sets other types:');
39 input
.value
= '1970-01';
40 input
.valueAsDate
= null;
41 shouldBe('input.value', '""');
42 input
.value
= '1970-01';
43 input
.valueAsDate
= undefined;
44 shouldBe('input.value', '""');
45 input
.value
= '1970-01';
46 input
.valueAsDate
= document
;
47 shouldBe('input.value', '""');