OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> |
| 5 </head> |
| 6 <body> |
| 7 <script> |
| 8 description("This tests that multiple speak utterances are handled in sequen
ce."); |
| 9 |
| 10 if (window.internals) |
| 11 window.internals.enableMockSpeechSynthesizer(document); |
| 12 |
| 13 if (window.testRunner) |
| 14 testRunner.waitUntilDone(); |
| 15 |
| 16 window.jsTestIsAsync = true; |
| 17 |
| 18 var count = 3; |
| 19 var i = 0; |
| 20 |
| 21 // Start a very short speaking job that will finish quickly. |
| 22 var u = new SpeechSynthesisUtterance(" "); |
| 23 u.onstart = function(event) { |
| 24 shouldBeTrue("event.elapsedTime > 0"); |
| 25 shouldBeTrue("speechSynthesis.speaking"); |
| 26 }; |
| 27 u.onend = function(event) { |
| 28 shouldBeGreaterThanOrEqual("count", "i"); |
| 29 shouldBeTrue("event.elapsedTime > 0"); |
| 30 shouldBeTrue("speechSynthesis.speaking"); |
| 31 if (++i == count) { |
| 32 speechSynthesis.cancel(); |
| 33 // Add a new utterance just after the cancel() to signal test comple
tion. |
| 34 speechSynthesis.speak(finishingUtterance); |
| 35 } |
| 36 }; |
| 37 |
| 38 var finishingUtterance = new SpeechSynthesisUtterance(" "); |
| 39 finishingUtterance.onend = finishJSTest; |
| 40 |
| 41 shouldBeFalse("speechSynthesis.speaking"); |
| 42 // Issue more utterances than where we break off. |
| 43 for (var j = 0; j < count + 2; ++j) |
| 44 speechSynthesis.speak(u); |
| 45 </script> |
| 46 </body> |
| 47 </html> |
OLD | NEW |