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

Unified Diff: LayoutTests/fast/events/touch/gesture/gesture-tap-setrangetext-with-events.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/events/touch/gesture/gesture-tap-setrangetext-with-events.html
diff --git a/LayoutTests/fast/events/touch/gesture/gesture-tap-setrangetext-with-events.html b/LayoutTests/fast/events/touch/gesture/gesture-tap-setrangetext-with-events.html
new file mode 100644
index 0000000000000000000000000000000000000000..8e6b244b019f7c71fcddb201b21073ebb48115fc
--- /dev/null
+++ b/LayoutTests/fast/events/touch/gesture/gesture-tap-setrangetext-with-events.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<script src="../../../../resources/js-test.js"></script>
yosin_UTC9 2015/07/06 01:57:30 This is optional. Do you want to try new framewor
Miyoung Shin(g) 2015/07/13 03:32:57 I've changed all test cases of this patch to W3C t
+<script>
+ description("This tests the selection of the text field after setSelectionRange is called during a tap");
+ window.onload = function() {
+ if (window.eventSender) {
+ doSetSelectionRange('focus');
+ doSetSelectionRange('mousedown');
+ doSetSelectionRange('mouseup');
+ doSetSelectionRange('click');
+ }
+ }
+
+ function doSetSelectionRange(event) {
yosin_UTC9 2015/07/06 01:57:29 nit: It is better to use |eventType| or |eventName
Miyoung Shin(g) 2015/07/13 03:32:57 Done.
+ debug(event + ' test :');
+ var textfield = document.getElementById('textfield');
+ textfield.setSelectionRange(0, 0);
+ var tx = textfield.offsetLeft + 4;
+ var ty = textfield.offsetTop + 4;
+
+ textfield.addEventListener(event, setSelectionRange);
+ eventSender.gestureTapDown(tx, ty);
+ eventSender.gestureShowPress(tx, ty);
+ eventSender.gestureTap(tx, ty);
+ if (event == 'mousedown') {
yosin_UTC9 2015/07/06 01:57:29 nit: s/==/===/
Miyoung Shin(g) 2015/07/13 03:32:57 Done. I've changed it to === operator.
+ shouldBe('textfield.selectionStart', '0');
yosin_UTC9 2015/07/06 01:57:29 |shouldBeZero()|
+ shouldBe('textfield.selectionEnd', '0');
yosin_UTC9 2015/07/06 01:57:29 |shouldBeZero()|
+ } else {
+ shouldBe('textfield.selectionStart', '0');
yosin_UTC9 2015/07/06 01:57:29 |shouldBeZero()|
+ shouldBe('textfield.selectionEnd', '5');
+ }
+ textfield.setSelectionRange(0, 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>

Powered by Google App Engine
This is Rietveld 408576698