| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <p id="description"></p> |
| <div id="console"></div> |
| <script> |
| description('Test HTMLInputElement::valueAsDate binding.'); |
| |
| var input = document.createElement('input'); |
| |
| debug('Unsuppported type:'); |
| input.type = 'text'; |
| shouldBe('input.valueAsDate', 'null'); |
| shouldThrowErrorName('input.valueAsDate = date', 'InvalidStateError'); |
| |
| debug(''); |
| debug('Supported type:'); |
| input.type = 'month'; |
| input.value = '2009-12'; |
| var valueAsDate = input.valueAsDate; |
| shouldBeTrue('valueAsDate != null'); |
| shouldBe('typeof valueAsDate', '"object"'); |
| shouldBe('valueAsDate.constructor.name', '"Date"'); |
| |
| debug('Sets an Epoch Date:'); |
| var date = new Date(); |
| date.setTime(0); |
| input.valueAsDate = date; |
| shouldBe('input.value', '"1970-01"'); |
| shouldBe('input.valueAsDate.getTime()', '0'); |
| debug('Sets a number 0:'); |
| input.valueAsDate = 0; |
| shouldBe('input.value', '"1970-01"'); |
| shouldBe('input.valueAsDate.getTime()', '0'); |
| debug('Sets other types:'); |
| input.value = '1970-01'; |
| input.valueAsDate = null; |
| shouldBe('input.value', '""'); |
| input.value = '1970-01'; |
| input.valueAsDate = undefined; |
| shouldBe('input.value', '""'); |
| input.value = '1970-01'; |
| input.valueAsDate = document; |
| shouldBe('input.value', '""'); |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |