| Index: LayoutTests/fast/forms/setrangetext-within-events.html
|
| diff --git a/LayoutTests/fast/forms/setrangetext-within-events.html b/LayoutTests/fast/forms/setrangetext-within-events.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..08ce45e200e35997804093a7df1f05e1cf59eb62
|
| --- /dev/null
|
| +++ b/LayoutTests/fast/forms/setrangetext-within-events.html
|
| @@ -0,0 +1,46 @@
|
| +<!DOCTYPE html>
|
| +<script src="../../resources/js-test.js"></script>
|
| +<script>
|
| + description("This tests the selection of the text field after setSelectionRange is called");
|
| + window.onload = function() {
|
| + if (window.eventSender) {
|
| + doSetSelectionRange('focus');
|
| + doSetSelectionRange('mousedown');
|
| + doSetSelectionRange('mouseup');
|
| + doSetSelectionRange('click');
|
| + }
|
| + }
|
| +
|
| + function doSetSelectionRange(event) {
|
| + debug(event + ' test :');
|
| + var textfield = document.getElementById('textfield');
|
| + textfield.setSelectionRange(0, 1);
|
| + var tx = textfield.offsetLeft + 4;
|
| + var ty = textfield.offsetTop + 4;
|
| +
|
| + textfield.addEventListener(event, setSelectionRange);
|
| + eventSender.mouseMoveTo(tx, ty);
|
| + eventSender.mouseDown();
|
| + eventSender.mouseUp();
|
| + if (event == 'mousedown') {
|
| + shouldBe('textfield.selectionStart', '0');
|
| + shouldBe('textfield.selectionEnd', '0');
|
| + } else {
|
| + shouldBe('textfield.selectionStart', '0');
|
| + shouldBe('textfield.selectionEnd', '5');
|
| + }
|
| + eventSender.mouseMoveTo(tx, ty + 30);
|
| + eventSender.mouseDown();
|
| + eventSender.mouseUp();
|
| + debug('the selection should be cleared');
|
| + shouldBe('textfield.selectionStart', '0');
|
| + shouldBe('textfield.selectionEnd', '0');
|
| + textfield.removeEventListener(event, setSelectionRange);
|
| + }
|
| +
|
| + function setSelectionRange(e) {
|
| + var textfield = document.getElementById('textfield');
|
| + textfield.setSelectionRange(0, textfield.value.length);
|
| + }
|
| +</script>
|
| +<input type="text" value="value" id="textfield"></input>
|
|
|