1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
4 <script src="../js/resources/js-test-pre.js"></script>
7 <script type="text/javascript">
8 description('Tests for speech button click with <input type="text" speech>.');
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';
17 x = input.offsetLeft + 4;
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.paddingRight.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();
31 if (window.layoutTestController && window.eventSender) {
32 layoutTestController.addMockSpeechInputResult('Pictures of the moon', 1.0, '');
33 startSpeechInput('input1');
38 document.getElementById('input2').focus();
41 function onSpeechChange() {
42 shouldBeEqualToString('document.getElementById("input1").value', 'Pictures of the moon');
43 shouldBeEqualToString('document.getElementById("input2").value', '');
48 window.jsTestIsAsync = true;
50 <script src="../js/resources/js-test-post.js"></script>
51 <input id='input1' x-webkit-speech onfocus="onFocus()" onwebkitspeechchange="onSpeechChange()">