Bug 1331696 - P2. make the speech synth mochitests pass. r?jya
MozReview-Commit-ID: 5fzgFZa8gcT
--- a/dom/media/webspeech/synth/SpeechSynthesis.cpp
+++ b/dom/media/webspeech/synth/SpeechSynthesis.cpp
@@ -204,34 +204,35 @@ SpeechSynthesis::Cancel()
void
SpeechSynthesis::Pause()
{
if (Paused()) {
return;
}
if (mCurrentTask && !mSpeechQueue.IsEmpty() &&
- mSpeechQueue.ElementAt(0)->GetState() != SpeechSynthesisUtterance::STATE_ENDED) {
+ mSpeechQueue.ElementAt(0)->GetState() == SpeechSynthesisUtterance::STATE_SPEAKING) {
mCurrentTask->Pause();
} else {
mHoldQueue = true;
}
}
void
SpeechSynthesis::Resume()
{
if (!Paused()) {
return;
}
+ mHoldQueue = false;
+
if (mCurrentTask) {
mCurrentTask->Resume();
} else {
- mHoldQueue = false;
AdvanceQueue();
}
}
void
SpeechSynthesis::OnEnd(const nsSpeechTask* aTask)
{
MOZ_ASSERT(mCurrentTask == aTask);
--- a/dom/media/webspeech/synth/nsSpeechTask.cpp
+++ b/dom/media/webspeech/synth/nsSpeechTask.cpp
@@ -429,16 +429,19 @@ nsSpeechTask::DispatchEnd(float aElapsed
}
return DispatchEndInner(aElapsedTime, aCharIndex);
}
nsresult
nsSpeechTask::DispatchEndInner(float aElapsedTime, uint32_t aCharIndex)
{
+ // After we end, no callback functions should go through.
+ mCallback = nullptr;
+
if (!mPreCanceled) {
nsSynthVoiceRegistry::GetInstance()->SpeakNext();
}
return DispatchEndImpl(aElapsedTime, aCharIndex);
}
nsresult
--- a/dom/media/webspeech/synth/test/file_global_queue_pause.html
+++ b/dom/media/webspeech/synth/test/file_global_queue_pause.html
@@ -54,18 +54,17 @@ https://bugzilla.mozilla.org/show_bug.cg
utterance1.addEventListener('resume', function(e) {
is(eventOrder.shift(), 'resume1', 'resume1');
testSynthState(win1, { speaking: true, pending: false, paused: false});
testSynthState(win2, { speaking: true, pending: true, paused: false});
win2.speechSynthesis.pause();
testSynthState(win1, { speaking: true, pending: false, paused: false});
- // 1188099: currently, paused state is not gaurenteed to be immediate.
- testSynthState(win2, { speaking: true, pending: true });
+ testSynthState(win2, { speaking: true, pending: true, paused: true });
// We now make the utterance end.
SpecialPowers.wrap(win1.speechSynthesis).forceEnd();
});
utterance1.addEventListener('end', function(e) {
is(eventOrder.shift(), 'end1', 'end1');
testSynthState(win1, { speaking: false, pending: false, paused: false});
testSynthState(win2, { speaking: false, pending: true, paused: true});
--- a/dom/media/webspeech/synth/test/file_speech_queue.html
+++ b/dom/media/webspeech/synth/test/file_speech_queue.html
@@ -54,17 +54,18 @@ function testFunc(done_cb) {
[{text: "Come stai?", args: { lang: "it-IT-fail" } },
{ rate: 1, pitch: 1, uri: langUriMap['it-IT-fail'], err: true }],
[{text: "¡hasta mañana!", args: { lang: "es-MX" } },
{ uri: langUriMap['es-MX'] }]],
function () {
var test_data = [];
var voices = speechSynthesis.getVoices();
for (var voice of voices) {
- if (voice.voiceURI.indexOf('urn:moz-tts:fake-direct') < 0) {
+ if (voice.lang.split("-").length > 2) {
+ // Skip voices that don't automatically end with success
continue;
}
test_data.push([{text: "Hello world", args: { voice: voice} },
{uri: voice.voiceURI}]);
}
synthTestQueue(test_data, done_cb);
});