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

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: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/forms/setrangetext-within-events-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f5ea6b577874da468a87d91dd731a9e821f4729f
--- /dev/null
+++ b/LayoutTests/fast/forms/setrangetext-within-events.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<script src="../../resources/js-test.js"></script>
+<script>
+ description("This tests the selection of the text field after setSelectionRange is called");
+ window.onload = function() {
+ if (window.eventSender) {
+ doSetSelectionRange('focus');
+ doSetSelectionRange('mousedown');
+ doSetSelectionRange('mouseup');
+ doSetSelectionRange('click');
+ }
+ }
+
+ function doSetSelectionRange(event) {
+ debug(event + ' test :');
+ var textfield = document.getElementById('textfield');
+ textfield.setSelectionRange(0, 1);
+ var tx = textfield.offsetLeft + 4;
+ var ty = textfield.offsetTop + 4;
+
+ textfield.addEventListener(event, setSelectionRange);
+ eventSender.mouseMoveTo(tx, ty);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ if (event == 'mousedown') {
+ shouldBe('textfield.selectionStart', '0');
+ shouldBe('textfield.selectionEnd', '0');
+ } else {
+ shouldBe('textfield.selectionStart', '0');
+ shouldBe('textfield.selectionEnd', '5');
+ }
+ eventSender.mouseMoveTo(tx, ty + 30);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ debug('the selection should be cleared');
+ shouldBe('textfield.selectionStart', '0');
+ shouldBe('textfield.selectionEnd', '0');
+ textfield.removeEventListener(event, setSelectionRange);
+ }
+
+ function setSelectionRange(e) {
+ var textfield = document.getElementById('textfield');
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698