зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1188099 - (Part 4) Introduce mochitest coverage for speech global queue. r=smaug r=kdavis
--HG-- rename : dom/media/webspeech/synth/test/test_speech_queue.html => dom/media/webspeech/synth/test/test_global_queue.html rename : dom/media/webspeech/synth/test/test_speech_queue.html => dom/media/webspeech/synth/test/test_global_queue_cancel.html rename : dom/media/webspeech/synth/test/test_speech_queue.html => dom/media/webspeech/synth/test/test_global_queue_pause.html
This commit is contained in:
Родитель
7283fc40c4
Коммит
c6f439d68a
|
@ -2,12 +2,13 @@ function synthTestQueue(aTestArgs, aEndFunc) {
|
||||||
var utterances = [];
|
var utterances = [];
|
||||||
for (var i in aTestArgs) {
|
for (var i in aTestArgs) {
|
||||||
var uargs = aTestArgs[i][0];
|
var uargs = aTestArgs[i][0];
|
||||||
var u = new SpeechSynthesisUtterance(uargs.text);
|
var win = uargs.win || window;
|
||||||
|
var u = new win.SpeechSynthesisUtterance(uargs.text);
|
||||||
|
|
||||||
delete uargs.text;
|
if (uargs.args) {
|
||||||
|
for (var attr in uargs.args)
|
||||||
for (var attr in uargs)
|
u[attr] = uargs.args[attr];
|
||||||
u[attr] = uargs[attr];
|
}
|
||||||
|
|
||||||
function onend_handler(e) {
|
function onend_handler(e) {
|
||||||
is(e.target, utterances.shift(), "Target matches utterances");
|
is(e.target, utterances.shift(), "Target matches utterances");
|
||||||
|
@ -43,9 +44,27 @@ function synthTestQueue(aTestArgs, aEndFunc) {
|
||||||
});
|
});
|
||||||
|
|
||||||
utterances.push(u);
|
utterances.push(u);
|
||||||
speechSynthesis.speak(u);
|
win.speechSynthesis.speak(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok(!speechSynthesis.speaking, "speechSynthesis is not speaking yet.");
|
ok(!speechSynthesis.speaking, "speechSynthesis is not speaking yet.");
|
||||||
ok(speechSynthesis.pending, "speechSynthesis has an utterance queued.");
|
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);
|
||||||
|
});
|
||||||
|
frame1.src = 'data:text/html,' + encodeURI('<html><head></head><body></body></html>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSynthState(win, expectedState) {
|
||||||
|
for (var attr in expectedState) {
|
||||||
|
is(win.speechSynthesis[attr], expectedState[attr],
|
||||||
|
win.document.title + ": '" + attr + '" does not match');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1188099
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test for Bug 1188099: Global queue should correctly schedule utterances</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;
|
||||||
|
window.todo = parent.todo;
|
||||||
|
</script>
|
||||||
|
<script type="application/javascript" src="common.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1188099">Mozilla Bug 1188099</a>
|
||||||
|
<iframe id="frame1"></iframe>
|
||||||
|
<iframe id="frame2"></iframe>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
Promise.all([loadFrame('frame1'), loadFrame('frame2')]).then(function ([frame1, frame2]) {
|
||||||
|
var win1 = frame1.contentWindow;
|
||||||
|
var win2 = frame2.contentWindow;
|
||||||
|
var utterance1 = new win1.SpeechSynthesisUtterance("hello, losers");
|
||||||
|
var utterance2 = new win1.SpeechSynthesisUtterance("hello, losers three");
|
||||||
|
var utterance3 = new win2.SpeechSynthesisUtterance("hello, losers too");
|
||||||
|
var eventOrder = ['start1', 'end1', 'start3', 'end3', 'start2', 'end2'];
|
||||||
|
utterance1.addEventListener('start', function(e) {
|
||||||
|
is(eventOrder.shift(), 'start1', 'start1');
|
||||||
|
testSynthState(win1, { speaking: true, pending: true });
|
||||||
|
testSynthState(win2, { speaking: true, pending: true });
|
||||||
|
});
|
||||||
|
utterance1.addEventListener('end', function(e) {
|
||||||
|
is(eventOrder.shift(), 'end1', 'end1');
|
||||||
|
});
|
||||||
|
utterance3.addEventListener('start', function(e) {
|
||||||
|
is(eventOrder.shift(), 'start3', 'start3');
|
||||||
|
testSynthState(win1, { speaking: true, pending: true });
|
||||||
|
testSynthState(win2, { speaking: true, pending: false });
|
||||||
|
});
|
||||||
|
utterance3.addEventListener('end', function(e) {
|
||||||
|
is(eventOrder.shift(), 'end3', 'end3');
|
||||||
|
});
|
||||||
|
utterance2.addEventListener('start', function(e) {
|
||||||
|
is(eventOrder.shift(), 'start2', 'start2');
|
||||||
|
testSynthState(win1, { speaking: true, pending: false });
|
||||||
|
testSynthState(win2, { speaking: true, pending: false });
|
||||||
|
});
|
||||||
|
utterance2.addEventListener('end', function(e) {
|
||||||
|
is(eventOrder.shift(), 'end2', 'end2');
|
||||||
|
testSynthState(win1, { speaking: false, pending: false });
|
||||||
|
testSynthState(win2, { speaking: false, pending: false });
|
||||||
|
SimpleTest.finish();
|
||||||
|
});
|
||||||
|
win1.speechSynthesis.speak(utterance1);
|
||||||
|
win1.speechSynthesis.speak(utterance2);
|
||||||
|
win2.speechSynthesis.speak(utterance3);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,88 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1188099
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test for Bug 1188099: Calling cancel() should work correctly with global queue</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;
|
||||||
|
window.todo = parent.todo;
|
||||||
|
</script>
|
||||||
|
<script type="application/javascript" src="common.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1188099">Mozilla Bug 1188099</a>
|
||||||
|
<iframe id="frame1"></iframe>
|
||||||
|
<iframe id="frame2"></iframe>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
Promise.all([loadFrame('frame1'), loadFrame('frame2')]).then(function ([frame1, frame2]) {
|
||||||
|
var win1 = frame1.contentWindow;
|
||||||
|
var win2 = frame2.contentWindow;
|
||||||
|
|
||||||
|
var utterance1 = new win1.SpeechSynthesisUtterance(
|
||||||
|
"u1: Donec ac nunc feugiat, posuere");
|
||||||
|
utterance1.lang = 'it-IT-noend';
|
||||||
|
var utterance2 = new win1.SpeechSynthesisUtterance("u2: hello, losers too");
|
||||||
|
utterance2.lang = 'it-IT-noend';
|
||||||
|
var utterance3 = new win1.SpeechSynthesisUtterance("u3: hello, losers three");
|
||||||
|
|
||||||
|
var utterance4 = new win2.SpeechSynthesisUtterance("u4: hello, losers same!");
|
||||||
|
utterance4.lang = 'it-IT-noend';
|
||||||
|
var utterance5 = new win2.SpeechSynthesisUtterance("u5: hello, losers too");
|
||||||
|
utterance5.lang = 'it-IT-noend';
|
||||||
|
|
||||||
|
var eventOrder = ['start1', 'end1', 'start2', 'end2'];
|
||||||
|
utterance1.addEventListener('start', function(e) {
|
||||||
|
is(eventOrder.shift(), 'start1', 'start1');
|
||||||
|
testSynthState(win1, { speaking: true, pending: true });
|
||||||
|
testSynthState(win2, { speaking: true, pending: true });
|
||||||
|
win2.speechSynthesis.cancel();
|
||||||
|
SpecialPowers.wrap(win1.speechSynthesis).forceEnd();
|
||||||
|
|
||||||
|
});
|
||||||
|
utterance1.addEventListener('end', function(e) {
|
||||||
|
is(eventOrder.shift(), 'end1', 'end1');
|
||||||
|
testSynthState(win1, { pending: true });
|
||||||
|
testSynthState(win2, { pending: false });
|
||||||
|
});
|
||||||
|
utterance2.addEventListener('start', function(e) {
|
||||||
|
is(eventOrder.shift(), 'start2', 'start2');
|
||||||
|
testSynthState(win1, { speaking: true, pending: true });
|
||||||
|
testSynthState(win2, { speaking: true, pending: false });
|
||||||
|
win1.speechSynthesis.cancel();
|
||||||
|
});
|
||||||
|
utterance2.addEventListener('end', function(e) {
|
||||||
|
is(eventOrder.shift(), 'end2', 'end2');
|
||||||
|
testSynthState(win1, { speaking: false, pending: false });
|
||||||
|
testSynthState(win2, { speaking: false, pending: false });
|
||||||
|
SimpleTest.finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
function wrongUtterance(e) {
|
||||||
|
ok(false, 'This shall not be uttered: "' + e.target.text + '"');
|
||||||
|
}
|
||||||
|
|
||||||
|
utterance3.addEventListener('start', wrongUtterance);
|
||||||
|
utterance4.addEventListener('start', wrongUtterance);
|
||||||
|
utterance5.addEventListener('start', wrongUtterance);
|
||||||
|
|
||||||
|
win1.speechSynthesis.speak(utterance1);
|
||||||
|
win1.speechSynthesis.speak(utterance2);
|
||||||
|
win1.speechSynthesis.speak(utterance3);
|
||||||
|
win2.speechSynthesis.speak(utterance4);
|
||||||
|
win2.speechSynthesis.speak(utterance5);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,131 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1188099
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test for Bug 1188099: Calling pause() should work correctly with global queue</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;
|
||||||
|
window.todo = parent.todo;
|
||||||
|
</script>
|
||||||
|
<script type="application/javascript" src="common.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1188099">Mozilla Bug 1188099</a>
|
||||||
|
<iframe id="frame1"></iframe>
|
||||||
|
<iframe id="frame2"></iframe>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
Promise.all([loadFrame('frame1'), loadFrame('frame2')]).then(function ([frame1, frame2]) {
|
||||||
|
var win1 = frame1.contentWindow;
|
||||||
|
var win2 = frame2.contentWindow;
|
||||||
|
|
||||||
|
var utterance1 = new win1.SpeechSynthesisUtterance("Speak utterance 1.");
|
||||||
|
utterance1.lang = 'it-IT-noend';
|
||||||
|
var utterance2 = new win2.SpeechSynthesisUtterance("Speak utterance 2.");
|
||||||
|
var utterance3 = new win1.SpeechSynthesisUtterance("Speak utterance 3.");
|
||||||
|
var utterance4 = new win2.SpeechSynthesisUtterance("Speak utterance 4.");
|
||||||
|
var eventOrder = ['start1', 'pause1', 'resume1', 'end1', 'start2', 'end2',
|
||||||
|
'start4', 'end4', 'start3', 'end3'];
|
||||||
|
|
||||||
|
utterance1.addEventListener('start', function(e) {
|
||||||
|
is(eventOrder.shift(), 'start1', 'start1');
|
||||||
|
win1.speechSynthesis.pause();
|
||||||
|
});
|
||||||
|
utterance1.addEventListener('pause', function(e) {
|
||||||
|
var expectedEvent = eventOrder.shift()
|
||||||
|
is(expectedEvent, 'pause1', 'pause1');
|
||||||
|
testSynthState(win1, { speaking: true, pending: false, paused: true});
|
||||||
|
testSynthState(win2, { speaking: true, pending: true, paused: false});
|
||||||
|
|
||||||
|
if (expectedEvent == 'pause1') {
|
||||||
|
win1.speechSynthesis.resume();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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 });
|
||||||
|
|
||||||
|
// 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});
|
||||||
|
|
||||||
|
win2.speechSynthesis.resume();
|
||||||
|
});
|
||||||
|
|
||||||
|
utterance2.addEventListener('start', function(e) {
|
||||||
|
is(eventOrder.shift(), 'start2', 'start2');
|
||||||
|
testSynthState(win1, { speaking: true, pending: false, paused: false});
|
||||||
|
testSynthState(win2, { speaking: true, pending: false, paused: false});
|
||||||
|
});
|
||||||
|
utterance2.addEventListener('end', function(e) {
|
||||||
|
is(eventOrder.shift(), 'end2', 'end2');
|
||||||
|
testSynthState(win1, { speaking: false, pending: false, paused: false});
|
||||||
|
testSynthState(win2, { speaking: false, pending: false, paused: false});
|
||||||
|
|
||||||
|
win1.speechSynthesis.pause();
|
||||||
|
|
||||||
|
testSynthState(win1, { speaking: false, pending: false, paused: true});
|
||||||
|
testSynthState(win2, { speaking: false, pending: false, paused: false});
|
||||||
|
|
||||||
|
win1.speechSynthesis.speak(utterance3);
|
||||||
|
win2.speechSynthesis.speak(utterance4);
|
||||||
|
|
||||||
|
testSynthState(win1, { speaking: false, pending: true, paused: true});
|
||||||
|
testSynthState(win2, { speaking: false, pending: true, paused: false});
|
||||||
|
});
|
||||||
|
|
||||||
|
utterance4.addEventListener('start', function(e) {
|
||||||
|
is(eventOrder.shift(), 'start4', 'start4');
|
||||||
|
testSynthState(win1, { speaking: true, pending: true, paused: true});
|
||||||
|
testSynthState(win2, { speaking: true, pending: false, paused: false});
|
||||||
|
|
||||||
|
win1.speechSynthesis.resume();
|
||||||
|
});
|
||||||
|
utterance4.addEventListener('end', function(e) {
|
||||||
|
is(eventOrder.shift(), 'end4', 'end4');
|
||||||
|
testSynthState(win1, { speaking: false, pending: true, paused: false});
|
||||||
|
testSynthState(win2, { speaking: false, pending: false, paused: false});
|
||||||
|
});
|
||||||
|
|
||||||
|
utterance3.addEventListener('start', function(e) {
|
||||||
|
is(eventOrder.shift(), 'start3', 'start3');
|
||||||
|
testSynthState(win1, { speaking: true, pending: false, paused: false});
|
||||||
|
testSynthState(win2, { speaking: true, pending: false, paused: false});
|
||||||
|
});
|
||||||
|
|
||||||
|
utterance3.addEventListener('end', function(e) {
|
||||||
|
is(eventOrder.shift(), 'end3', 'end3');
|
||||||
|
testSynthState(win1, { speaking: false, pending: false, paused: false});
|
||||||
|
testSynthState(win2, { speaking: false, pending: false, paused: false});
|
||||||
|
|
||||||
|
SimpleTest.finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
win1.speechSynthesis.speak(utterance1);
|
||||||
|
win2.speechSynthesis.speak(utterance2);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -26,66 +26,75 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1155034
|
||||||
|
|
||||||
/** Test for Bug 1155034 **/
|
/** Test for Bug 1155034 **/
|
||||||
|
|
||||||
function test_with_events() {
|
function testFunc(done_cb) {
|
||||||
info('test_with_events');
|
function test_with_events() {
|
||||||
var utterance = new SpeechSynthesisUtterance("never end, callback events");
|
info('test_with_events');
|
||||||
utterance.lang = 'it-IT-noend';
|
var utterance = new SpeechSynthesisUtterance("never end, callback events");
|
||||||
|
utterance.lang = 'it-IT-noend';
|
||||||
|
|
||||||
utterance.addEventListener('start', function(e) {
|
utterance.addEventListener('start', function(e) {
|
||||||
speechSynthesis.pause();
|
info('start test_with_events');
|
||||||
// Wait to see if we get some bad events we didn't expect.
|
speechSynthesis.pause();
|
||||||
});
|
|
||||||
|
|
||||||
utterance.addEventListener('pause', function(e) {
|
|
||||||
is(e.charIndex, 1, 'pause event charIndex matches service arguments');
|
|
||||||
is(e.elapsedTime, 1.5, 'pause event elapsedTime matches service arguments');
|
|
||||||
speechSynthesis.resume();
|
|
||||||
});
|
|
||||||
|
|
||||||
utterance.addEventListener('resume', function(e) {
|
|
||||||
is(e.charIndex, 1, 'resume event charIndex matches service arguments');
|
|
||||||
is(e.elapsedTime, 1.5, 'resume event elapsedTime matches service arguments');
|
|
||||||
speechSynthesis.cancel();
|
|
||||||
});
|
|
||||||
|
|
||||||
utterance.addEventListener('end', function(e) {
|
|
||||||
ok(e.charIndex, 1, 'resume event charIndex matches service arguments');
|
|
||||||
ok(e.elapsedTime, 1.5, 'end event elapsedTime matches service arguments');
|
|
||||||
test_no_events();
|
|
||||||
});
|
|
||||||
|
|
||||||
speechSynthesis.speak(utterance);
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_no_events() {
|
|
||||||
var utterance = new SpeechSynthesisUtterance("never end");
|
|
||||||
utterance.lang = "it-IT-noevents-noend";
|
|
||||||
utterance.addEventListener('start', function(e) {
|
|
||||||
speechSynthesis.pause();
|
|
||||||
// Wait to see if we get some bad events we didn't expect.
|
// Wait to see if we get some bad events we didn't expect.
|
||||||
setTimeout(function() {
|
});
|
||||||
SimpleTest.finish();
|
|
||||||
}, 1000);
|
|
||||||
});
|
|
||||||
|
|
||||||
utterance.addEventListener('pause', function(e) {
|
utterance.addEventListener('pause', function(e) {
|
||||||
ok(false, 'no pause event was explicitly dispatched from the service')
|
is(e.charIndex, 1, 'pause event charIndex matches service arguments');
|
||||||
speechSynthesis.resume();
|
is(e.elapsedTime, 1.5, 'pause event elapsedTime matches service arguments');
|
||||||
});
|
speechSynthesis.resume();
|
||||||
|
});
|
||||||
|
|
||||||
utterance.addEventListener('resume', function(e) {
|
utterance.addEventListener('resume', function(e) {
|
||||||
ok(false, 'no resume event was explicitly dispatched from the service')
|
is(e.charIndex, 1, 'resume event charIndex matches service arguments');
|
||||||
speechSynthesis.cancel();
|
is(e.elapsedTime, 1.5, 'resume event elapsedTime matches service arguments');
|
||||||
});
|
speechSynthesis.cancel();
|
||||||
|
});
|
||||||
|
|
||||||
utterance.addEventListener('end', function(e) {
|
utterance.addEventListener('end', function(e) {
|
||||||
ok(false, 'no end event was explicitly dispatched from the service')
|
ok(e.charIndex, 1, 'resume event charIndex matches service arguments');
|
||||||
});
|
ok(e.elapsedTime, 1.5, 'end event elapsedTime matches service arguments');
|
||||||
|
test_no_events();
|
||||||
|
});
|
||||||
|
|
||||||
speechSynthesis.speak(utterance);
|
info('start speak');
|
||||||
|
speechSynthesis.speak(utterance);
|
||||||
|
}
|
||||||
|
|
||||||
|
function forbiddenEvent(e) {
|
||||||
|
ok(false, 'no "' + e.type + '" event was explicitly dispatched from the service')
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_no_events() {
|
||||||
|
info('test_no_events');
|
||||||
|
var utterance = new SpeechSynthesisUtterance("never end");
|
||||||
|
utterance.lang = "it-IT-noevents-noend";
|
||||||
|
utterance.addEventListener('start', function(e) {
|
||||||
|
speechSynthesis.pause();
|
||||||
|
// Wait to see if we get some bad events we didn't expect.
|
||||||
|
setTimeout(function() {
|
||||||
|
ok(true, 'didn\'t get any unwanted events');
|
||||||
|
utterance.removeEventListener('end', forbiddenEvent);
|
||||||
|
SpecialPowers.wrap(speechSynthesis).forceEnd();
|
||||||
|
done_cb();
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
utterance.addEventListener('pause', forbiddenEvent);
|
||||||
|
utterance.addEventListener('end', forbiddenEvent);
|
||||||
|
|
||||||
|
speechSynthesis.speak(utterance);
|
||||||
|
}
|
||||||
|
|
||||||
|
test_with_events();
|
||||||
}
|
}
|
||||||
|
|
||||||
test_with_events();
|
// Run test with no global queue, and then run it with a global queue.
|
||||||
|
testFunc(function() {
|
||||||
|
SpecialPowers.pushPrefEnv(
|
||||||
|
{ set: [['media.webspeech.synth.force_global_queue', true]] }, function() {
|
||||||
|
testFunc(SimpleTest.finish)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -26,62 +26,73 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1150315
|
||||||
|
|
||||||
/** Test for Bug 1150315 **/
|
/** Test for Bug 1150315 **/
|
||||||
|
|
||||||
var gotEndEvent = false;
|
function testFunc(done_cb) {
|
||||||
// A long utterance that we will interrupt.
|
var gotEndEvent = false;
|
||||||
var utterance = new SpeechSynthesisUtterance("Donec ac nunc feugiat, posuere " +
|
// A long utterance that we will interrupt.
|
||||||
"mauris id, pharetra velit. Donec fermentum orci nunc, sit amet maximus" +
|
var utterance = new SpeechSynthesisUtterance("Donec ac nunc feugiat, posuere " +
|
||||||
"dui tincidunt ut. Sed ultricies ac nisi a laoreet. Proin interdum," +
|
"mauris id, pharetra velit. Donec fermentum orci nunc, sit amet maximus" +
|
||||||
"libero maximus hendrerit posuere, lorem risus egestas nisl, a" +
|
"dui tincidunt ut. Sed ultricies ac nisi a laoreet. Proin interdum," +
|
||||||
"ultricies massa justo eu nisi. Duis mattis nibh a ligula tincidunt" +
|
"libero maximus hendrerit posuere, lorem risus egestas nisl, a" +
|
||||||
"tincidunt non eu erat. Sed bibendum varius vulputate. Cras leo magna," +
|
"ultricies massa justo eu nisi. Duis mattis nibh a ligula tincidunt" +
|
||||||
"ornare ac posuere vel, luctus id metus. Mauris nec quam ac augue" +
|
"tincidunt non eu erat. Sed bibendum varius vulputate. Cras leo magna," +
|
||||||
"consectetur bibendum. Integer a commodo tortor. Duis semper dolor eu" +
|
"ornare ac posuere vel, luctus id metus. Mauris nec quam ac augue" +
|
||||||
"facilisis facilisis. Etiam venenatis turpis est, quis tincidunt velit" +
|
"consectetur bibendum. Integer a commodo tortor. Duis semper dolor eu" +
|
||||||
"suscipit a. Cras semper orci in sapien rhoncus bibendum. Suspendisse" +
|
"facilisis facilisis. Etiam venenatis turpis est, quis tincidunt velit" +
|
||||||
"eu ex lobortis, finibus enim in, condimentum quam. Maecenas eget dui" +
|
"suscipit a. Cras semper orci in sapien rhoncus bibendum. Suspendisse" +
|
||||||
"ipsum. Aliquam tortor leo, interdum eget congue ut, tempor id elit.");
|
"eu ex lobortis, finibus enim in, condimentum quam. Maecenas eget dui" +
|
||||||
utterance.addEventListener('start', function(e) {
|
"ipsum. Aliquam tortor leo, interdum eget congue ut, tempor id elit.");
|
||||||
ok(true, 'start utterance 1');
|
utterance.addEventListener('start', function(e) {
|
||||||
|
ok(true, 'start utterance 1');
|
||||||
|
speechSynthesis.cancel();
|
||||||
|
info('cancel!');
|
||||||
|
speechSynthesis.speak(utterance2);
|
||||||
|
info('speak??');
|
||||||
|
});
|
||||||
|
|
||||||
|
var utterance2 = new SpeechSynthesisUtterance("Proin ornare neque vitae " +
|
||||||
|
"risus mattis rutrum. Suspendisse a velit ut est convallis aliquet." +
|
||||||
|
"Nullam ante elit, malesuada vel luctus rutrum, ultricies nec libero." +
|
||||||
|
"Praesent eu iaculis orci. Sed nisl diam, sodales ac purus et," +
|
||||||
|
"volutpat interdum tortor. Nullam aliquam porta elit et maximus. Cras" +
|
||||||
|
"risus lectus, elementum vel sodales vel, ultricies eget lectus." +
|
||||||
|
"Curabitur velit lacus, mollis vel finibus et, molestie sit amet" +
|
||||||
|
"sapien. Proin vitae dolor ac augue posuere efficitur ac scelerisque" +
|
||||||
|
"diam. Nulla sed odio elit.");
|
||||||
|
utterance2.addEventListener('start', function() {
|
||||||
|
info('start');
|
||||||
|
speechSynthesis.cancel();
|
||||||
|
speechSynthesis.speak(utterance3);
|
||||||
|
});
|
||||||
|
utterance2.addEventListener('end', function(e) {
|
||||||
|
gotEndEvent = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
var utterance3 = new SpeechSynthesisUtterance("Hello, world 3!");
|
||||||
|
utterance3.addEventListener('start', function() {
|
||||||
|
ok(gotEndEvent, "didn't get start event for this utterance");
|
||||||
|
});
|
||||||
|
utterance3.addEventListener('end', done_cb);
|
||||||
|
|
||||||
|
// Speak/cancel while paused (Bug 1187105)
|
||||||
|
speechSynthesis.pause();
|
||||||
|
speechSynthesis.speak(new SpeechSynthesisUtterance("hello."));
|
||||||
|
ok(speechSynthesis.pending, "paused speechSynthesis has an utterance queued.");
|
||||||
speechSynthesis.cancel();
|
speechSynthesis.cancel();
|
||||||
speechSynthesis.speak(utterance2);
|
ok(!speechSynthesis.pending, "paused speechSynthesis has no utterance queued.");
|
||||||
});
|
speechSynthesis.resume();
|
||||||
|
|
||||||
var utterance2 = new SpeechSynthesisUtterance("Proin ornare neque vitae " +
|
speechSynthesis.speak(utterance);
|
||||||
"risus mattis rutrum. Suspendisse a velit ut est convallis aliquet." +
|
ok(!speechSynthesis.speaking, "speechSynthesis is not speaking yet.");
|
||||||
"Nullam ante elit, malesuada vel luctus rutrum, ultricies nec libero." +
|
ok(speechSynthesis.pending, "speechSynthesis has an utterance queued.");
|
||||||
"Praesent eu iaculis orci. Sed nisl diam, sodales ac purus et," +
|
}
|
||||||
"volutpat interdum tortor. Nullam aliquam porta elit et maximus. Cras" +
|
|
||||||
"risus lectus, elementum vel sodales vel, ultricies eget lectus." +
|
|
||||||
"Curabitur velit lacus, mollis vel finibus et, molestie sit amet" +
|
|
||||||
"sapien. Proin vitae dolor ac augue posuere efficitur ac scelerisque" +
|
|
||||||
"diam. Nulla sed odio elit.");
|
|
||||||
utterance2.addEventListener('start', function() {
|
|
||||||
speechSynthesis.cancel();
|
|
||||||
speechSynthesis.speak(utterance3);
|
|
||||||
});
|
|
||||||
utterance2.addEventListener('end', function(e) {
|
|
||||||
gotEndEvent = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
var utterance3 = new SpeechSynthesisUtterance("Hello, world 3!");
|
// Run test with no global queue, and then run it with a global queue.
|
||||||
utterance3.addEventListener('start', function() {
|
testFunc(function() {
|
||||||
ok(gotEndEvent, "didn't get start event for this utterance");
|
SpecialPowers.pushPrefEnv(
|
||||||
|
{ set: [['media.webspeech.synth.force_global_queue', true]] }, function() {
|
||||||
|
testFunc(SimpleTest.finish)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
utterance3.addEventListener('end', function(e) {
|
|
||||||
SimpleTest.finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Speak/cancel while paused (Bug 1187105)
|
|
||||||
speechSynthesis.pause();
|
|
||||||
speechSynthesis.speak(new SpeechSynthesisUtterance("hello."));
|
|
||||||
ok(speechSynthesis.pending, "paused speechSynthesis has an utterance queued.");
|
|
||||||
speechSynthesis.cancel();
|
|
||||||
ok(!speechSynthesis.pending, "paused speechSynthesis has no utterance queued.");
|
|
||||||
speechSynthesis.resume();
|
|
||||||
|
|
||||||
speechSynthesis.speak(utterance);
|
|
||||||
ok(!speechSynthesis.speaking, "speechSynthesis is not speaking yet.");
|
|
||||||
ok(speechSynthesis.pending, "speechSynthesis has an utterance queued.");
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -44,32 +44,39 @@ ok(langUriMap['en-CA'], 'No English-Canadian voice');
|
||||||
ok(langUriMap['fr-CA'], 'No French-Canadian voice');
|
ok(langUriMap['fr-CA'], 'No French-Canadian voice');
|
||||||
ok(langUriMap['es-MX'], 'No Spanish-Mexican voice');
|
ok(langUriMap['es-MX'], 'No Spanish-Mexican voice');
|
||||||
|
|
||||||
synthTestQueue(
|
function testFunc(done_cb) {
|
||||||
[[{text: "Hello, world."},
|
synthTestQueue(
|
||||||
{ uri: langUriMap['en-JM'] }],
|
[[{text: "Hello, world."},
|
||||||
[{text: "Bonjour tout le monde .", lang: "fr", rate: 0.5, pitch: 0.75},
|
{ uri: langUriMap['en-JM'] }],
|
||||||
{ uri: langUriMap['fr-CA'], rate: 0.5, pitch: 0.75}],
|
[{text: "Bonjour tout le monde .",
|
||||||
[{text: "How are you doing?", lang: "en-GB"},
|
args: { lang: "fr", rate: 0.5, pitch: 0.75 }},
|
||||||
{ rate: 1, pitch: 1, uri: langUriMap['en-GB']}],
|
{ uri: langUriMap['fr-CA'], rate: 0.5, pitch: 0.75}],
|
||||||
[{text: "¡hasta mañana!", lang: "es-MX"},
|
[{text: "How are you doing?", args: { lang: "en-GB" } },
|
||||||
{ uri: langUriMap['es-MX'] }]],
|
{ rate: 1, pitch: 1, uri: langUriMap['en-GB']}],
|
||||||
function () {
|
[{text: "¡hasta mañana!", args: { lang: "es-MX" } },
|
||||||
var test_data = [];
|
{ uri: langUriMap['es-MX'] }]],
|
||||||
var voices = speechSynthesis.getVoices();
|
function () {
|
||||||
for (var voice of voices) {
|
var test_data = [];
|
||||||
if (voice.voiceURI.indexOf('urn:moz-tts:fake-direct') < 0) {
|
var voices = speechSynthesis.getVoices();
|
||||||
continue;
|
for (var voice of voices) {
|
||||||
|
if (voice.voiceURI.indexOf('urn:moz-tts:fake-direct') < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
test_data.push([{text: "Hello world", args: { voice: voice} },
|
||||||
|
{uri: voice.voiceURI}]);
|
||||||
}
|
}
|
||||||
test_data.push([{text: "Hello world", voice: voice},
|
|
||||||
{uri: voice.voiceURI}]);
|
|
||||||
}
|
|
||||||
|
|
||||||
synthTestQueue(test_data,
|
synthTestQueue(test_data, done_cb);
|
||||||
function () {
|
});
|
||||||
SimpleTest.finish();
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// Run test with no global queue, and then run it with a global queue.
|
||||||
|
testFunc(function() {
|
||||||
|
SpecialPowers.pushPrefEnv(
|
||||||
|
{ set: [['media.webspeech.synth.force_global_queue', true]] }, function() {
|
||||||
|
testFunc(SimpleTest.finish)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -7,9 +7,15 @@ support-files =
|
||||||
file_speech_simple.html
|
file_speech_simple.html
|
||||||
file_speech_cancel.html
|
file_speech_cancel.html
|
||||||
file_indirect_service_events.html
|
file_indirect_service_events.html
|
||||||
|
file_global_queue.html
|
||||||
|
file_global_queue_cancel.html
|
||||||
|
file_global_queue_pause.html
|
||||||
|
|
||||||
[test_setup.html]
|
[test_setup.html]
|
||||||
[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_indirect_service_events.html]
|
[test_indirect_service_events.html]
|
||||||
|
[test_global_queue.html]
|
||||||
|
[test_global_queue_cancel.html]
|
||||||
|
[test_global_queue_pause.html]
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1188099
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test for Bug 1188099: Global queue should correctly schedule utterances</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=1188099">Mozilla Bug 1188099</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 525444 **/
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
SpecialPowers.pushPrefEnv({ set: [['media.webspeech.synth.enabled', true],
|
||||||
|
['media.webspeech.synth.force_global_queue', true]] },
|
||||||
|
function() { document.getElementById("testFrame").src = "file_global_queue.html"; });
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,34 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1188099
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test for Bug 1188099: Calling cancel() should work correctly with global queue</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=1188099">Mozilla Bug 1188099</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 525444 **/
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
SpecialPowers.pushPrefEnv({ set: [['media.webspeech.synth.enabled', true],
|
||||||
|
['media.webspeech.synth.force_global_queue', true]] },
|
||||||
|
function() { document.getElementById("testFrame").src = "file_global_queue_cancel.html"; });
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,34 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1188099
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test for Bug 1188099: Calling pause() should work correctly with global queue</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=1188099">Mozilla Bug 1188099</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 525444 **/
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
SpecialPowers.pushPrefEnv({ set: [['media.webspeech.synth.enabled', true],
|
||||||
|
['media.webspeech.synth.force_global_queue', true]] },
|
||||||
|
function() { document.getElementById("testFrame").src = "file_global_queue_pause.html"; });
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -24,8 +24,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1155034
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
SpecialPowers.pushPrefEnv({ set: [['media.webspeech.synth.enabled', true]] },
|
SpecialPowers.pushPrefEnv(
|
||||||
function() { document.getElementById("testFrame").src = "file_indirect_service_events.html"; });
|
{ set: [['media.webspeech.synth.enabled', true],
|
||||||
|
['media.webspeech.synth.force_global_queue', false]] },
|
||||||
|
function() { document.getElementById("testFrame").src = "file_indirect_service_events.html"; });
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -24,8 +24,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1150315
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
SpecialPowers.pushPrefEnv({ set: [['media.webspeech.synth.enabled', true]] },
|
SpecialPowers.pushPrefEnv(
|
||||||
function() { document.getElementById("testFrame").src = "file_speech_cancel.html"; });
|
{ set: [['media.webspeech.synth.enabled', true],
|
||||||
|
['media.webspeech.synth.force_global_queue', false]] },
|
||||||
|
function() { document.getElementById("testFrame").src = "file_speech_cancel.html"; });
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -24,8 +24,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=525444
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
SpecialPowers.pushPrefEnv({ set: [['media.webspeech.synth.enabled', true]] },
|
SpecialPowers.pushPrefEnv(
|
||||||
function() { document.getElementById("testFrame").src = "file_speech_queue.html"; });
|
{ set: [['media.webspeech.synth.enabled', true],
|
||||||
|
['media.webspeech.synth.force_global_queue', false]] },
|
||||||
|
function() { document.getElementById("testFrame").src = "file_speech_queue.html"; });
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче