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

Side by Side Diff: content/test/data/touch_selection.html

Issue 23823004: Re-enable TouchCursorInTextfieldTest with some fixes and logs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added some comments Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/touch_editable_impl_aura_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <div id='textDiv'>Some text we can select</div> 2 <div id='textDiv'>Some text we can select</div>
3 <input id='textfield' type="text" value="Text in a textfield"> 3 <input id='textfield' type="text" value="Text in a textfield">
4 <script> 4 <script>
5 5
6 function select_all_text() { 6 function select_all_text() {
7 var div = document.getElementById("textDiv"); 7 var div = document.getElementById("textDiv");
8 var range = document.createRange(); 8 var range = document.createRange();
9 range.selectNodeContents(div); 9 range.selectNodeContents(div);
10 var sel = window.getSelection(); 10 var sel = window.getSelection();
11 sel.removeAllRanges(); 11 sel.removeAllRanges();
12 sel.addRange(range); 12 sel.addRange(range);
13 } 13 }
14 14
15 function get_selection() { 15 function get_selection() {
16 return (window.getSelection() + ""); 16 return (window.getSelection() + "");
17 } 17 }
18 18
19 function focus_textfield() { 19 function focus_textfield() {
20 document.getElementById("textfield").focus(); 20 document.getElementById("textfield").focus();
21 // Focusing the textfiled selects its text. Collapse selection to a cursor.
22 window.getSelection().collapseToStart();
21 } 23 }
22 24
23 function get_cursor_position() { 25 function get_cursor_position() {
24 var div = document.getElementById("textfield"); 26 var div = document.getElementById("textfield");
25 var start = div.selectionStart; 27 var start = div.selectionStart;
26 var end = div.selectionEnd; 28 var end = div.selectionEnd;
27 if (start == end) 29 if (start == end)
28 return start; 30 return start;
29 else 31 else
30 return -1; 32 return -1;
31 } 33 }
32 34
33 </script> 35 </script>
34 36
35 </html> 37 </html>
OLDNEW
« no previous file with comments | « content/browser/web_contents/touch_editable_impl_aura_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698