Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<title>SpeechRecognition onstart and onend events</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(async t => {
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
// Promise that resolves when the 'start' event is fired.
const startPromise = new Promise(resolve => {
recognition.onstart = () => {
resolve();
};
});
// Promise that resolves when the 'end' event is fired.
const endPromise = new Promise(resolve => {
recognition.onend = () => {
resolve();
};
});
// Start speech recognition.
recognition.start();
// Wait for the 'start' event.
await startPromise;
// Stop speech recognition.
recognition.stop();
// Wait for the 'end' event.
await endPromise;
}, 'Speech recognition onstart and onend events are called.');
</script>