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 the onspeechchange event with <input type="text" speec
h>.'); | |
9 | |
10 var results; | |
11 function onSpeechChange(event) { | |
12 results = event.results; | |
13 shouldBeEqualToString('document.getElementById("speechInput").value', 'Green
eggs and ham'); | |
14 shouldEvaluateTo('results.length', 3); | |
15 shouldBeEqualToString('results[0].utterance', 'Green eggs and ham'); | |
16 shouldEvaluateTo('results[0].confidence', 0.8); | |
17 shouldBeEqualToString('results[1].utterance', 'Green x and ham'); | |
18 shouldEvaluateTo('results[1].confidence', 0.5); | |
19 shouldBeEqualToString('results[2].utterance', '3 x and am'); | |
20 shouldEvaluateTo('results[2].confidence', 0.2); | |
21 shouldBeNull("results.item(-1)"); | |
22 finishJSTest(); | |
23 } | |
24 | |
25 function run() { | |
26 if (window.testRunner && window.eventSender) { | |
27 testRunner.addMockSpeechInputResult('Green eggs and ham', 0.8, ''); | |
28 testRunner.addMockSpeechInputResult('Green x and ham', 0.5, ''); | |
29 testRunner.addMockSpeechInputResult('3 x and am', 0.2, ''); | |
30 | |
31 // Clicking the speech button should fill in mock speech-recognized text
. | |
32 var input = document.getElementById('speechInput'); | |
33 var x = input.offsetLeft + input.offsetWidth - 4; | |
34 var y = input.offsetTop + input.offsetHeight / 2; | |
35 eventSender.mouseMoveTo(x, y); | |
36 eventSender.mouseDown(); | |
37 eventSender.mouseUp(); | |
38 } | |
39 } | |
40 | |
41 window.onload = run; | |
42 window.jsTestIsAsync = true; | |
43 </script> | |
44 <input id='speechInput' x-webkit-speech onwebkitspeechchange="onSpeechChange(eve
nt)"> | |
45 </body> | |
46 </html> | |
OLD | NEW |