dom/media/webspeech/synth/test/file_global_queue.html
author Sandor Molnar <smolnar@mozilla.com>
Wed, 10 Aug 2022 05:20:08 +0300
changeset 626626 615367610bb5ff8411add68f8aa79628fd90c157
parent 256437 f89e9a209c6c24a35580d8d18bd78204f4ef175b
permissions -rw-r--r--
Backed out 2 changesets (bug 793686) for causing reftest failures. CLOSED TREE Backed out changeset b7e8fd18039a (bug 793686) Backed out changeset fcf30cda2dce (bug 793686)

<!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>