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

Side by Side Diff: LayoutTests/fast/forms/setrangetext-within-events.html

Issue 507533002: Fix to keep the selection of the text field in input element after setSelectionRange is called by d… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | LayoutTests/fast/forms/setrangetext-within-events-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 window.onload = function() {
5 if (window.eventSender) {
6 doSetSelectionRange('focus');
7 doSetSelectionRange('mousedown');
8 doSetSelectionRange('mouseup');
9 doSetSelectionRange('click');
10 }
11 }
12
13 function doSetSelectionRange(event) {
14 debug(event + ' :');
15 var textfield = document.getElementById('textfield');
16 var tx = textfield.offsetLeft + 4;
17 var ty = textfield.offsetTop + 4;
18
19 textfield.addEventListener(event, setSelectionRange);
20 eventSender.mouseMoveTo(tx, ty);
21 if (event == 'mousedown') {
22 eventSender.mouseDown();
23 eventSender.mouseUp();
24 shouldBe('textfield.selectionStart', '0');
25 shouldBe('textfield.selectionEnd', '0');
26 }
yosin_UTC9 2014/08/28 00:54:29 nit: Please align "}" and "else" like: "} else {"
27 else {
28 eventSender.mouseDown();
29 eventSender.mouseUp();
30 shouldBe('textfield.selectionStart', '0');
31 shouldBe('textfield.selectionEnd', '5');
32 }
33 eventSender.mouseMoveTo(tx, ty + 100);
34 eventSender.mouseDown();
35 eventSender.mouseUp();
36 textfield.removeEventListener(event, setSelectionRange);
37 }
38
39 function setSelectionRange(e) {
40 var textfield = document.getElementById('textfield');
41 textfield.setSelectionRange(0, textfield.value.length);
42 }
43 </script>
44 <input type="text" value="value" id="textfield"></input>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/forms/setrangetext-within-events-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698