From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- dom/media/webspeech/synth/test/common.js | 104 ++++++++ dom/media/webspeech/synth/test/components.conf | 17 ++ .../webspeech/synth/test/file_bfcache_page1.html | 18 ++ .../webspeech/synth/test/file_bfcache_page2.html | 14 + .../webspeech/synth/test/file_global_queue.html | 69 +++++ .../synth/test/file_global_queue_cancel.html | 88 +++++++ .../synth/test/file_global_queue_pause.html | 130 ++++++++++ .../synth/test/file_indirect_service_events.html | 102 ++++++++ dom/media/webspeech/synth/test/file_setup.html | 96 +++++++ .../webspeech/synth/test/file_speech_cancel.html | 100 +++++++ .../webspeech/synth/test/file_speech_error.html | 46 ++++ .../webspeech/synth/test/file_speech_queue.html | 86 ++++++ .../test/file_speech_repeating_utterance.html | 26 ++ .../webspeech/synth/test/file_speech_simple.html | 53 ++++ dom/media/webspeech/synth/test/mochitest.toml | 40 +++ .../webspeech/synth/test/nsFakeSynthServices.cpp | 288 +++++++++++++++++++++ .../webspeech/synth/test/nsFakeSynthServices.h | 42 +++ .../synth/test/startup/file_voiceschanged.html | 32 +++ .../webspeech/synth/test/startup/mochitest.toml | 8 + .../synth/test/startup/test_voiceschanged.html | 32 +++ dom/media/webspeech/synth/test/test_bfcache.html | 46 ++++ .../webspeech/synth/test/test_global_queue.html | 35 +++ .../synth/test/test_global_queue_cancel.html | 35 +++ .../synth/test/test_global_queue_pause.html | 35 +++ .../synth/test/test_indirect_service_events.html | 36 +++ dom/media/webspeech/synth/test/test_setup.html | 32 +++ .../webspeech/synth/test/test_speech_cancel.html | 35 +++ .../webspeech/synth/test/test_speech_error.html | 35 +++ .../webspeech/synth/test/test_speech_queue.html | 37 +++ .../test/test_speech_repeating_utterance.html | 18 ++ .../webspeech/synth/test/test_speech_simple.html | 34 +++ 31 files changed, 1769 insertions(+) create mode 100644 dom/media/webspeech/synth/test/common.js create mode 100644 dom/media/webspeech/synth/test/components.conf create mode 100644 dom/media/webspeech/synth/test/file_bfcache_page1.html create mode 100644 dom/media/webspeech/synth/test/file_bfcache_page2.html create mode 100644 dom/media/webspeech/synth/test/file_global_queue.html create mode 100644 dom/media/webspeech/synth/test/file_global_queue_cancel.html create mode 100644 dom/media/webspeech/synth/test/file_global_queue_pause.html create mode 100644 dom/media/webspeech/synth/test/file_indirect_service_events.html create mode 100644 dom/media/webspeech/synth/test/file_setup.html create mode 100644 dom/media/webspeech/synth/test/file_speech_cancel.html create mode 100644 dom/media/webspeech/synth/test/file_speech_error.html create mode 100644 dom/media/webspeech/synth/test/file_speech_queue.html create mode 100644 dom/media/webspeech/synth/test/file_speech_repeating_utterance.html create mode 100644 dom/media/webspeech/synth/test/file_speech_simple.html create mode 100644 dom/media/webspeech/synth/test/mochitest.toml create mode 100644 dom/media/webspeech/synth/test/nsFakeSynthServices.cpp create mode 100644 dom/media/webspeech/synth/test/nsFakeSynthServices.h create mode 100644 dom/media/webspeech/synth/test/startup/file_voiceschanged.html create mode 100644 dom/media/webspeech/synth/test/startup/mochitest.toml create mode 100644 dom/media/webspeech/synth/test/startup/test_voiceschanged.html create mode 100644 dom/media/webspeech/synth/test/test_bfcache.html create mode 100644 dom/media/webspeech/synth/test/test_global_queue.html create mode 100644 dom/media/webspeech/synth/test/test_global_queue_cancel.html create mode 100644 dom/media/webspeech/synth/test/test_global_queue_pause.html create mode 100644 dom/media/webspeech/synth/test/test_indirect_service_events.html create mode 100644 dom/media/webspeech/synth/test/test_setup.html create mode 100644 dom/media/webspeech/synth/test/test_speech_cancel.html create mode 100644 dom/media/webspeech/synth/test/test_speech_error.html create mode 100644 dom/media/webspeech/synth/test/test_speech_queue.html create mode 100644 dom/media/webspeech/synth/test/test_speech_repeating_utterance.html create mode 100644 dom/media/webspeech/synth/test/test_speech_simple.html (limited to 'dom/media/webspeech/synth/test') diff --git a/dom/media/webspeech/synth/test/common.js b/dom/media/webspeech/synth/test/common.js new file mode 100644 index 0000000000..c22b0b488c --- /dev/null +++ b/dom/media/webspeech/synth/test/common.js @@ -0,0 +1,104 @@ +function synthTestQueue(aTestArgs, aEndFunc) { + var utterances = []; + for (var i in aTestArgs) { + var uargs = aTestArgs[i][0]; + var win = uargs.win || window; + var u = new win.SpeechSynthesisUtterance(uargs.text); + + if (uargs.args) { + for (var attr in uargs.args) { + u[attr] = uargs.args[attr]; + } + } + + function onend_handler(e) { + is(e.target, utterances.shift(), "Target matches utterances"); + ok(!speechSynthesis.speaking, "speechSynthesis is not speaking."); + + if (utterances.length) { + ok(speechSynthesis.pending, "other utterances queued"); + } else { + ok(!speechSynthesis.pending, "queue is empty, nothing pending."); + if (aEndFunc) { + aEndFunc(); + } + } + } + + u.addEventListener( + "start", + (function (expectedUri) { + return function (e) { + if (expectedUri) { + var chosenVoice = SpecialPowers.wrap(e).target.chosenVoiceURI; + is(chosenVoice, expectedUri, "Incorrect URI is used"); + } + }; + })(aTestArgs[i][1] ? aTestArgs[i][1].uri : null) + ); + + u.addEventListener("end", onend_handler); + u.addEventListener("error", onend_handler); + + u.addEventListener( + "error", + (function (expectedError) { + return function onerror_handler(e) { + ok( + expectedError, + "Error in speech utterance '" + e.target.text + "'" + ); + }; + })(aTestArgs[i][1] ? aTestArgs[i][1].err : false) + ); + + utterances.push(u); + win.speechSynthesis.speak(u); + } + + ok(!speechSynthesis.speaking, "speechSynthesis is not speaking yet."); + ok(speechSynthesis.pending, "speechSynthesis has an utterance queued."); +} + +function loadFrame(frameId) { + return new Promise(function (resolve, reject) { + var frame = document.getElementById(frameId); + frame.addEventListener("load", function (e) { + frame.contentWindow.document.title = frameId; + resolve(frame); + }); + frame.src = "about:blank"; + }); +} + +function waitForVoices(win) { + return new Promise(resolve => { + function resolver() { + if (win.speechSynthesis.getVoices().length) { + win.speechSynthesis.removeEventListener("voiceschanged", resolver); + resolve(); + } + } + + win.speechSynthesis.addEventListener("voiceschanged", resolver); + resolver(); + }); +} + +function loadSpeechTest(fileName, prefs, frameId = "testFrame") { + loadFrame(frameId).then(frame => { + waitForVoices(frame.contentWindow).then( + () => (document.getElementById("testFrame").src = fileName) + ); + }); +} + +function testSynthState(win, expectedState) { + for (var attr in expectedState) { + is( + win.speechSynthesis[attr], + expectedState[attr], + win.document.title + ": '" + attr + '" does not match' + ); + } +} diff --git a/dom/media/webspeech/synth/test/components.conf b/dom/media/webspeech/synth/test/components.conf new file mode 100644 index 0000000000..f37e4eafae --- /dev/null +++ b/dom/media/webspeech/synth/test/components.conf @@ -0,0 +1,17 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{e7d52d9e-c148-47d8-ab2a-95d7f40ea53d}', + 'contract_ids': ['@mozilla.org/fakesynth;1'], + 'singleton': True, + 'type': 'mozilla::dom::nsFakeSynthServices', + 'headers': ['/dom/media/webspeech/synth/test/nsFakeSynthServices.h'], + 'constructor': 'mozilla::dom::nsFakeSynthServices::GetInstanceForService', + 'categories': {'speech-synth-started': 'Fake Speech Synth'}, + }, +] diff --git a/dom/media/webspeech/synth/test/file_bfcache_page1.html b/dom/media/webspeech/synth/test/file_bfcache_page1.html new file mode 100644 index 0000000000..d6229eeeda --- /dev/null +++ b/dom/media/webspeech/synth/test/file_bfcache_page1.html @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/dom/media/webspeech/synth/test/file_bfcache_page2.html b/dom/media/webspeech/synth/test/file_bfcache_page2.html new file mode 100644 index 0000000000..30b9aa9117 --- /dev/null +++ b/dom/media/webspeech/synth/test/file_bfcache_page2.html @@ -0,0 +1,14 @@ + + + + + diff --git a/dom/media/webspeech/synth/test/file_global_queue.html b/dom/media/webspeech/synth/test/file_global_queue.html new file mode 100644 index 0000000000..5d762c0d51 --- /dev/null +++ b/dom/media/webspeech/synth/test/file_global_queue.html @@ -0,0 +1,69 @@ + + + + + + Test for Bug 1188099: Global queue should correctly schedule utterances + + + + +Mozilla Bug 1188099 + + + +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/file_global_queue_cancel.html b/dom/media/webspeech/synth/test/file_global_queue_cancel.html new file mode 100644 index 0000000000..03b77ba2fc --- /dev/null +++ b/dom/media/webspeech/synth/test/file_global_queue_cancel.html @@ -0,0 +1,88 @@ + + + + + + Test for Bug 1188099: Calling cancel() should work correctly with global queue + + + + +Mozilla Bug 1188099 + + + +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/file_global_queue_pause.html b/dom/media/webspeech/synth/test/file_global_queue_pause.html new file mode 100644 index 0000000000..e345eb4c98 --- /dev/null +++ b/dom/media/webspeech/synth/test/file_global_queue_pause.html @@ -0,0 +1,130 @@ + + + + + + Test for Bug 1188099: Calling pause() should work correctly with global queue + + + + +Mozilla Bug 1188099 + + + +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/file_indirect_service_events.html b/dom/media/webspeech/synth/test/file_indirect_service_events.html new file mode 100644 index 0000000000..5ed7812757 --- /dev/null +++ b/dom/media/webspeech/synth/test/file_indirect_service_events.html @@ -0,0 +1,102 @@ + + + + + + Test for Bug 1155034: Check that indirect audio services dispatch their own events + + + + +Mozilla Bug 1155034 +

+ +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/file_setup.html b/dom/media/webspeech/synth/test/file_setup.html new file mode 100644 index 0000000000..da8c2c6824 --- /dev/null +++ b/dom/media/webspeech/synth/test/file_setup.html @@ -0,0 +1,96 @@ + + + + + + Test for Bug 525444: Web Speech API check all classes are present + + + + +Mozilla Bug 650295 +

+ +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/file_speech_cancel.html b/dom/media/webspeech/synth/test/file_speech_cancel.html new file mode 100644 index 0000000000..2ab0e1d0a8 --- /dev/null +++ b/dom/media/webspeech/synth/test/file_speech_cancel.html @@ -0,0 +1,100 @@ + + + + + + Test for Bug 1150315: Check that successive cancel/speak calls work + + + + +Mozilla Bug 1150315 +

+ +
+
+
+ + 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 0000000000..b98ec2fac0 --- /dev/null +++ b/dom/media/webspeech/synth/test/file_speech_error.html @@ -0,0 +1,46 @@ + + + + + + Test for Bug 1226015 + + + + +Mozilla Bug 1226015 +

+ +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/file_speech_queue.html b/dom/media/webspeech/synth/test/file_speech_queue.html new file mode 100644 index 0000000000..a471034dcf --- /dev/null +++ b/dom/media/webspeech/synth/test/file_speech_queue.html @@ -0,0 +1,86 @@ + + + + + + Test for Bug 525444: Web Speech API, check speech synth queue + + + + +Mozilla Bug 525444 +

+ +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/file_speech_repeating_utterance.html b/dom/media/webspeech/synth/test/file_speech_repeating_utterance.html new file mode 100644 index 0000000000..6e37653057 --- /dev/null +++ b/dom/media/webspeech/synth/test/file_speech_repeating_utterance.html @@ -0,0 +1,26 @@ + + + + + Test for Bug 1305344: Utterance not repeating in Firefox + + + + + + + diff --git a/dom/media/webspeech/synth/test/file_speech_simple.html b/dom/media/webspeech/synth/test/file_speech_simple.html new file mode 100644 index 0000000000..c3f240ccdc --- /dev/null +++ b/dom/media/webspeech/synth/test/file_speech_simple.html @@ -0,0 +1,53 @@ + + + + + + Test for Bug 650295: Web Speech API check all classes are present + + + + +Mozilla Bug 650295 +

+ +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/mochitest.toml b/dom/media/webspeech/synth/test/mochitest.toml new file mode 100644 index 0000000000..5180e2ea01 --- /dev/null +++ b/dom/media/webspeech/synth/test/mochitest.toml @@ -0,0 +1,40 @@ +[DEFAULT] +tags = "mtg" +subsuite = "media" +support-files = [ + "common.js", + "file_bfcache_page1.html", + "file_bfcache_page2.html", + "file_setup.html", + "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", + "file_global_queue_pause.html", + "file_speech_repeating_utterance.html", +] + +["test_bfcache.html"] + +["test_global_queue.html"] + +["test_global_queue_cancel.html"] + +["test_global_queue_pause.html"] + +["test_indirect_service_events.html"] + +["test_setup.html"] + +["test_speech_cancel.html"] + +["test_speech_error.html"] + +["test_speech_queue.html"] + +["test_speech_repeating_utterance.html"] + +["test_speech_simple.html"] diff --git a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp new file mode 100644 index 0000000000..075e8aa878 --- /dev/null +++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp @@ -0,0 +1,288 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsISupports.h" +#include "nsFakeSynthServices.h" +#include "nsPrintfCString.h" +#include "SharedBuffer.h" + +#include "mozilla/ClearOnShutdown.h" +#include "mozilla/dom/nsSynthVoiceRegistry.h" +#include "mozilla/dom/nsSpeechTask.h" + +#include "nsThreadUtils.h" +#include "nsXULAppAPI.h" +#include "prenv.h" +#include "mozilla/Preferences.h" +#include "mozilla/DebugOnly.h" + +#define CHANNELS 1 +#define SAMPLERATE 1600 + +namespace mozilla::dom { + +StaticRefPtr nsFakeSynthServices::sSingleton; + +enum VoiceFlags { + eSuppressEvents = 1, + eSuppressEnd = 2, + eFailAtStart = 4, + eFail = 8 +}; + +struct VoiceDetails { + const char* uri; + const char* name; + const char* lang; + bool defaultVoice; + uint32_t flags; +}; + +static const VoiceDetails sVoices[] = { + {"urn:moz-tts:fake:bob", "Bob Marley", "en-JM", true, 0}, + {"urn:moz-tts:fake:amy", "Amy Winehouse", "en-GB", false, 0}, + {"urn:moz-tts:fake:lenny", "Leonard Cohen", "en-CA", false, 0}, + {"urn:moz-tts:fake:celine", "Celine Dion", "fr-CA", false, 0}, + { + "urn:moz-tts:fake:julie", + "Julieta Venegas", + "es-MX", + false, + }, + {"urn:moz-tts:fake:zanetta", "Zanetta Farussi", "it-IT", false, 0}, + {"urn:moz-tts:fake:margherita", "Margherita Durastanti", + "it-IT-noevents-noend", false, eSuppressEvents | eSuppressEnd}, + {"urn:moz-tts:fake:teresa", "Teresa Cornelys", "it-IT-noend", false, + eSuppressEnd}, + {"urn:moz-tts:fake:cecilia", "Cecilia Bartoli", "it-IT-failatstart", false, + eFailAtStart}, + {"urn:moz-tts:fake:gottardo", "Gottardo Aldighieri", "it-IT-fail", false, + eFail}, +}; + +// FakeSynthCallback +class FakeSynthCallback : public nsISpeechTaskCallback { + public: + explicit FakeSynthCallback(nsISpeechTask* aTask) : mTask(aTask) {} + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(FakeSynthCallback, + nsISpeechTaskCallback) + + NS_IMETHOD OnPause() override { + if (mTask) { + mTask->DispatchPause(1.5, 1); + } + + return NS_OK; + } + + NS_IMETHOD OnResume() override { + if (mTask) { + mTask->DispatchResume(1.5, 1); + } + + return NS_OK; + } + + NS_IMETHOD OnCancel() override { + if (mTask) { + mTask->DispatchEnd(1.5, 1); + } + + return NS_OK; + } + + NS_IMETHOD OnVolumeChanged(float aVolume) override { return NS_OK; } + + private: + virtual ~FakeSynthCallback() = default; + + nsCOMPtr mTask; +}; + +NS_IMPL_CYCLE_COLLECTION(FakeSynthCallback, mTask); + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FakeSynthCallback) + NS_INTERFACE_MAP_ENTRY(nsISpeechTaskCallback) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISpeechTaskCallback) +NS_INTERFACE_MAP_END + +NS_IMPL_CYCLE_COLLECTING_ADDREF(FakeSynthCallback) +NS_IMPL_CYCLE_COLLECTING_RELEASE(FakeSynthCallback) + +// FakeSpeechSynth + +class FakeSpeechSynth : public nsISpeechService { + public: + FakeSpeechSynth() = default; + + NS_DECL_ISUPPORTS + NS_DECL_NSISPEECHSERVICE + + private: + virtual ~FakeSpeechSynth() = default; +}; + +NS_IMPL_ISUPPORTS(FakeSpeechSynth, nsISpeechService) + +NS_IMETHODIMP +FakeSpeechSynth::Speak(const nsAString& aText, const nsAString& aUri, + float aVolume, float aRate, float aPitch, + nsISpeechTask* aTask) { + class DispatchStart final : public Runnable { + public: + explicit DispatchStart(nsISpeechTask* aTask) + : mozilla::Runnable("DispatchStart"), mTask(aTask) {} + + NS_IMETHOD Run() override { + mTask->DispatchStart(); + + return NS_OK; + } + + private: + nsCOMPtr mTask; + }; + + class DispatchEnd final : public Runnable { + public: + DispatchEnd(nsISpeechTask* aTask, const nsAString& aText) + : mozilla::Runnable("DispatchEnd"), mTask(aTask), mText(aText) {} + + NS_IMETHOD Run() override { + mTask->DispatchEnd(mText.Length() / 2, mText.Length()); + + return NS_OK; + } + + private: + nsCOMPtr mTask; + nsString mText; + }; + + class DispatchError final : public Runnable { + public: + DispatchError(nsISpeechTask* aTask, const nsAString& aText) + : mozilla::Runnable("DispatchError"), mTask(aTask), mText(aText) {} + + NS_IMETHOD Run() override { + mTask->DispatchError(mText.Length() / 2, mText.Length()); + + return NS_OK; + } + + private: + nsCOMPtr mTask; + nsString mText; + }; + + uint32_t flags = 0; + for (VoiceDetails voice : sVoices) { + if (aUri.EqualsASCII(voice.uri)) { + flags = voice.flags; + break; + } + } + + if (flags & eFailAtStart) { + return NS_ERROR_FAILURE; + } + + RefPtr cb = + new FakeSynthCallback((flags & eSuppressEvents) ? nullptr : aTask); + + aTask->Setup(cb); + + nsCOMPtr runnable = new DispatchStart(aTask); + NS_DispatchToMainThread(runnable); + + if (flags & eFail) { + runnable = new DispatchError(aTask, aText); + NS_DispatchToMainThread(runnable); + } else if ((flags & eSuppressEnd) == 0) { + runnable = new DispatchEnd(aTask, aText); + NS_DispatchToMainThread(runnable); + } + + return NS_OK; +} + +// nsFakeSynthService + +NS_INTERFACE_MAP_BEGIN(nsFakeSynthServices) + NS_INTERFACE_MAP_ENTRY(nsIObserver) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver) +NS_INTERFACE_MAP_END + +NS_IMPL_ADDREF(nsFakeSynthServices) +NS_IMPL_RELEASE(nsFakeSynthServices) + +static void AddVoices(nsISpeechService* aService, const VoiceDetails* aVoices, + uint32_t aLength) { + RefPtr registry = nsSynthVoiceRegistry::GetInstance(); + for (uint32_t i = 0; i < aLength; i++) { + NS_ConvertUTF8toUTF16 name(aVoices[i].name); + NS_ConvertUTF8toUTF16 uri(aVoices[i].uri); + NS_ConvertUTF8toUTF16 lang(aVoices[i].lang); + // These services can handle more than one utterance at a time and have + // several speaking simultaniously. So, aQueuesUtterances == false + registry->AddVoice(aService, uri, name, lang, true, false); + if (aVoices[i].defaultVoice) { + registry->SetDefaultVoice(uri, true); + } + } + + registry->NotifyVoicesChanged(); +} + +void nsFakeSynthServices::Init() { + mSynthService = new FakeSpeechSynth(); + AddVoices(mSynthService, sVoices, ArrayLength(sVoices)); +} + +// nsIObserver + +NS_IMETHODIMP +nsFakeSynthServices::Observe(nsISupports* aSubject, const char* aTopic, + const char16_t* aData) { + MOZ_ASSERT(NS_IsMainThread()); + if (NS_WARN_IF(!(!strcmp(aTopic, "speech-synth-started")))) { + return NS_ERROR_UNEXPECTED; + } + + if (Preferences::GetBool("media.webspeech.synth.test")) { + NS_DispatchToMainThread(NewRunnableMethod( + "dom::nsFakeSynthServices::Init", this, &nsFakeSynthServices::Init)); + } + + return NS_OK; +} + +// static methods + +nsFakeSynthServices* nsFakeSynthServices::GetInstance() { + MOZ_ASSERT(NS_IsMainThread()); + if (!XRE_IsParentProcess()) { + MOZ_ASSERT(false, + "nsFakeSynthServices can only be started on main gecko process"); + return nullptr; + } + + if (!sSingleton) { + sSingleton = new nsFakeSynthServices(); + ClearOnShutdown(&sSingleton); + } + + return sSingleton; +} + +already_AddRefed +nsFakeSynthServices::GetInstanceForService() { + RefPtr picoService = GetInstance(); + return picoService.forget(); +} + +} // namespace mozilla::dom diff --git a/dom/media/webspeech/synth/test/nsFakeSynthServices.h b/dom/media/webspeech/synth/test/nsFakeSynthServices.h new file mode 100644 index 0000000000..f7e1ca7da6 --- /dev/null +++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.h @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nsFakeSynthServices_h +#define nsFakeSynthServices_h + +#include "nsTArray.h" +#include "nsIObserver.h" +#include "nsISpeechService.h" +#include "nsRefPtrHashtable.h" +#include "mozilla/StaticPtr.h" +#include "mozilla/Monitor.h" + +namespace mozilla::dom { + +class nsFakeSynthServices : public nsIObserver { + public: + NS_DECL_ISUPPORTS + NS_DECL_NSIOBSERVER + + nsFakeSynthServices() = default; + + static nsFakeSynthServices* GetInstance(); + + static already_AddRefed GetInstanceForService(); + + private: + virtual ~nsFakeSynthServices() = default; + + void Init(); + + nsCOMPtr mSynthService; + + static StaticRefPtr sSingleton; +}; + +} // namespace mozilla::dom + +#endif diff --git a/dom/media/webspeech/synth/test/startup/file_voiceschanged.html b/dom/media/webspeech/synth/test/startup/file_voiceschanged.html new file mode 100644 index 0000000000..6bb25462e4 --- /dev/null +++ b/dom/media/webspeech/synth/test/startup/file_voiceschanged.html @@ -0,0 +1,32 @@ + + + + + + Test for Bug 1254378: Web Speech API check all classes are present + + + + + + diff --git a/dom/media/webspeech/synth/test/startup/mochitest.toml b/dom/media/webspeech/synth/test/startup/mochitest.toml new file mode 100644 index 0000000000..ab8b057b2a --- /dev/null +++ b/dom/media/webspeech/synth/test/startup/mochitest.toml @@ -0,0 +1,8 @@ +[DEFAULT] +tags = "mtg" +subsuite = "media" +support-files = ["file_voiceschanged.html"] + +["test_voiceschanged.html"] +skip-if = ["verify"] + diff --git a/dom/media/webspeech/synth/test/startup/test_voiceschanged.html b/dom/media/webspeech/synth/test/startup/test_voiceschanged.html new file mode 100644 index 0000000000..a60252ea7e --- /dev/null +++ b/dom/media/webspeech/synth/test/startup/test_voiceschanged.html @@ -0,0 +1,32 @@ + + + + + + Test for Bug 1254378: Emit onvoiceschanged when voices first added + + + + +Mozilla Bug 1254378 +

+ + +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/test_bfcache.html b/dom/media/webspeech/synth/test/test_bfcache.html new file mode 100644 index 0000000000..ba5981a42b --- /dev/null +++ b/dom/media/webspeech/synth/test/test_bfcache.html @@ -0,0 +1,46 @@ + + + + + + Test for Bug 1230533: Test speech is stopped from a window when unloaded + + + + + +Mozilla Bug 1230533 +

+ +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/test_global_queue.html b/dom/media/webspeech/synth/test/test_global_queue.html new file mode 100644 index 0000000000..177f79b399 --- /dev/null +++ b/dom/media/webspeech/synth/test/test_global_queue.html @@ -0,0 +1,35 @@ + + + + + + Test for Bug 1188099: Global queue should correctly schedule utterances + + + + + +Mozilla Bug 1188099 +

+ + +
+
+
+ + \ No newline at end of file diff --git a/dom/media/webspeech/synth/test/test_global_queue_cancel.html b/dom/media/webspeech/synth/test/test_global_queue_cancel.html new file mode 100644 index 0000000000..748d1367b5 --- /dev/null +++ b/dom/media/webspeech/synth/test/test_global_queue_cancel.html @@ -0,0 +1,35 @@ + + + + + + Test for Bug 1188099: Calling cancel() should work correctly with global queue + + + + + +Mozilla Bug 1188099 +

+ + +
+
+
+ + \ No newline at end of file diff --git a/dom/media/webspeech/synth/test/test_global_queue_pause.html b/dom/media/webspeech/synth/test/test_global_queue_pause.html new file mode 100644 index 0000000000..9632d85127 --- /dev/null +++ b/dom/media/webspeech/synth/test/test_global_queue_pause.html @@ -0,0 +1,35 @@ + + + + + + Test for Bug 1188099: Calling pause() should work correctly with global queue + + + + + +Mozilla Bug 1188099 +

+ + +
+
+
+ + \ No newline at end of file diff --git a/dom/media/webspeech/synth/test/test_indirect_service_events.html b/dom/media/webspeech/synth/test/test_indirect_service_events.html new file mode 100644 index 0000000000..e5b32e70f0 --- /dev/null +++ b/dom/media/webspeech/synth/test/test_indirect_service_events.html @@ -0,0 +1,36 @@ + + + + + + Test for Bug 1155034: Check that indirect audio services dispatch their own events + + + + + +Mozilla Bug 1155034 +

+ + +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/test_setup.html b/dom/media/webspeech/synth/test/test_setup.html new file mode 100644 index 0000000000..da07687750 --- /dev/null +++ b/dom/media/webspeech/synth/test/test_setup.html @@ -0,0 +1,32 @@ + + + + + + Test for Bug 525444: Web Speech API check all classes are present + + + + +Mozilla Bug 650295 +

+ + +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/test_speech_cancel.html b/dom/media/webspeech/synth/test/test_speech_cancel.html new file mode 100644 index 0000000000..ced952c736 --- /dev/null +++ b/dom/media/webspeech/synth/test/test_speech_cancel.html @@ -0,0 +1,35 @@ + + + + + + Test for Bug 1150315: Web Speech API check all classes are present + + + + + +Mozilla Bug 1150315 +

+ + +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/test_speech_error.html b/dom/media/webspeech/synth/test/test_speech_error.html new file mode 100644 index 0000000000..e2ce156dc6 --- /dev/null +++ b/dom/media/webspeech/synth/test/test_speech_error.html @@ -0,0 +1,35 @@ + + + + + + Test for Bug 1150315: Web Speech API check all classes are present + + + + + +Mozilla Bug 1226015 +

+ + +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/test_speech_queue.html b/dom/media/webspeech/synth/test/test_speech_queue.html new file mode 100644 index 0000000000..3bca9e0ce2 --- /dev/null +++ b/dom/media/webspeech/synth/test/test_speech_queue.html @@ -0,0 +1,37 @@ + + + + + + Test for Bug 525444: Web Speech API, check speech synth queue + + + + + +Mozilla Bug 525444 +

+ + +
+
+
+ + diff --git a/dom/media/webspeech/synth/test/test_speech_repeating_utterance.html b/dom/media/webspeech/synth/test/test_speech_repeating_utterance.html new file mode 100644 index 0000000000..6313a275c1 --- /dev/null +++ b/dom/media/webspeech/synth/test/test_speech_repeating_utterance.html @@ -0,0 +1,18 @@ + + + + + Test for Bug 1305344: Utterance not repeating in Firefox + + + + + + Mozilla Bug 1305344 + + + + diff --git a/dom/media/webspeech/synth/test/test_speech_simple.html b/dom/media/webspeech/synth/test/test_speech_simple.html new file mode 100644 index 0000000000..c6c0e3a5be --- /dev/null +++ b/dom/media/webspeech/synth/test/test_speech_simple.html @@ -0,0 +1,34 @@ + + + + + + Test for Bug 650295: Web Speech API check all classes are present + + + + + +Mozilla Bug 650295 +

+ + +
+
+
+ + -- cgit v1.2.3