diff --git a/dom/media/webspeech/synth/ipc/PSpeechSynthesisRequest.ipdl b/dom/media/webspeech/synth/ipc/PSpeechSynthesisRequest.ipdl index da75234e1b42..db02f04868fe 100644 --- a/dom/media/webspeech/synth/ipc/PSpeechSynthesisRequest.ipdl +++ b/dom/media/webspeech/synth/ipc/PSpeechSynthesisRequest.ipdl @@ -15,6 +15,8 @@ async protocol PSpeechSynthesisRequest parent: + __delete__(); + Pause(); Resume(); @@ -27,7 +29,7 @@ async protocol PSpeechSynthesisRequest child: - __delete__(bool aIsError, float aElapsedTime, uint32_t aCharIndex); + OnEnd(bool aIsError, float aElapsedTime, uint32_t aCharIndex); OnStart(nsString aUri); diff --git a/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp b/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp index 0de3030d0940..983e210db966 100644 --- a/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp +++ b/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp @@ -87,10 +87,11 @@ SpeechSynthesisRequestChild::RecvOnStart(const nsString& aUri) } bool -SpeechSynthesisRequestChild::Recv__delete__(const bool& aIsError, - const float& aElapsedTime, - const uint32_t& aCharIndex) +SpeechSynthesisRequestChild::RecvOnEnd(const bool& aIsError, + const float& aElapsedTime, + const uint32_t& aCharIndex) { + SpeechSynthesisRequestChild* actor = mTask->mActor; mTask->mActor = nullptr; if (aIsError) { @@ -99,6 +100,8 @@ SpeechSynthesisRequestChild::Recv__delete__(const bool& aIsError, mTask->DispatchEndImpl(aElapsedTime, aCharIndex); } + actor->Send__delete__(actor); + return true; } diff --git a/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.h b/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.h index 5f4c8f1920c6..37e8da3e5841 100644 --- a/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.h +++ b/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.h @@ -52,9 +52,9 @@ public: protected: virtual bool RecvOnStart(const nsString& aUri) override; - virtual bool Recv__delete__(const bool& aIsError, - const float& aElapsedTime, - const uint32_t& aCharIndex) override; + virtual bool RecvOnEnd(const bool& aIsError, + const float& aElapsedTime, + const uint32_t& aCharIndex) override; virtual bool RecvOnPause(const float& aElapsedTime, const uint32_t& aCharIndex) override; diff --git a/dom/media/webspeech/synth/ipc/SpeechSynthesisParent.cpp b/dom/media/webspeech/synth/ipc/SpeechSynthesisParent.cpp index 9ec28ff1dbab..5e5d20286c01 100644 --- a/dom/media/webspeech/synth/ipc/SpeechSynthesisParent.cpp +++ b/dom/media/webspeech/synth/ipc/SpeechSynthesisParent.cpp @@ -82,9 +82,6 @@ SpeechSynthesisRequestParent::SpeechSynthesisRequestParent(SpeechTaskParent* aTa SpeechSynthesisRequestParent::~SpeechSynthesisRequestParent() { - if (mTask && mTask->mActor) { - mTask->mActor = nullptr; - } MOZ_COUNT_DTOR(SpeechSynthesisRequestParent); } @@ -103,6 +100,15 @@ SpeechSynthesisRequestParent::RecvPause() return true; } +bool +SpeechSynthesisRequestParent::Recv__delete__() +{ + MOZ_ASSERT(mTask); + mTask->mActor = nullptr; + mTask = nullptr; + return true; +} + bool SpeechSynthesisRequestParent::RecvResume() { @@ -152,9 +158,7 @@ nsresult SpeechTaskParent::DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex) { MOZ_ASSERT(mActor); - SpeechSynthesisRequestParent* actor = mActor; - mActor = nullptr; - if(NS_WARN_IF(!(actor->Send__delete__(actor, false, aElapsedTime, aCharIndex)))) { + if(NS_WARN_IF(!(mActor->SendOnEnd(false, aElapsedTime, aCharIndex)))) { return NS_ERROR_FAILURE; } @@ -187,9 +191,7 @@ nsresult SpeechTaskParent::DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex) { MOZ_ASSERT(mActor); - SpeechSynthesisRequestParent* actor = mActor; - mActor = nullptr; - if(NS_WARN_IF(!(actor->Send__delete__(actor, true, aElapsedTime, aCharIndex)))) { + if(NS_WARN_IF(!(mActor->SendOnEnd(true, aElapsedTime, aCharIndex)))) { return NS_ERROR_FAILURE; } diff --git a/dom/media/webspeech/synth/ipc/SpeechSynthesisParent.h b/dom/media/webspeech/synth/ipc/SpeechSynthesisParent.h index 5724e223ec12..53379def1980 100644 --- a/dom/media/webspeech/synth/ipc/SpeechSynthesisParent.h +++ b/dom/media/webspeech/synth/ipc/SpeechSynthesisParent.h @@ -71,6 +71,8 @@ protected: virtual bool RecvForceEnd() override; virtual bool RecvSetAudioOutputVolume(const float& aVolume) override; + + virtual bool Recv__delete__() override; }; class SpeechTaskParent : public nsSpeechTask diff --git a/dom/media/webspeech/synth/test/file_speech_error.html b/dom/media/webspeech/synth/test/file_speech_error.html new file mode 100644 index 000000000000..a80f0cbf48af --- /dev/null +++ b/dom/media/webspeech/synth/test/file_speech_error.html @@ -0,0 +1,46 @@ + + + +
+ ++ ++ + diff --git a/dom/media/webspeech/synth/test/mochitest.ini b/dom/media/webspeech/synth/test/mochitest.ini index d2ca7b99de62..28ce3ecc6cdc 100644 --- a/dom/media/webspeech/synth/test/mochitest.ini +++ b/dom/media/webspeech/synth/test/mochitest.ini @@ -6,6 +6,7 @@ support-files = file_speech_queue.html file_speech_simple.html file_speech_cancel.html + file_speech_error.html file_indirect_service_events.html file_global_queue.html file_global_queue_cancel.html @@ -15,6 +16,7 @@ support-files = [test_speech_queue.html] [test_speech_simple.html] [test_speech_cancel.html] +[test_speech_error.html] [test_indirect_service_events.html] [test_global_queue.html] [test_global_queue_cancel.html] diff --git a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp index 9e685c65cae5..2f9507203a3d 100644 --- a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp +++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp @@ -30,7 +30,8 @@ StaticRefPtr
+ ++ +