Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: LayoutTests/fast/events/touch/gesture/gesture-tap-setrangetext-with-events.html

Issue 1049233003: Keep the selection of the text field when changed by JS. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../../../resources/testharness.js"></script>
3 <script src="../../../../resources/testharnessreport.js"></script>
4 <input type="text" value="value" id="textfield"></input>
5 <script>
6 async_test(function(t) {
7 window.onload = t.step_func(function() {
8 if (window.eventSender) {
9 doSetSelectionRange('focus');
10 doSetSelectionRange('mousedown');
11 doSetSelectionRange('mouseup');
12 doSetSelectionRange('click');
13 t.done();
14 }
15 });
16
17 function doSetSelectionRange(eventType) {
18 var textfield = document.getElementById('textfield');
19 textfield.setSelectionRange(0, 0);
20 var tx = textfield.offsetLeft + 4;
21 var ty = textfield.offsetTop + 4;
22
23 textfield.addEventListener(eventType, setSelectionRange);
24 eventSender.gestureTapDown(tx, ty);
25 eventSender.gestureShowPress(tx, ty);
26 eventSender.gestureTap(tx, ty);
27 if (eventType === 'mousedown') {
28 assert_equals(textfield.selectionStart, 0);
29 assert_equals(textfield.selectionEnd, 0);
30 } else {
31 assert_equals(textfield.selectionStart, 0);
32 assert_equals(textfield.selectionEnd, 5);
33 }
34 textfield.setSelectionRange(0, 0);
35 textfield.removeEventListener(eventType, setSelectionRange);
36 }
37
38 function setSelectionRange(e) {
39 var textfield = document.getElementById('textfield');
40 textfield.setSelectionRange(0, textfield.value.length);
41 }
42 }, "This tests the selection of the text field after setSelectionRange is called during a tap.");
43 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698