| 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 debug('Clicking on speech button.'); | |
| 13 var input = document.getElementById(id); | |
| 14 var isRTL = input.dir == 'rtl'; | |
| 15 var x = 0; | |
| 16 if (isRTL) | |
| 17 x = input.offsetLeft + 4; | |
| 18 else | |
| 19 x = input.offsetLeft + input.offsetWidth - 4; | |
| 20 var y = input.offsetTop + input.offsetHeight / 2; | |
| 21 if (!isRTL && input.style.paddingRight.length) | |
| 22 x -= parseInt(input.style.paddingRight.substr(0, input.style.paddingRigh
t.length - 2)); | |
| 23 else if (isRTL && input.style.paddingLeft.length) | |
| 24 x += parseInt(input.style.paddingLeft.substr(0, input.style.paddingLeft.
length - 2)); | |
| 25 eventSender.mouseMoveTo(x, y); | |
| 26 eventSender.mouseDown(); | |
| 27 eventSender.mouseUp(); | |
| 28 } | |
| 29 | |
| 30 function run() { | |
| 31 if (window.testRunner && window.eventSender) { | |
| 32 testRunner.addMockSpeechInputResult('Pictures of the moon', 1.0, ''); | |
| 33 startSpeechInput('input1'); | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 function onFocus() { | |
| 38 document.getElementById('input2').focus(); | |
| 39 } | |
| 40 | |
| 41 function onSpeechChange() { | |
| 42 shouldBeEqualToString('document.getElementById("input1").value', 'Pictures o
f the moon'); | |
| 43 shouldBeEqualToString('document.getElementById("input2").value', ''); | |
| 44 finishJSTest(); | |
| 45 } | |
| 46 | |
| 47 window.onload = run; | |
| 48 window.jsTestIsAsync = true; | |
| 49 </script> | |
| 50 <input id='input1' x-webkit-speech onfocus="onFocus()" onwebkitspeechchange="onS
peechChange()"> | |
| 51 <input id='input2'> | |
| 52 </body> | |
| 53 </html> | |
| OLD | NEW |