OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> |
| 3 <script> |
| 4 description("This tests the selection of the text field when mouse event occ
urs out of range"); |
| 5 jsTestIsAsync = true; |
| 6 window.onload = function() { |
| 7 runTest(); |
| 8 } |
| 9 function runTest() { |
| 10 var textfield = document.getElementById('textfield'); |
| 11 textfield.addEventListener('focus', setSelectionRange); |
| 12 textfield.setSelectionRange(0, 1); |
| 13 |
| 14 if (window.eventSender) { |
| 15 eventSender.mouseMoveTo(textfield.offsetLeft + textfield.offsetWidth
- 4, textfield.offsetTop + 4); |
| 16 eventSender.mouseDown(); |
| 17 eventSender.mouseUp(); |
| 18 shouldBeZero('textfield.selectionStart'); |
| 19 shouldBe('textfield.selectionEnd', '5'); |
| 20 |
| 21 eventSender.mouseMoveTo(textfield.offsetLeft + textfield.offsetWidth
- 4, textfield.offsetTop + 4); |
| 22 eventSender.mouseDown(); |
| 23 eventSender.mouseUp(); |
| 24 debug('\nthe selection should be cleared'); |
| 25 shouldBeNonZero('textfield.selectionStart'); |
| 26 shouldBeNonZero('textfield.selectionEnd'); |
| 27 } |
| 28 finishJSTest(); |
| 29 } |
| 30 |
| 31 function setSelectionRange(e) { |
| 32 var textfield = document.getElementById('textfield'); |
| 33 textfield.setSelectionRange(0, 5); |
| 34 } |
| 35 </script> |
| 36 <input type="text" value="This text field is for the selection test" id="textfie
ld"></input> |
OLD | NEW |