Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <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
| |
| 3 <script> | |
| 4 description("This tests the selection of the text field after setSelectionRa nge is called during a tap"); | |
| 5 window.onload = function() { | |
| 6 if (window.eventSender) { | |
| 7 doSetSelectionRange('focus'); | |
| 8 doSetSelectionRange('mousedown'); | |
| 9 doSetSelectionRange('mouseup'); | |
| 10 doSetSelectionRange('click'); | |
| 11 } | |
| 12 } | |
| 13 | |
| 14 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.
| |
| 15 debug(event + ' test :'); | |
| 16 var textfield = document.getElementById('textfield'); | |
| 17 textfield.setSelectionRange(0, 0); | |
| 18 var tx = textfield.offsetLeft + 4; | |
| 19 var ty = textfield.offsetTop + 4; | |
| 20 | |
| 21 textfield.addEventListener(event, setSelectionRange); | |
| 22 eventSender.gestureTapDown(tx, ty); | |
| 23 eventSender.gestureShowPress(tx, ty); | |
| 24 eventSender.gestureTap(tx, ty); | |
| 25 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.
| |
| 26 shouldBe('textfield.selectionStart', '0'); | |
|
yosin_UTC9
2015/07/06 01:57:29
|shouldBeZero()|
| |
| 27 shouldBe('textfield.selectionEnd', '0'); | |
|
yosin_UTC9
2015/07/06 01:57:29
|shouldBeZero()|
| |
| 28 } else { | |
| 29 shouldBe('textfield.selectionStart', '0'); | |
|
yosin_UTC9
2015/07/06 01:57:29
|shouldBeZero()|
| |
| 30 shouldBe('textfield.selectionEnd', '5'); | |
| 31 } | |
| 32 textfield.setSelectionRange(0, 0); | |
| 33 textfield.removeEventListener(event, setSelectionRange); | |
| 34 } | |
| 35 | |
| 36 function setSelectionRange(e) { | |
| 37 var textfield = document.getElementById('textfield'); | |
| 38 textfield.setSelectionRange(0, textfield.value.length); | |
| 39 } | |
| 40 </script> | |
| 41 <input type="text" value="value" id="textfield"></input> | |
| OLD | NEW |