file_speech_queue.html (2708B)
1 <!DOCTYPE HTML> 2 <html lang="en-US"> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=525444 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 525444: Web Speech API, check speech synth queue</title> 9 <script type="application/javascript"> 10 window.SimpleTest = parent.SimpleTest; 11 window.is = parent.is; 12 window.isnot = parent.isnot; 13 window.ok = parent.ok; 14 </script> 15 <script type="application/javascript" src="common.js"></script> 16 </head> 17 <body> 18 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=525444">Mozilla Bug 525444</a> 19 <p id="display"></p> 20 <div id="content" style="display: none"> 21 22 </div> 23 <pre id="test"> 24 <script type="application/javascript"> 25 26 /** Test for Bug 525444 */ 27 28 // XXX: Rate and pitch are not tested. 29 30 var langUriMap = {}; 31 32 for (let voice of speechSynthesis.getVoices()) { 33 langUriMap[voice.lang] = voice.voiceURI; 34 ok(true, voice.lang + ' ' + voice.voiceURI + ' ' + voice.default); 35 is(voice.default, voice.lang == 'en-JM', 'Only Jamaican voice should be default'); 36 } 37 38 ok(langUriMap['en-JM'], 'No English-Jamaican voice'); 39 ok(langUriMap['en-GB'], 'No English-British voice'); 40 ok(langUriMap['en-CA'], 'No English-Canadian voice'); 41 ok(langUriMap['fr-CA'], 'No French-Canadian voice'); 42 ok(langUriMap['es-MX'], 'No Spanish-Mexican voice'); 43 ok(langUriMap['it-IT-fail'], 'No Failing Italian voice'); 44 45 function testFunc(done_cb) { 46 synthTestQueue( 47 [[{text: "Hello, world."}, 48 { uri: langUriMap['en-JM'] }], 49 [{text: "Bonjour tout le monde .", 50 args: { lang: "fr", rate: 0.5, pitch: 0.75 }}, 51 { uri: langUriMap['fr-CA'], rate: 0.5, pitch: 0.75}], 52 [{text: "How are you doing?", args: { lang: "en-GB" } }, 53 { rate: 1, pitch: 1, uri: langUriMap['en-GB']}], 54 [{text: "Come stai?", args: { lang: "it-IT-fail" } }, 55 { rate: 1, pitch: 1, uri: langUriMap['it-IT-fail'], err: true }], 56 [{text: "¡hasta mañana!", args: { lang: "es-MX" } }, 57 { uri: langUriMap['es-MX'] }]], 58 function () { 59 var test_data = []; 60 var voices = speechSynthesis.getVoices(); 61 for (let voice of voices) { 62 if (voice.lang.split("-").length > 2) { 63 // Skip voices that don't automatically end with success 64 continue; 65 } 66 test_data.push([{text: "Hello world", args: { voice} }, 67 {uri: voice.voiceURI}]); 68 } 69 70 synthTestQueue(test_data, done_cb); 71 }); 72 } 73 74 // Run test with no global queue, and then run it with a global queue. 75 testFunc(function() { 76 SpecialPowers.pushPrefEnv( 77 { set: [['media.webspeech.synth.force_global_queue', true]] }, function() { 78 testFunc(SimpleTest.finish) 79 }); 80 }); 81 82 83 </script> 84 </pre> 85 </body> 86 </html>