OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>SpeechSynthesisUtterance voice attribute</title> | 2 <title>SpeechSynthesisUtterance voice attribute</title> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <script> | 5 <script> |
6 test(() => { | 6 test(() => { |
7 const u = new SpeechSynthesisUtterance(); | 7 const u = new SpeechSynthesisUtterance(); |
8 assert_equals(u.voice, null); | 8 assert_equals(u.voice, null); |
9 }, 'initial state'); | 9 }, 'initial state'); |
10 | 10 |
11 test(() => { | 11 test(() => { |
12 const u = new SpeechSynthesisUtterance(); | 12 const u = new SpeechSynthesisUtterance(); |
13 u.voice = null; | 13 u.voice = null; |
14 assert_equals(u.voice, null); | 14 assert_equals(u.voice, null); |
15 u.voice = undefined; | 15 u.voice = undefined; |
16 assert_equals(u.voice, null); | 16 assert_equals(u.voice, null); |
17 }, 'setting to null/undefined'); | 17 }, 'setting to null/undefined'); |
18 | 18 |
19 test(() => { | 19 test(() => { |
20 const u = new SpeechSynthesisUtterance(); | 20 const u = new SpeechSynthesisUtterance(); |
21 for (const value of [{}, "", window]) { | 21 for (const value of [{}, "", window]) { |
22 assert_throws(new TypeError, () => { u.voice = value; } ); | 22 assert_throws(new TypeError, () => { u.voice = value; } ); |
23 assert_equals(u.voice, null); | 23 assert_equals(u.voice, null); |
24 } | 24 } |
25 }, 'setting to non-SpeechSynthesisVoice values'); | 25 }, 'setting to non-SpeechSynthesisVoice values'); |
26 | 26 |
27 test(() => { | 27 test(() => { |
28 internals.enableMockSpeechSynthesizer(document); | 28 internals.enableMockSpeechSynthesizer(window); |
29 | 29 |
30 const u = new SpeechSynthesisUtterance(); | 30 const u = new SpeechSynthesisUtterance(); |
31 const voice = speechSynthesis.getVoices()[0]; | 31 const voice = speechSynthesis.getVoices()[0]; |
32 // TODO(foolip): This should test instanceof SpeechSynthesisVoice when that | 32 // TODO(foolip): This should test instanceof SpeechSynthesisVoice when that |
33 // interface is exposed. | 33 // interface is exposed. |
34 assert_equals(typeof voice, "object"); | 34 assert_equals(typeof voice, "object"); |
35 u.voice = voice; | 35 u.voice = voice; |
36 assert_equals(u.voice, voice); | 36 assert_equals(u.voice, voice); |
37 }, 'setting to SpeechSynthesisVoice'); | 37 }, 'setting to SpeechSynthesisVoice'); |
38 </script> | 38 </script> |
OLD | NEW |