Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / month / input-valueasdate.html
blob47779147eb989837d93de018473f26063e0655bc
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('Test HTMLInputElement::valueAsDate binding.');
12 var input = document.createElement('input');
14 debug('Unsuppported type:');
15 input.type = 'text';
16 shouldBe('input.valueAsDate', 'null');
17 shouldThrow('input.valueAsDate = date');
19 debug('');
20 debug('Supported type:');
21 input.type = 'month';
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();
30 date.setTime(0);
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', '""');
48 </script>
49 </body>
50 </html>