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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/forms/setrangetext-within-events.html
diff --git a/LayoutTests/fast/forms/setrangetext-within-events.html b/LayoutTests/fast/forms/setrangetext-within-events.html
new file mode 100644
index 0000000000000000000000000000000000000000..f0e4c81571d708223f3b57917f79129843dad26a
--- /dev/null
+++ b/LayoutTests/fast/forms/setrangetext-within-events.html
@@ -0,0 +1,38 @@
+<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
+<head>
+<script>
+ function test() {
+ if (window.testRunner && window.eventSender) {
+ testRunner.dumpAsText();
+ doSetSelectionRange("focus");
+ doSetSelectionRange("mousedown");
+ doSetSelectionRange("mouseup");
+ doSetSelectionRange("click");
+ }
+ }
+ 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
+ var textfield = document.getElementById('textfield');
yosin_UTC9 2014/08/26 03:55:07 nit: Please use one type of quote in script, L7-L8
+ var tx = textfield.offsetLeft + textfield.offsetWidth / 2;
+ var ty = textfield.offsetTop + 4;
+ textfield.addEventListener(event, setSelectionRange);
+ eventSender.mouseMoveTo(tx, ty);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ alert('start: ' + textfield.selectionStart + ' end: ' + textfield.selectionEnd + ' [' + event + ']');
yosin_UTC9 2014/08/26 03:55:08 Could you use "resources/js-test.js" framework?
+
+ eventSender.mouseMoveTo(tx, ty+100);
yosin_UTC9 2014/08/26 03:55:07 nit: Please have spaces around |+|.
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ textfield.removeEventListener(event, setSelectionRange, false);
yosin_UTC9 2014/08/26 03:55:08 nit: You don't need to have third argument |false|
+ }
+ function setSelectionRange(e) {
yosin_UTC9 2014/08/26 03:55:08 We can omit parameter |e|. Since, it isn't used.
+ var textfield = document.getElementById('textfield');
+ textfield.setSelectionRange(0, textfield.value.length)
+ }
+</script>
+</head>
+<body onload="test()">
yosin_UTC9 2014/08/26 03:55:07 nit: You can use window.onload = function() { ...
+ <input type="text" value="value" id="textfield"></input>
+</body>
+</html>
+
yosin_UTC9 2014/08/26 03:55:07 nit: Please remove an extra blank line.
« 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