| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script> | 7 <script> |
| 8 description('Test for keyboard operations for <input type=number>'); | 8 description('Test for keyboard operations for <input type=number>'); |
| 9 var parent = document.createElement('div'); | 9 var parent = document.createElement('div'); |
| 10 document.body.appendChild(parent); | 10 document.body.appendChild(parent); |
| 11 parent.innerHTML = '<input type=number id=number>'; | 11 parent.innerHTML = '<input type=number id=number>'; |
| 12 | 12 |
| 13 var input = document.getElementById('number'); | 13 var input = document.getElementById('number'); |
| 14 input.focus(); | 14 input.focus(); |
| 15 debug('Inserting "ab123cd":'); | 15 debug('Inserting "ab123cd":'); |
| 16 document.execCommand('InsertText', false, 'ab123cd'); | 16 document.execCommand('InsertText', false, 'ab123cd'); |
| 17 shouldBe('input.value', '""'); | 17 shouldBeEqualToString('input.value', '123'); |
| 18 | 18 |
| 19 debug('Press the up arrow key:'); | 19 debug('Press the up arrow key:'); |
| 20 input.valueAsNumber = 123; | 20 input.valueAsNumber = 123; |
| 21 eventSender.keyDown('upArrow'); | 21 eventSender.keyDown('upArrow'); |
| 22 shouldBe('input.value', '"124"'); | 22 shouldBe('input.value', '"124"'); |
| 23 | 23 |
| 24 debug('Press the down arrow key:'); | 24 debug('Press the down arrow key:'); |
| 25 eventSender.keyDown('downArrow'); | 25 eventSender.keyDown('downArrow'); |
| 26 shouldBe('input.value', '"123"'); | 26 shouldBe('input.value', '"123"'); |
| 27 | 27 |
| 28 debug('Press the down and alt arrow key, should not decrement value:'); | 28 debug('Press the down and alt arrow key, should not decrement value:'); |
| 29 eventSender.keyDown('downArrow', ['altKey']); | 29 eventSender.keyDown('downArrow', ['altKey']); |
| 30 shouldBeEqualToString('input.value', '123'); | 30 shouldBeEqualToString('input.value', '123'); |
| 31 | 31 |
| 32 debug('Disable input element:'); | 32 debug('Disable input element:'); |
| 33 input.disabled = true; | 33 input.disabled = true; |
| 34 eventSender.keyDown('upArrow'); | 34 eventSender.keyDown('upArrow'); |
| 35 shouldBe('input.value', '"123"'); | 35 shouldBe('input.value', '"123"'); |
| 36 input.removeAttribute('disabled'); | 36 input.removeAttribute('disabled'); |
| 37 | 37 |
| 38 debug('Read-only input element:'); | 38 debug('Read-only input element:'); |
| 39 input.readOnly = true; | 39 input.readOnly = true; |
| 40 eventSender.keyDown('upArrow'); | 40 eventSender.keyDown('upArrow'); |
| 41 shouldBe('input.value', '"123"'); | 41 shouldBe('input.value', '"123"'); |
| 42 </script> | 42 </script> |
| 43 </body> | 43 </body> |
| 44 </html> | 44 </html> |
| OLD | NEW |