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