1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
4 <script src="../../resources/js-test.js"></script>
7 <script type="text/javascript">
8 description('Tests for speech button click with <input type="text" speech>.');
10 function onSpeechChange() {
11 // Since we requested dumpRect, the rect comes back as the speech result.
12 var rect = input.value.split(',');
13 var x = parseInt(rect[0]);
14 var y = parseInt(rect[1]);
16 // Check that the rect is inside the iframe.
17 if (x >= iframe.offsetLeft && x <= iframe.offsetLeft + iframe.offsetWidth
18 && y >= iframe.offsetTop && y <= iframe.offsetTop + iframe.offsetHeight)
19 testPassed("rect is inside the iframe");
21 testFailed("FAIL: rect was outside the iframe. Actual rect.x: " + x + ", rect.y: " + y);
27 window.iframe = document.getElementById('iframe');
28 window.input = iframe.contentDocument.createElement('input');
29 input.setAttribute('x-webkit-speech', '');
30 input.onwebkitspeechchange = onSpeechChange;
31 iframe.contentDocument.getElementsByTagName('body')[0].appendChild(input);
33 if (window.testRunner && window.eventSender) {
34 testRunner.setMockSpeechInputDumpRect(true);
36 debug('Clicking the speech button.');
37 var x = input.offsetLeft + input.offsetWidth - 4;
38 var y = input.offsetTop + input.offsetHeight / 2;
39 x += iframe.offsetLeft;
40 y += iframe.offsetTop;
42 eventSender.mouseMoveTo(x, y);
43 eventSender.mouseDown();
44 eventSender.mouseUp();
49 window.jsTestIsAsync = true;