4 https://bugzilla.mozilla.org/show_bug.cgi?id=525444
8 <title>Test for Bug
525444: Web Speech API check all classes are present
</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;
15 <script type=
"application/javascript" src=
"common.js"></script>
18 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=650295">Mozilla Bug
650295</a>
20 <div id=
"content" style=
"display: none">
24 <script type=
"application/javascript">
26 /** Test for Bug
525444 **/
28 ok(SpeechSynthesis,
"SpeechSynthesis exists in global scope");
29 ok(SpeechSynthesisVoice,
"SpeechSynthesisVoice exists in global scope");
30 ok(SpeechSynthesisErrorEvent,
"SpeechSynthesisErrorEvent exists in global scope");
31 ok(SpeechSynthesisEvent,
"SpeechSynthesisEvent exists in global scope");
33 // SpeechSynthesisUtterance is the only type that has a constructor
34 // and writable properties
35 ok(SpeechSynthesisUtterance,
"SpeechSynthesisUtterance exists in global scope");
36 var ssu = new SpeechSynthesisUtterance(
"hello world");
37 is(typeof ssu,
"object",
"SpeechSynthesisUtterance instance is an object");
38 is(ssu.text,
"hello world",
"SpeechSynthesisUtterance.text is correct");
39 is(ssu.volume,
1,
"SpeechSynthesisUtterance.volume default is correct");
40 is(ssu.rate,
1,
"SpeechSynthesisUtterance.rate default is correct");
41 is(ssu.pitch,
1,
"SpeechSynthesisUtterance.pitch default is correct");
46 is(ssu.lang,
"he-IL",
"SpeechSynthesisUtterance.lang is correct");
47 is(ssu.volume,
0.5,
"SpeechSynthesisUtterance.volume is correct");
48 is(ssu.rate,
2.0,
"SpeechSynthesisUtterance.rate is correct");
49 is(ssu.pitch,
1.5,
"SpeechSynthesisUtterance.pitch is correct");
51 // Assign a rate that is out of bounds
53 is(ssu.rate,
10,
"SpeechSynthesisUtterance.rate enforces max of 10");
55 is(ssu.rate.toPrecision(
1),
"0.1",
"SpeechSynthesisUtterance.rate enforces min of 0.1");
57 // Assign a volume which is out of bounds
59 is(ssu.volume,
1,
"SpeechSynthesisUtterance.volume enforces max of 1");
61 is(ssu.volume,
0,
"SpeechSynthesisUtterance.volume enforces min of 0");
63 // Assign a pitch which is out of bounds
65 is(ssu.pitch,
2,
"SpeechSynthesisUtterance.pitch enforces max of 2");
67 is(ssu.pitch,
0,
"SpeechSynthesisUtterance.pitch enforces min of 0");
69 // Test for singleton instance hanging off of window.
70 ok(speechSynthesis,
"speechSynthesis exists in global scope");
71 is(typeof speechSynthesis,
"object",
"speechSynthesis instance is an object");
72 is(typeof speechSynthesis.speak,
"function",
"speechSynthesis.speak is a function");
73 is(typeof speechSynthesis.cancel,
"function",
"speechSynthesis.cancel is a function");
74 is(typeof speechSynthesis.pause,
"function",
"speechSynthesis.pause is a function");
75 is(typeof speechSynthesis.resume,
"function",
"speechSynthesis.resume is a function");
76 is(typeof speechSynthesis.getVoices,
"function",
"speechSynthesis.getVoices is a function");
78 is(typeof speechSynthesis.pending,
"boolean",
"speechSynthesis.pending is a boolean");
79 is(typeof speechSynthesis.speaking,
"boolean",
"speechSynthesis.speaking is a boolean");
80 is(typeof speechSynthesis.paused,
"boolean",
"speechSynthesis.paused is a boolean");
82 var voices1 = speechSynthesis.getVoices();
83 var voices2 = speechSynthesis.getVoices();
85 ok(!!voices1.length,
"More than one voice found");
86 ok(voices1.length == voices2.length,
"Voice count matches");
88 for (var i in voices1) {
89 ok(voices1[i] == voices2[i],
"Voice instance matches");