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