OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | |
7 <script type="text/javascript"> | |
8 description('Tests for speech button click with <input type="text" speech>.')
; | |
9 | |
10 function onSpeechChange() { | |
11 debug('onSpeechChange'); | |
12 var rect = input.value.split(','); | |
13 var x = parseInt(rect[0]); | |
14 var y = parseInt(rect[1]); | |
15 | |
16 if (Math.abs(x - clickTargetX) > 20) { | |
17 testFailed('x too far away from clickTargetX'); | |
18 debug('x: ' + x + ' clickTargetX: ' + clickTargetX); | |
19 } else { | |
20 debug('x OK'); | |
21 } | |
22 | |
23 if (Math.abs(y - clickTargetY) > 20) { | |
24 testFailed('y too far away from clickTargetY'); | |
25 debug('y: ' + y + ' clickTargetY: ' + clickTargetY); | |
26 } else { | |
27 debug('y OK'); | |
28 } | |
29 | |
30 finishJSTest(); | |
31 } | |
32 | |
33 function run() { | |
34 window.input = document.getElementsByTagName('input')[0]; | |
35 input.onwebkitspeechchange = onSpeechChange; | |
36 | |
37 var scrollAmount = 100; | |
38 window.scrollTo(0, scrollAmount); | |
39 | |
40 if (window.testRunner && window.eventSender) { | |
41 testRunner.setMockSpeechInputDumpRect(true); | |
42 debug('Clicking the speech button.'); | |
43 | |
44 window.clickTargetX = input.offsetLeft + input.offsetWidth - 4; | |
45 window.clickTargetY = input.offsetTop + input.offsetHeight / 2; | |
46 | |
47 clickTargetY -= scrollAmount; | |
48 | |
49 eventSender.mouseMoveTo(clickTargetX, clickTargetY); | |
50 eventSender.mouseDown(); | |
51 eventSender.mouseUp(); | |
52 } | |
53 } | |
54 | |
55 window.onload = run; | |
56 window.jsTestIsAsync = true; | |
57 </script> | |
58 <div style="height: 200px"></div> | |
59 <input x-webkit-speech> | |
60 <div style="height: 1000px"></div> | |
61 </body> | |
62 </html> | |
OLD | NEW |