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

Side by Side Diff: LayoutTests/fast/forms/setrangetext-within-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 <script>
5 async_test(function(t) {
6 window.onload = t.step_func(function() {
7 if (!window.eventSender) {
8 t.done();
9 return;
10 }
11 doSetSelectionRange('focus');
12 doSetSelectionRange('mousedown');
13 doSetSelectionRange('mouseup');
14 doSetSelectionRange('click');
15 t.done();
16 });
17
18 function doSetSelectionRange(eventType) {
19 var textfield = document.getElementById('textfield');
20 textfield.setSelectionRange(0, 1);
21 var tx = textfield.offsetLeft + 4;
22 var ty = textfield.offsetTop + 4;
23
24 textfield.addEventListener(eventType, setSelectionRange);
25 eventSender.mouseMoveTo(tx, ty);
26 eventSender.mouseDown();
27 eventSender.mouseUp();
28 if (eventType === 'mousedown') {
29 assert_equals(textfield.selectionStart, 0);
30 assert_equals(textfield.selectionEnd, 0);
31 } else {
32 assert_equals(textfield.selectionStart, 0);
33 assert_equals(textfield.selectionEnd, 5);
34 }
35
36 eventSender.leapForward(1000);
37 eventSender.mouseMoveTo(textfield.offsetLeft , textfield.offsetTop);
38 eventSender.mouseDown();
39 eventSender.mouseUp();
40 textfield.blur();
41
42 assert_equals(textfield.selectionStart, 0);
43 assert_equals(textfield.selectionEnd, 0);
44 textfield.removeEventListener(eventType, setSelectionRange);
45 }
46
47 function setSelectionRange(e) {
48 var textfield = document.getElementById('textfield');
49 textfield.setSelectionRange(0, textfield.value.length);
50 }
51 }, "This tests the selection of the text field after setSelectionRange is called .");
52 </script>
53 <input type="text" value="value" id="textfield"></input>
OLDNEW
« no previous file with comments | « LayoutTests/fast/forms/setrangetext-out-of-range.html ('k') | Source/core/editing/FrameSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698