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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/webspeech/synth/test/file_setup.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,84 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=525444
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test for Bug 525444: Web Speech API check all classes are present</title>
    1.12 +  <script type="application/javascript">
    1.13 +    window.SimpleTest = parent.SimpleTest;
    1.14 +    window.is = parent.is;
    1.15 +    window.isnot = parent.isnot;
    1.16 +    window.ok = parent.ok;
    1.17 +  </script>
    1.18 +  <script type="application/javascript" src="common.js"></script>
    1.19 +</head>
    1.20 +<body>
    1.21 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=650295">Mozilla Bug 650295</a>
    1.22 +<p id="display"></p>
    1.23 +<div id="content" style="display: none">
    1.24 +  
    1.25 +</div>
    1.26 +<pre id="test">
    1.27 +<script type="application/javascript">
    1.28 +
    1.29 +/** Test for Bug 525444 **/
    1.30 +
    1.31 +synthAddVoice('TestSpeechServiceNoAudio', 'Bob Marley', 'en-JM', true);
    1.32 +synthAddVoice('TestSpeechServiceNoAudio', 'Amy Winehouse', 'en-GB', true);
    1.33 +synthAddVoice('TestSpeechServiceNoAudio', 'Leonard Cohen', 'en-CA', true);
    1.34 +synthAddVoice('TestSpeechServiceNoAudio', 'Celine Dion', 'fr-CA', true);
    1.35 +synthAddVoice('TestSpeechServiceNoAudio', 'Julieta Venegas', 'es-MX', true);
    1.36 +
    1.37 +ok(SpeechSynthesis, "SpeechSynthesis exists in global scope");
    1.38 +ok(SpeechSynthesisVoice, "SpeechSynthesisVoice exists in global scope");
    1.39 +ok(SpeechSynthesisEvent, "SpeechSynthesisEvent exists in global scope");
    1.40 +
    1.41 +// SpeechSynthesisUtterance is the only type that has a constructor
    1.42 +//  and writable properties
    1.43 +ok(SpeechSynthesisUtterance, "SpeechSynthesisUtterance exists in global scope");
    1.44 +var ssu = new SpeechSynthesisUtterance("hello world");
    1.45 +is(typeof ssu, "object", "SpeechSynthesisUtterance instance is an object");
    1.46 +is(ssu.text, "hello world", "SpeechSynthesisUtterance.text is correct");
    1.47 +is(ssu.volume, 1, "SpeechSynthesisUtterance.volume default is correct");
    1.48 +is(ssu.rate, 1, "SpeechSynthesisUtterance.rate default is correct");
    1.49 +is(ssu.pitch, 1, "SpeechSynthesisUtterance.pitch default is correct");
    1.50 +ssu.lang = "he-IL";
    1.51 +ssu.volume = 0.5;
    1.52 +ssu.rate = 2.0;
    1.53 +ssu.pitch = 1.5;
    1.54 +is(ssu.lang, "he-IL", "SpeechSynthesisUtterance.lang is correct");
    1.55 +is(ssu.volume, 0.5,  "SpeechSynthesisUtterance.volume is correct");
    1.56 +is(ssu.rate, 2.0,  "SpeechSynthesisUtterance.rate is correct");
    1.57 +is(ssu.pitch, 1.5,  "SpeechSynthesisUtterance.pitch is correct");
    1.58 +
    1.59 +// Test for singleton instance hanging off of window.
    1.60 +ok(speechSynthesis, "speechSynthesis exists in global scope");
    1.61 +is(typeof speechSynthesis, "object", "speechSynthesis instance is an object");
    1.62 +is(typeof speechSynthesis.speak, "function", "speechSynthesis.speak is a function");
    1.63 +is(typeof speechSynthesis.cancel, "function", "speechSynthesis.cancel is a function");
    1.64 +is(typeof speechSynthesis.pause, "function", "speechSynthesis.pause is a function");
    1.65 +is(typeof speechSynthesis.resume, "function", "speechSynthesis.resume is a function");
    1.66 +is(typeof speechSynthesis.getVoices, "function", "speechSynthesis.getVoices is a function");
    1.67 +
    1.68 +is(typeof speechSynthesis.pending, "boolean", "speechSynthesis.pending is a boolean");
    1.69 +is(typeof speechSynthesis.speaking, "boolean", "speechSynthesis.speaking is a boolean");
    1.70 +is(typeof speechSynthesis.paused, "boolean", "speechSynthesis.paused is a boolean");
    1.71 +
    1.72 +var voices1 = speechSynthesis.getVoices();
    1.73 +var voices2 = speechSynthesis.getVoices();
    1.74 +
    1.75 +ok(voices1.length == voices2.length, "Voice count matches");
    1.76 +
    1.77 +for (var i in voices1) {
    1.78 +  ok(voices1[i] == voices2[i], "Voice instance matches");
    1.79 +}
    1.80 +
    1.81 +synthCleanup();
    1.82 +
    1.83 +SimpleTest.finish();
    1.84 +</script>
    1.85 +</pre>
    1.86 +</body>
    1.87 +</html>

mercurial