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

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: 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..4ee6bb4beaef57a64080dd4c746b61870ef90e13
--- /dev/null
+++ b/LayoutTests/fast/forms/setrangetext-within-events.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<script src="../../resources/js-test.js"></script>
+<script>
+ window.onload = function() {
Rick Byers 2014/08/28 18:16:41 please add a description() call
Miyoung Shin(g) 2014/08/29 14:18:52 OK, I will
+ if (window.eventSender) {
+ doSetSelectionRange('focus');
+ doSetSelectionRange('mousedown');
+ doSetSelectionRange('mouseup');
+ doSetSelectionRange('click');
+ }
+ }
+
+ function doSetSelectionRange(event) {
+ debug(event + ' :');
+ var textfield = document.getElementById('textfield');
+ var tx = textfield.offsetLeft + 4;
+ var ty = textfield.offsetTop + 4;
+
+ textfield.addEventListener(event, setSelectionRange);
+ eventSender.mouseMoveTo(tx, ty);
+ if (event == 'mousedown') {
Rick Byers 2014/08/28 18:16:41 is this behavior of clearing for changes in moused
Miyoung Shin(g) 2014/08/29 14:18:52 This is intended to work like it. I referred tota
Rick Byers 2014/08/29 15:48:05 Sounds reasonable, thanks.
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ shouldBe('textfield.selectionStart', '0');
+ shouldBe('textfield.selectionEnd', '0');
+ } else {
+ eventSender.mouseDown();
+ eventSender.mouseUp();
Rick Byers 2014/08/28 18:16:41 The first three lines here are duplicated with abo
Miyoung Shin(g) 2014/08/29 14:18:52 OK, I will
+ shouldBe('textfield.selectionStart', '0');
+ shouldBe('textfield.selectionEnd', '5');
+ }
+ eventSender.mouseMoveTo(tx, ty + 100);
Rick Byers 2014/08/28 18:16:41 Is this click here to clear the selection? If so
Miyoung Shin(g) 2014/08/29 14:18:52 OK, I will
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ textfield.removeEventListener(event, setSelectionRange);
+ }
+
+ function setSelectionRange(e) {
+ var textfield = document.getElementById('textfield');
Rick Byers 2014/08/28 18:16:41 perhaps this function should output a log entry to
Miyoung Shin(g) 2014/08/29 14:18:52 If I try to output here, we may lost focus of inpu
Rick Byers 2014/08/29 15:48:05 Ok, even better then - how about resetting the sel
+ textfield.setSelectionRange(0, textfield.value.length);
+ }
+</script>
+<input type="text" value="value" id="textfield"></input>
« no previous file with comments | « no previous file | LayoutTests/fast/forms/setrangetext-within-events-expected.txt » ('j') | Source/core/page/EventHandler.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698