1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
8 <div id=
"console"></div>
12 description("This tests that cancelling a speech job fires the right events.");
14 if (window
.testRunner
)
15 testRunner
.waitUntilDone();
18 window
.internals
.enableMockSpeechSynthesizer(document
);
20 window
.jsTestIsAsync
= true;
22 var u
= new SpeechSynthesisUtterance("this is a test");
23 u
.onstart = function(event
) {
24 debug("Speech started");
27 u
.onerror = function(event
) {
28 debug("Speech error received because we cancelled and speech should no longer be pending.");
29 shouldBeFalse("speechSynthesis.pending");
33 // Queue the first job which will start speaking immediately.
34 speechSynthesis
.speak(u
);
36 // Make a few more jobs, so that when we cancel, it will clear the entire queue.
37 var u2
= new SpeechSynthesisUtterance("this is a second test");
38 speechSynthesis
.speak(u2
);
40 // Make a few more jobs, so that when we cancel, it will clear the entire queue.
41 var u3
= new SpeechSynthesisUtterance("this is a third test");
42 speechSynthesis
.speak(u3
);
44 // While we have two jobs, speech synthesis should report that it's pending.
45 shouldBeTrue("speechSynthesis.pending");
48 setTimeout("speechSynthesis.cancel()", 1);