| 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 startSpeechInput(id) { | |
| 11 // Clicking the speech button should fill in mock speech-recognized text. | |
| 12 var input = document.getElementById(id); | |
| 13 var isRTL = input.dir == 'rtl'; | |
| 14 var x = 0; | |
| 15 if (isRTL) | |
| 16 x = input.offsetLeft + 4; | |
| 17 else | |
| 18 x = input.offsetLeft + input.offsetWidth - 4; | |
| 19 var y = input.offsetTop + input.offsetHeight / 2; | |
| 20 if (!isRTL && input.style.paddingRight.length) | |
| 21 x -= parseInt(input.style.paddingRight.substr(0, input.style.paddingRigh
t.length - 2)); | |
| 22 else if (isRTL && input.style.paddingLeft.length) | |
| 23 x += parseInt(input.style.paddingLeft.substr(0, input.style.paddingLeft.
length - 2)); | |
| 24 eventSender.mouseMoveTo(x, y); | |
| 25 eventSender.mouseDown(); | |
| 26 eventSender.mouseUp(); | |
| 27 } | |
| 28 | |
| 29 var testIndex = 1; | |
| 30 function onWebkitSpeechChange() { | |
| 31 shouldBeEqualToString('document.getElementById("speechInput' + testIndex + '
").value', 'Pictures of the moon'); | |
| 32 if (testIndex == 4) { | |
| 33 finishJSTest(); | |
| 34 return; | |
| 35 } | |
| 36 ++testIndex; | |
| 37 setTimeout(function() { | |
| 38 startSpeechInput("speechInput" + testIndex); | |
| 39 }, 50); | |
| 40 } | |
| 41 | |
| 42 function run() { | |
| 43 if (window.testRunner && window.eventSender) { | |
| 44 testRunner.addMockSpeechInputResult('Pictures of the moon', 1.0, ''); | |
| 45 startSpeechInput("speechInput" + testIndex); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 window.onload = run; | |
| 50 window.jsTestIsAsync = true; | |
| 51 </script> | |
| 52 <input id='speechInput1' x-webkit-speech onwebkitspeechchange="onWebkitSpeechCha
nge()"> | |
| 53 <input id='speechInput2' x-webkit-speech onwebkitspeechchange="onWebkitSpeechCha
nge()" dir="rtl"> | |
| 54 <input id='speechInput3' x-webkit-speech onwebkitspeechchange="onWebkitSpeechCha
nge()" style="padding:5px 10px"> | |
| 55 <input id='speechInput4' x-webkit-speech onwebkitspeechchange="onWebkitSpeechCha
nge()" style="padding:5px 10px" dir="rtl"> | |
| 56 </body> | |
| 57 </html> | |
| 58 | |
| OLD | NEW |