DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
<!DOCTYPE HTML>
<html lang="en-US">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=525444
-->
<head>
  <meta charset="utf-8">
  <title>Test for Bug 525444: Web Speech API, check speech synth queue</title>
  <script type="application/javascript">
    window.SimpleTest = parent.SimpleTest;
    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=525444">Mozilla Bug 525444</a>
<p id="display"></p>
<div id="content" style="display: none">

</div>
<pre id="test">
<script type="application/javascript">

/** Test for Bug 525444 **/

// XXX: Rate and pitch are not tested.

var langUriMap = {};

for (let voice of speechSynthesis.getVoices()) {
  langUriMap[voice.lang] = voice.voiceURI;
  ok(true, voice.lang + ' ' + voice.voiceURI + ' ' + voice.default);
  is(voice.default, voice.lang == 'en-JM', 'Only Jamaican voice should be default');
}

ok(langUriMap['en-JM'], 'No English-Jamaican voice');
ok(langUriMap['en-GB'], 'No English-British voice');
ok(langUriMap['en-CA'], 'No English-Canadian voice');
ok(langUriMap['fr-CA'], 'No French-Canadian voice');
ok(langUriMap['es-MX'], 'No Spanish-Mexican voice');
ok(langUriMap['it-IT-fail'], 'No Failing Italian voice');

function testFunc(done_cb) {
  synthTestQueue(
    [[{text: "Hello, world."},
      { uri: langUriMap['en-JM'] }],
     [{text: "Bonjour tout le monde .",
       args: { lang: "fr", rate: 0.5, pitch: 0.75 }},
      { uri: langUriMap['fr-CA'], rate: 0.5, pitch: 0.75}],
     [{text: "How are you doing?", args: { lang: "en-GB" } },
      { rate: 1, pitch: 1, uri: langUriMap['en-GB']}],
     [{text: "Come stai?", args: { lang: "it-IT-fail" } },
      { rate: 1, pitch: 1, uri: langUriMap['it-IT-fail'], err: true }],
     [{text: "¡hasta mañana!", args: { lang: "es-MX" } },
      { uri: langUriMap['es-MX'] }]],
    function () {
      var test_data = [];
      var voices = speechSynthesis.getVoices();
      for (let voice of voices) {
        if (voice.lang.split("-").length > 2) {
          // Skip voices that don't automatically end with success
          continue;
        }
        test_data.push([{text: "Hello world", args: { voice} },
                        {uri: voice.voiceURI}]);
      }

      synthTestQueue(test_data, done_cb);
    });
}

// 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>
</pre>
</body>
</html>