blob: 98d8476181155a6e9f7deb066a607a1ed2fc23e9 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body id="body">
<div id="console"></div>
<script>
description("This tests that cancelling a speech job fires the right events.");
if (window.testRunner)
testRunner.waitUntilDone();
if (window.internals)
window.internals.enableMockSpeechSynthesizer();
window.jsTestIsAsync = true;
var u = new SpeechSynthesisUtterance("this is a test");
u.onstart = function(event) {
debug("Speech started");
}
u.onerror = function(event) {
debug("Speech error received because we cancelled and speech should no longer be pending.");
shouldBeFalse("speechSynthesis.pending");
finishJSTest();
}
// Queue the first job which will start speaking immediately.
speechSynthesis.speak(u);
// Make a few more jobs, so that when we cancel, it will clear the entire queue.
var u2 = new SpeechSynthesisUtterance("this is a second test");
speechSynthesis.speak(u2);
// Make a few more jobs, so that when we cancel, it will clear the entire queue.
var u3 = new SpeechSynthesisUtterance("this is a third test");
speechSynthesis.speak(u3);
// While we have two jobs, speech synthesis should report that it's pending.
shouldBeTrue("speechSynthesis.pending");
// Cancel speaking.
setTimeout("speechSynthesis.cancel()", "1");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>