OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../../resources/testharness.js"></script> | |
3 <script src="../../resources/testharnessreport.js"></script> | |
4 <script> | |
5 async_test(function(t) { | |
6 window.onload = t.step_func(function() { | |
7 if (window.eventSender) { | |
yosin_UTC9
2015/07/13 03:47:22
nit: Could you use early return pattern?
Miyoung Shin(g)
2015/07/13 04:23:49
Done.
| |
8 doSetSelectionRange('focus'); | |
9 doSetSelectionRange('mousedown'); | |
10 doSetSelectionRange('mouseup'); | |
11 doSetSelectionRange('click'); | |
12 t.done(); | |
13 } | |
14 }); | |
15 | |
16 function doSetSelectionRange(eventType) { | |
17 var textfield = document.getElementById('textfield'); | |
18 textfield.setSelectionRange(0, 1); | |
19 var tx = textfield.offsetLeft + 4; | |
20 var ty = textfield.offsetTop + 4; | |
21 | |
22 textfield.addEventListener(eventType, setSelectionRange); | |
23 eventSender.mouseMoveTo(tx, ty); | |
24 eventSender.mouseDown(); | |
25 eventSender.mouseUp(); | |
26 if (eventType === 'mousedown') { | |
27 assert_equals(textfield.selectionStart, 0); | |
28 assert_equals(textfield.selectionEnd, 0); | |
29 } else { | |
30 assert_equals(textfield.selectionStart, 0); | |
31 assert_equals(textfield.selectionEnd, 5); | |
32 } | |
33 | |
34 eventSender.leapForward(1000); | |
35 eventSender.mouseMoveTo(textfield.offsetLeft , textfield.offsetTop); | |
36 eventSender.mouseDown(); | |
37 eventSender.mouseUp(); | |
38 textfield.blur(); | |
39 | |
40 assert_equals(textfield.selectionStart, 0); | |
41 assert_equals(textfield.selectionEnd, 0); | |
42 textfield.removeEventListener(eventType, setSelectionRange); | |
43 } | |
44 | |
45 function setSelectionRange(e) { | |
46 var textfield = document.getElementById('textfield'); | |
47 textfield.setSelectionRange(0, textfield.value.length); | |
48 } | |
49 }, "This tests the selection of the text field after setSelectionRange is called ."); | |
50 </script> | |
51 <input type="text" value="value" id="textfield"></input> | |
OLD | NEW |