Title: [164807] trunk
Revision
164807
Author
[email protected]
Date
2014-02-27 09:49:45 -0800 (Thu, 27 Feb 2014)

Log Message

speechSynthesis.speak of a zero length utterance kills future speech
https://bugs.webkit.org/show_bug.cgi?id=129403

Reviewed by Mario Sanchez Prada.

Source/WebCore:

Empty length strings may choke a synthesizer and result in didFinishSpeaking not being called.
The WebKit code should be proactive about screening out empty length strings.

Test: platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string.html

* Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::startSpeakingImmediately):

LayoutTests:

* platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string-expected.txt: Added.
* platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (164806 => 164807)


--- trunk/LayoutTests/ChangeLog	2014-02-27 17:02:13 UTC (rev 164806)
+++ trunk/LayoutTests/ChangeLog	2014-02-27 17:49:45 UTC (rev 164807)
@@ -1,3 +1,13 @@
+2014-02-27  Chris Fleizach  <[email protected]>
+
+        speechSynthesis.speak of a zero length utterance kills future speech
+        https://bugs.webkit.org/show_bug.cgi?id=129403
+
+        Reviewed by Mario Sanchez Prada.
+
+        * platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string-expected.txt: Added.
+        * platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string.html: Added.
+
 2014-02-27  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r164783.

Added: trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string-expected.txt (0 => 164807)


--- trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string-expected.txt	2014-02-27 17:49:45 UTC (rev 164807)
@@ -0,0 +1,12 @@
+This tests that an empty string sent to the synthesizer still generates a callback.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS speechSynthesis.speaking is false
+PASS event.elapsedTime > 0 is true
+PASS speechSynthesis.speaking is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string.html (0 => 164807)


--- trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string.html	2014-02-27 17:49:45 UTC (rev 164807)
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div id="console"></div>
+
+<script>
+
+    if (window.internals)
+        window.internals.enableMockSpeechSynthesizer();
+
+    description("This tests that an empty string sent to the synthesizer still generates a callback.");
+
+    if (window.testRunner)
+        testRunner.waitUntilDone();
+
+    window.jsTestIsAsync = true;
+
+    // Start a very short speaking job that will finish quickly.
+    var u = new SpeechSynthesisUtterance("");
+
+    u._onstart_ = function(event) {
+       shouldBeTrue("event.elapsedTime > 0");
+       shouldBeTrue("speechSynthesis.speaking");
+    }
+    u._onend_ = function(event) {
+       shouldBeTrue("event.elapsedTime > 0");
+       shouldBeFalse("speechSynthesis.speaking");
+       finishJSTest();
+    }
+
+    shouldBeFalse("speechSynthesis.speaking");
+    speechSynthesis.speak(u);
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (164806 => 164807)


--- trunk/Source/WebCore/ChangeLog	2014-02-27 17:02:13 UTC (rev 164806)
+++ trunk/Source/WebCore/ChangeLog	2014-02-27 17:49:45 UTC (rev 164807)
@@ -1,3 +1,18 @@
+2014-02-27  Chris Fleizach  <[email protected]>
+
+        speechSynthesis.speak of a zero length utterance kills future speech
+        https://bugs.webkit.org/show_bug.cgi?id=129403
+
+        Reviewed by Mario Sanchez Prada.
+
+        Empty length strings may choke a synthesizer and result in didFinishSpeaking not being called. 
+        The WebKit code should be proactive about screening out empty length strings.
+
+        Test: platform/mac/fast/speechsynthesis/speech-synthesis-speak-empty-string.html
+
+        * Modules/speech/SpeechSynthesis.cpp:
+        (WebCore::SpeechSynthesis::startSpeakingImmediately):
+
 2014-02-27  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r164783.

Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp (164806 => 164807)


--- trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp	2014-02-27 17:02:13 UTC (rev 164806)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp	2014-02-27 17:49:45 UTC (rev 164807)
@@ -107,6 +107,13 @@
     utterance->setStartTime(monotonicallyIncreasingTime());
     m_currentSpeechUtterance = utterance;
     m_isPaused = false;
+    
+    // Zero lengthed strings should immediately notify that the event is complete.
+    if (utterance->text().isEmpty()) {
+        handleSpeakingCompleted(utterance, false);
+        return;
+    }
+    
     if (!m_platformSpeechSynthesizer)
         m_platformSpeechSynthesizer = PlatformSpeechSynthesizer::create(this);
     m_platformSpeechSynthesizer->speak(utterance->platformUtterance());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to