зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1226015 - Have child send __delete__ in speech synth request protocol, fixes race. r=smaug
This commit is contained in:
Родитель
6f06c75266
Коммит
f010e62608
|
@ -15,6 +15,8 @@ async protocol PSpeechSynthesisRequest
|
||||||
|
|
||||||
parent:
|
parent:
|
||||||
|
|
||||||
|
__delete__();
|
||||||
|
|
||||||
Pause();
|
Pause();
|
||||||
|
|
||||||
Resume();
|
Resume();
|
||||||
|
@ -27,7 +29,7 @@ async protocol PSpeechSynthesisRequest
|
||||||
|
|
||||||
child:
|
child:
|
||||||
|
|
||||||
__delete__(bool aIsError, float aElapsedTime, uint32_t aCharIndex);
|
OnEnd(bool aIsError, float aElapsedTime, uint32_t aCharIndex);
|
||||||
|
|
||||||
OnStart(nsString aUri);
|
OnStart(nsString aUri);
|
||||||
|
|
||||||
|
|
|
@ -87,10 +87,11 @@ SpeechSynthesisRequestChild::RecvOnStart(const nsString& aUri)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SpeechSynthesisRequestChild::Recv__delete__(const bool& aIsError,
|
SpeechSynthesisRequestChild::RecvOnEnd(const bool& aIsError,
|
||||||
const float& aElapsedTime,
|
const float& aElapsedTime,
|
||||||
const uint32_t& aCharIndex)
|
const uint32_t& aCharIndex)
|
||||||
{
|
{
|
||||||
|
SpeechSynthesisRequestChild* actor = mTask->mActor;
|
||||||
mTask->mActor = nullptr;
|
mTask->mActor = nullptr;
|
||||||
|
|
||||||
if (aIsError) {
|
if (aIsError) {
|
||||||
|
@ -99,6 +100,8 @@ SpeechSynthesisRequestChild::Recv__delete__(const bool& aIsError,
|
||||||
mTask->DispatchEndImpl(aElapsedTime, aCharIndex);
|
mTask->DispatchEndImpl(aElapsedTime, aCharIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actor->Send__delete__(actor);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual bool RecvOnStart(const nsString& aUri) override;
|
virtual bool RecvOnStart(const nsString& aUri) override;
|
||||||
|
|
||||||
virtual bool Recv__delete__(const bool& aIsError,
|
virtual bool RecvOnEnd(const bool& aIsError,
|
||||||
const float& aElapsedTime,
|
const float& aElapsedTime,
|
||||||
const uint32_t& aCharIndex) override;
|
const uint32_t& aCharIndex) override;
|
||||||
|
|
||||||
virtual bool RecvOnPause(const float& aElapsedTime, const uint32_t& aCharIndex) override;
|
virtual bool RecvOnPause(const float& aElapsedTime, const uint32_t& aCharIndex) override;
|
||||||
|
|
||||||
|
|
|
@ -82,9 +82,6 @@ SpeechSynthesisRequestParent::SpeechSynthesisRequestParent(SpeechTaskParent* aTa
|
||||||
|
|
||||||
SpeechSynthesisRequestParent::~SpeechSynthesisRequestParent()
|
SpeechSynthesisRequestParent::~SpeechSynthesisRequestParent()
|
||||||
{
|
{
|
||||||
if (mTask && mTask->mActor) {
|
|
||||||
mTask->mActor = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_COUNT_DTOR(SpeechSynthesisRequestParent);
|
MOZ_COUNT_DTOR(SpeechSynthesisRequestParent);
|
||||||
}
|
}
|
||||||
|
@ -103,6 +100,15 @@ SpeechSynthesisRequestParent::RecvPause()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SpeechSynthesisRequestParent::Recv__delete__()
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(mTask);
|
||||||
|
mTask->mActor = nullptr;
|
||||||
|
mTask = nullptr;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SpeechSynthesisRequestParent::RecvResume()
|
SpeechSynthesisRequestParent::RecvResume()
|
||||||
{
|
{
|
||||||
|
@ -152,9 +158,7 @@ nsresult
|
||||||
SpeechTaskParent::DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex)
|
SpeechTaskParent::DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mActor);
|
MOZ_ASSERT(mActor);
|
||||||
SpeechSynthesisRequestParent* actor = mActor;
|
if(NS_WARN_IF(!(mActor->SendOnEnd(false, aElapsedTime, aCharIndex)))) {
|
||||||
mActor = nullptr;
|
|
||||||
if(NS_WARN_IF(!(actor->Send__delete__(actor, false, aElapsedTime, aCharIndex)))) {
|
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,9 +191,7 @@ nsresult
|
||||||
SpeechTaskParent::DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex)
|
SpeechTaskParent::DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mActor);
|
MOZ_ASSERT(mActor);
|
||||||
SpeechSynthesisRequestParent* actor = mActor;
|
if(NS_WARN_IF(!(mActor->SendOnEnd(true, aElapsedTime, aCharIndex)))) {
|
||||||
mActor = nullptr;
|
|
||||||
if(NS_WARN_IF(!(actor->Send__delete__(actor, true, aElapsedTime, aCharIndex)))) {
|
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,8 @@ protected:
|
||||||
virtual bool RecvForceEnd() override;
|
virtual bool RecvForceEnd() override;
|
||||||
|
|
||||||
virtual bool RecvSetAudioOutputVolume(const float& aVolume) override;
|
virtual bool RecvSetAudioOutputVolume(const float& aVolume) override;
|
||||||
|
|
||||||
|
virtual bool Recv__delete__() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpeechTaskParent : public nsSpeechTask
|
class SpeechTaskParent : public nsSpeechTask
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1226015
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test for Bug 1226015</title>
|
||||||
|
<script type="application/javascript">
|
||||||
|
window.SimpleTest = parent.SimpleTest;
|
||||||
|
window.info = parent.info;
|
||||||
|
window.is = parent.is;
|
||||||
|
window.isnot = parent.isnot;
|
||||||
|
window.ok = parent.ok;
|
||||||
|
</script>
|
||||||
|
<script type="application/javascript" src="common.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1226015">Mozilla Bug 1226015</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
/** Test for Bug 1226015 **/
|
||||||
|
|
||||||
|
function testFunc(done_cb) {
|
||||||
|
var utterance = new SpeechSynthesisUtterance();
|
||||||
|
utterance.lang = 'it-IT-error';
|
||||||
|
|
||||||
|
speechSynthesis.speak(utterance);
|
||||||
|
speechSynthesis.cancel();
|
||||||
|
|
||||||
|
ok(true, "we didn't crash, that is good.")
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run test with no global queue, and then run it with a global queue.
|
||||||
|
testFunc();
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -6,6 +6,7 @@ support-files =
|
||||||
file_speech_queue.html
|
file_speech_queue.html
|
||||||
file_speech_simple.html
|
file_speech_simple.html
|
||||||
file_speech_cancel.html
|
file_speech_cancel.html
|
||||||
|
file_speech_error.html
|
||||||
file_indirect_service_events.html
|
file_indirect_service_events.html
|
||||||
file_global_queue.html
|
file_global_queue.html
|
||||||
file_global_queue_cancel.html
|
file_global_queue_cancel.html
|
||||||
|
@ -15,6 +16,7 @@ support-files =
|
||||||
[test_speech_queue.html]
|
[test_speech_queue.html]
|
||||||
[test_speech_simple.html]
|
[test_speech_simple.html]
|
||||||
[test_speech_cancel.html]
|
[test_speech_cancel.html]
|
||||||
|
[test_speech_error.html]
|
||||||
[test_indirect_service_events.html]
|
[test_indirect_service_events.html]
|
||||||
[test_global_queue.html]
|
[test_global_queue.html]
|
||||||
[test_global_queue_cancel.html]
|
[test_global_queue_cancel.html]
|
||||||
|
|
|
@ -30,7 +30,8 @@ StaticRefPtr<nsFakeSynthServices> nsFakeSynthServices::sSingleton;
|
||||||
enum VoiceFlags
|
enum VoiceFlags
|
||||||
{
|
{
|
||||||
eSuppressEvents = 1,
|
eSuppressEvents = 1,
|
||||||
eSuppressEnd = 2
|
eSuppressEnd = 2,
|
||||||
|
eFailAtStart = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VoiceDetails
|
struct VoiceDetails
|
||||||
|
@ -54,6 +55,7 @@ static const VoiceDetails sIndirectVoices[] = {
|
||||||
{"urn:moz-tts:fake-indirect:zanetta", "Zanetta Farussi", "it-IT", false, 0},
|
{"urn:moz-tts:fake-indirect:zanetta", "Zanetta Farussi", "it-IT", false, 0},
|
||||||
{"urn:moz-tts:fake-indirect:margherita", "Margherita Durastanti", "it-IT-noevents-noend", false, eSuppressEvents | eSuppressEnd},
|
{"urn:moz-tts:fake-indirect:margherita", "Margherita Durastanti", "it-IT-noevents-noend", false, eSuppressEvents | eSuppressEnd},
|
||||||
{"urn:moz-tts:fake-indirect:teresa", "Teresa Cornelys", "it-IT-noend", false, eSuppressEnd},
|
{"urn:moz-tts:fake-indirect:teresa", "Teresa Cornelys", "it-IT-noend", false, eSuppressEnd},
|
||||||
|
{"urn:moz-tts:fake-indirect:cecilia", "Cecilia Bartoli", "it-IT-error", false, eFailAtStart},
|
||||||
};
|
};
|
||||||
|
|
||||||
// FakeSynthCallback
|
// FakeSynthCallback
|
||||||
|
@ -243,6 +245,11 @@ FakeIndirectAudioSynth::Speak(const nsAString& aText, const nsAString& aUri,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & eFailAtStart) {
|
||||||
|
aTask->DispatchError(0, 0);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
RefPtr<FakeSynthCallback> cb = new FakeSynthCallback(
|
RefPtr<FakeSynthCallback> cb = new FakeSynthCallback(
|
||||||
(flags & eSuppressEvents) ? nullptr : aTask);
|
(flags & eSuppressEvents) ? nullptr : aTask);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1226015
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test for Bug 1150315: Web Speech API check all classes are present</title>
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="application/javascript" src="common.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1226015">Mozilla Bug 1226015</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<iframe id="testFrame"></iframe>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
/** Test for Bug 1226015 **/
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
SpecialPowers.pushPrefEnv(
|
||||||
|
{ set: [['media.webspeech.synth.enabled', true],
|
||||||
|
['media.webspeech.synth.force_global_queue', false]] },
|
||||||
|
function() { document.getElementById("testFrame").src = "file_speech_error.html"; });
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
Загрузка…
Ссылка в новой задаче