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 // Since we requested dumpRect, the rect comes back as the speech result. | |
12 var rect = input.value.split(','); | |
13 var x = parseInt(rect[0]); | |
14 var y = parseInt(rect[1]); | |
15 | |
16 // Check that the rect is inside the iframe. | |
17 if (x >= iframe.offsetLeft && x <= iframe.offsetLeft + iframe.offsetWidth | |
18 && y >= iframe.offsetTop && y <= iframe.offsetTop + iframe.offsetHei
ght) | |
19 testPassed("rect is inside the iframe"); | |
20 else | |
21 testFailed("FAIL: rect was outside the iframe. Actual rect.x: " + x + ",
rect.y: " + y); | |
22 | |
23 finishJSTest(); | |
24 } | |
25 | |
26 function run() { | |
27 window.iframe = document.getElementById('iframe'); | |
28 window.input = iframe.contentDocument.createElement('input'); | |
29 input.setAttribute('x-webkit-speech', ''); | |
30 input.onwebkitspeechchange = onSpeechChange; | |
31 iframe.contentDocument.getElementsByTagName('body')[0].appendChild(input); | |
32 | |
33 if (window.testRunner && window.eventSender) { | |
34 testRunner.setMockSpeechInputDumpRect(true); | |
35 | |
36 debug('Clicking the speech button.'); | |
37 var x = input.offsetLeft + input.offsetWidth - 4; | |
38 var y = input.offsetTop + input.offsetHeight / 2; | |
39 x += iframe.offsetLeft; | |
40 y += iframe.offsetTop; | |
41 | |
42 eventSender.mouseMoveTo(x, y); | |
43 eventSender.mouseDown(); | |
44 eventSender.mouseUp(); | |
45 } | |
46 } | |
47 | |
48 window.onload = run; | |
49 window.jsTestIsAsync = true; | |
50 </script> | |
51 <iframe id="iframe"> | |
52 </body> | |
53 </html> | |
54 | |
OLD | NEW |