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

Unified Diff: LayoutTests/fast/forms/setrangetext-out-of-range.html

Issue 1049233003: Keep the selection of the text field when changed by JS. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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-out-of-range.html
diff --git a/LayoutTests/fast/forms/setrangetext-out-of-range.html b/LayoutTests/fast/forms/setrangetext-out-of-range.html
new file mode 100644
index 0000000000000000000000000000000000000000..2bdf16eb01d8d625a14ff66b46b63252995682fd
--- /dev/null
+++ b/LayoutTests/fast/forms/setrangetext-out-of-range.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+async_test(function(t) {
+ window.onload = t.step_func(function() {
+ var textfield = document.getElementById('textfield');
+ textfield.addEventListener('focus', setSelectionRange);
+ textfield.setSelectionRange(0, 1);
+
+ if (!window.eventSender) {
+ t.done();
+ return;
+ }
+
+ eventSender.mouseMoveTo(textfield.offsetLeft + textfield.offsetWidth - 4, textfield.offsetTop + 4);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ assert_equals(textfield.selectionStart, 0);
+ assert_equals(textfield.selectionEnd, 5);
+
+ eventSender.leapForward(1000);
+ eventSender.mouseMoveTo(textfield.offsetLeft + textfield.offsetWidth - 4, textfield.offsetTop + 4);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+
+ assert_not_equals(textfield.selectionStart, 0);
+ assert_not_equals(textfield.selectionEnd, 0);
+
+ t.done();
+ });
+
+ function setSelectionRange(e) {
+ var textfield = document.getElementById('textfield');
+ textfield.setSelectionRange(0, 5);
+ }
+}, "This tests the selection of the text field when mouse event occurs out of range.");
+</script>
+<input type="text" value="This text field is for the selection test" id="textfield"></input>

Powered by Google App Engine
This is Rietveld 408576698