blob: c21ff433696c6281b4c1c99a2548cdb2e5b66819 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<script type="text/javascript">
description('Test getting an exception when calling start() in the Speech JavaScript API');
function run() {
// Check availability of constructors.
shouldBeTrue("'webkitSpeechRecognition' in self");
shouldBeFalse("webkitSpeechRecognition == null");
doubleStart();
}
function doubleStart() {
debug('\ndoubleStart():');
evalAndLog("window.r = new webkitSpeechRecognition()");
// Set default handlers.
for (var prop in r) {
if (prop.match('^on')) {
r[prop] = function() {
debug('on' + event.type);
if (event.type === 'end') {
shouldNotThrow("r.start()");
evalAndLog("r.abort()");
r.onend = function() {
debug('onend');
finishJSTest();
}
} else {
shouldThrow("r.start()", '"InvalidStateError: Failed to execute \'start\' on \'SpeechRecognition\': recognition has already started."');
}
}
}
}
shouldNotThrow("r.start()");
shouldThrow("r.start()", '"InvalidStateError: Failed to execute \'start\' on \'SpeechRecognition\': recognition has already started."');
}
window.onload = run;
window.jsTestIsAsync = true;
</script>
</body>
</html>