chromium/third_party/blink/web_tests/fast/speechsynthesis/speech-synthesis-utterance-uses-voice.html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body id="body">

<div id="console"></div>

<script>
    description("This tests that we can get synthesizer voices on the Mac");

    if (window.internals)
        internals.enableMockSpeechSynthesizer(window);

    if (window.testRunner)
        testRunner.waitUntilDone();

    window.jsTestIsAsync = true;

    var list;
    speechSynthesis.onvoiceschanged = function() {
        list = speechSynthesis.getVoices(); 
        continueTest();
    }

    var u;
    var voice;

    function continueTest() {
        voice = list[0];

        // Start a very short speaking job that will finish quickly.
        u = new SpeechSynthesisUtterance("this is a test string.");
        u.voice = voice;

        debug("Verify that setting and retrieving the voice works.");
        shouldBeTrue("u.voice.name == voice.name");

        u.onend = function(event) {
           debug("Speech job finished successfully.");
           finishJSTest();
        }

        speechSynthesis.speak(u);    
    }

</script>

</body>
</html>