content/media/webspeech/synth/test/file_setup.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=525444
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <meta charset="utf-8">
michael@0 8 <title>Test for Bug 525444: Web Speech API check all classes are present</title>
michael@0 9 <script type="application/javascript">
michael@0 10 window.SimpleTest = parent.SimpleTest;
michael@0 11 window.is = parent.is;
michael@0 12 window.isnot = parent.isnot;
michael@0 13 window.ok = parent.ok;
michael@0 14 </script>
michael@0 15 <script type="application/javascript" src="common.js"></script>
michael@0 16 </head>
michael@0 17 <body>
michael@0 18 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=650295">Mozilla Bug 650295</a>
michael@0 19 <p id="display"></p>
michael@0 20 <div id="content" style="display: none">
michael@0 21
michael@0 22 </div>
michael@0 23 <pre id="test">
michael@0 24 <script type="application/javascript">
michael@0 25
michael@0 26 /** Test for Bug 525444 **/
michael@0 27
michael@0 28 synthAddVoice('TestSpeechServiceNoAudio', 'Bob Marley', 'en-JM', true);
michael@0 29 synthAddVoice('TestSpeechServiceNoAudio', 'Amy Winehouse', 'en-GB', true);
michael@0 30 synthAddVoice('TestSpeechServiceNoAudio', 'Leonard Cohen', 'en-CA', true);
michael@0 31 synthAddVoice('TestSpeechServiceNoAudio', 'Celine Dion', 'fr-CA', true);
michael@0 32 synthAddVoice('TestSpeechServiceNoAudio', 'Julieta Venegas', 'es-MX', true);
michael@0 33
michael@0 34 ok(SpeechSynthesis, "SpeechSynthesis exists in global scope");
michael@0 35 ok(SpeechSynthesisVoice, "SpeechSynthesisVoice exists in global scope");
michael@0 36 ok(SpeechSynthesisEvent, "SpeechSynthesisEvent exists in global scope");
michael@0 37
michael@0 38 // SpeechSynthesisUtterance is the only type that has a constructor
michael@0 39 // and writable properties
michael@0 40 ok(SpeechSynthesisUtterance, "SpeechSynthesisUtterance exists in global scope");
michael@0 41 var ssu = new SpeechSynthesisUtterance("hello world");
michael@0 42 is(typeof ssu, "object", "SpeechSynthesisUtterance instance is an object");
michael@0 43 is(ssu.text, "hello world", "SpeechSynthesisUtterance.text is correct");
michael@0 44 is(ssu.volume, 1, "SpeechSynthesisUtterance.volume default is correct");
michael@0 45 is(ssu.rate, 1, "SpeechSynthesisUtterance.rate default is correct");
michael@0 46 is(ssu.pitch, 1, "SpeechSynthesisUtterance.pitch default is correct");
michael@0 47 ssu.lang = "he-IL";
michael@0 48 ssu.volume = 0.5;
michael@0 49 ssu.rate = 2.0;
michael@0 50 ssu.pitch = 1.5;
michael@0 51 is(ssu.lang, "he-IL", "SpeechSynthesisUtterance.lang is correct");
michael@0 52 is(ssu.volume, 0.5, "SpeechSynthesisUtterance.volume is correct");
michael@0 53 is(ssu.rate, 2.0, "SpeechSynthesisUtterance.rate is correct");
michael@0 54 is(ssu.pitch, 1.5, "SpeechSynthesisUtterance.pitch is correct");
michael@0 55
michael@0 56 // Test for singleton instance hanging off of window.
michael@0 57 ok(speechSynthesis, "speechSynthesis exists in global scope");
michael@0 58 is(typeof speechSynthesis, "object", "speechSynthesis instance is an object");
michael@0 59 is(typeof speechSynthesis.speak, "function", "speechSynthesis.speak is a function");
michael@0 60 is(typeof speechSynthesis.cancel, "function", "speechSynthesis.cancel is a function");
michael@0 61 is(typeof speechSynthesis.pause, "function", "speechSynthesis.pause is a function");
michael@0 62 is(typeof speechSynthesis.resume, "function", "speechSynthesis.resume is a function");
michael@0 63 is(typeof speechSynthesis.getVoices, "function", "speechSynthesis.getVoices is a function");
michael@0 64
michael@0 65 is(typeof speechSynthesis.pending, "boolean", "speechSynthesis.pending is a boolean");
michael@0 66 is(typeof speechSynthesis.speaking, "boolean", "speechSynthesis.speaking is a boolean");
michael@0 67 is(typeof speechSynthesis.paused, "boolean", "speechSynthesis.paused is a boolean");
michael@0 68
michael@0 69 var voices1 = speechSynthesis.getVoices();
michael@0 70 var voices2 = speechSynthesis.getVoices();
michael@0 71
michael@0 72 ok(voices1.length == voices2.length, "Voice count matches");
michael@0 73
michael@0 74 for (var i in voices1) {
michael@0 75 ok(voices1[i] == voices2[i], "Voice instance matches");
michael@0 76 }
michael@0 77
michael@0 78 synthCleanup();
michael@0 79
michael@0 80 SimpleTest.finish();
michael@0 81 </script>
michael@0 82 </pre>
michael@0 83 </body>
michael@0 84 </html>

mercurial