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

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: fix the indentation of HTML document 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
OLDNEW
(Empty)
1 <html>
yosin_UTC9 2014/08/26 03:55:07 nit: We don't need to have HTML and HEAD.
yosin_UTC9 2014/08/26 03:55:08 nit: Please <!DOCTYPE html>. We prefer to use stri
2 <head>
3 <script>
4 function test() {
5 if (window.testRunner && window.eventSender) {
6 testRunner.dumpAsText();
7 doSetSelectionRange("focus");
8 doSetSelectionRange("mousedown");
9 doSetSelectionRange("mouseup");
10 doSetSelectionRange("click");
11 }
12 }
13 function doSetSelectionRange (event) {
yosin_UTC9 2014/08/26 03:55:07 nit: Please insert a blank line to separate functi
yosin_UTC9 2014/08/26 03:55:08 nit: No need to have a space between function name
14 var textfield = document.getElementById('textfield');
yosin_UTC9 2014/08/26 03:55:07 nit: Please use one type of quote in script, L7-L8
15 var tx = textfield.offsetLeft + textfield.offsetWidth / 2;
16 var ty = textfield.offsetTop + 4;
17 textfield.addEventListener(event, setSelectionRange);
18 eventSender.mouseMoveTo(tx, ty);
19 eventSender.mouseDown();
20 eventSender.mouseUp();
21 alert('start: ' + textfield.selectionStart + ' end: ' + textfield.select ionEnd + ' [' + event + ']');
yosin_UTC9 2014/08/26 03:55:08 Could you use "resources/js-test.js" framework?
22
23 eventSender.mouseMoveTo(tx, ty+100);
yosin_UTC9 2014/08/26 03:55:07 nit: Please have spaces around |+|.
24 eventSender.mouseDown();
25 eventSender.mouseUp();
26 textfield.removeEventListener(event, setSelectionRange, false);
yosin_UTC9 2014/08/26 03:55:08 nit: You don't need to have third argument |false|
27 }
28 function setSelectionRange(e) {
yosin_UTC9 2014/08/26 03:55:08 We can omit parameter |e|. Since, it isn't used.
29 var textfield = document.getElementById('textfield');
30 textfield.setSelectionRange(0, textfield.value.length)
31 }
32 </script>
33 </head>
34 <body onload="test()">
yosin_UTC9 2014/08/26 03:55:07 nit: You can use window.onload = function() { ...
35 <input type="text" value="value" id="textfield"></input>
36 </body>
37 </html>
38
yosin_UTC9 2014/08/26 03:55:07 nit: Please remove an extra blank line.
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/forms/setrangetext-within-events-expected.txt » ('j') | Source/core/editing/FrameSelection.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698