blob: aecf3d91f80955f381d39ec3e1a872164931a16c [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script type="text/javascript">
description('Tests for speech button click with &lt;input type="text" speech>.');
function onSpeechChange() {
// Since we requested dumpRect, the rect comes back as the speech result.
var rect = input.value.split(',');
var x = parseInt(rect[0]);
var y = parseInt(rect[1]);
// Check that the rect is inside the iframe.
if (x >= iframe.offsetLeft && x <= iframe.offsetLeft + iframe.offsetWidth
&& y >= iframe.offsetTop && y <= iframe.offsetTop + iframe.offsetHeight)
testPassed("rect is inside the iframe");
else
testFailed("FAIL: rect was outside the iframe. Actual rect.x: " + x + ", rect.y: " + y);
finishJSTest();
}
function run() {
window.iframe = document.getElementById('iframe');
window.input = iframe.contentDocument.createElement('input');
input.setAttribute('x-webkit-speech');
input.onwebkitspeechchange = onSpeechChange;
iframe.contentDocument.getElementsByTagName('body')[0].appendChild(input);
if (window.testRunner && window.eventSender) {
testRunner.setMockSpeechInputDumpRect(true);
debug('Clicking the speech button.');
var x = input.offsetLeft + input.offsetWidth - 4;
var y = input.offsetTop + input.offsetHeight / 2;
x += iframe.offsetLeft;
y += iframe.offsetTop;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
}
}
window.onload = run;
window.jsTestIsAsync = true;
</script>
<script src="../../resources/js-test-post.js"></script>
<iframe id="iframe">
</body>
</html>