Bug 1178738 - Update narrator to use error events when narration is stopped. r=Gijs
☠☠ backed out by cb32941f1d46 ☠ ☠
authorEitan Isaacson <eitan@monotonous.org>
Wed, 18 May 2016 09:50:04 -0700
changeset 341243 54d1e8caf69b2ffe033c4664b5651a1f7987ecb5
parent 341242 5c995bbdfa3ac09234e829d5a8ba91741c89ff35
child 341244 f34508f1a4a0f2c5a3f1a3faba15a51dbd8f4ee8
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1178738
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1178738 - Update narrator to use error events when narration is stopped. r=Gijs MozReview-Commit-ID: L9Bd2WDdlMp
toolkit/components/narrate/Narrator.jsm
--- a/toolkit/components/narrate/Narrator.jsm
+++ b/toolkit/components/narrate/Narrator.jsm
@@ -172,39 +172,44 @@ Narrator.prototype = {
           this._sendTestEvent("paragraphstart", {
             voice: utterance.chosenVoiceURI,
             rate: utterance.rate,
             paragraph: paragraph.textContent
           });
         }
       });
 
-      utterance.addEventListener("end", () => {
+      let onDone = (e) => {
         if (!this._win) {
           // page got unloaded, don't do anything.
           return;
         }
 
+        if (e.type == "error" &&
+            !(['interrupted', 'canceled'].includes(e.error))) {
+          reject("speech synthesis failed");
+          return;
+        }
+
         paragraph.classList.remove("narrating");
         this._startTime = 0;
         if (this._inTest) {
           this._sendTestEvent("paragraphend", {});
         }
 
         if (this._stopped) {
           // User pressed stopped.
           resolve();
         } else {
           this._speakInner().then(resolve, reject);
         }
-      });
+      };
 
-      utterance.addEventListener("error", () => {
-        reject("speech synthesis failed");
-      });
+      utterance.addEventListener("end", onDone);
+      utterance.addEventListener("error", onDone);
 
       this._win.speechSynthesis.speak(utterance);
     });
   },
 
   start: function(speechOptions) {
     this._speechOptions = {
       rate: speechOptions.rate,