blob: 70ba83d7878bc8589c69f069cd07b62ff2ce6e23 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.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)
internals.enableMockSpeechSynthesizer(window);
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>
</body>
</html>