blob: 3087644b745578a2d5be9e4fb93c3bcf6341307f [file] [log] [blame]
<!DOCTYPE html>
<title>SpeechSynthesisUtterance voice attribute</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(() => {
const u = new SpeechSynthesisUtterance();
assert_equals(u.voice, null);
}, 'initial state');
test(() => {
const u = new SpeechSynthesisUtterance();
u.voice = null;
assert_equals(u.voice, null);
u.voice = undefined;
assert_equals(u.voice, null);
}, 'setting to null/undefined');
test(() => {
const u = new SpeechSynthesisUtterance();
for (const value of [{}, "", window]) {
assert_throws(new TypeError, () => { u.voice = value; } );
assert_equals(u.voice, null);
}
}, 'setting to non-SpeechSynthesisVoice values');
test(() => {
internals.enableMockSpeechSynthesizer(window);
const u = new SpeechSynthesisUtterance();
const voice = speechSynthesis.getVoices()[0];
// TODO(foolip): This should test instanceof SpeechSynthesisVoice when that
// interface is exposed.
assert_equals(typeof voice, "object");
u.voice = voice;
assert_equals(u.voice, voice);
}, 'setting to SpeechSynthesisVoice');
</script>