Bug 1208373 - Check that we don't get "ended" event for tracks after calling stop(). r?jib draft
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 04 May 2016 11:26:12 +0200
changeset 363325 82f5f1a61d509a58bbd34b8f9cb820e82d1955c0
parent 356965 86730d0a82093d705e44f33a34973d28b269f1ea
child 363326 8e50d2ed8a9c416b70cb615f6613eb72f32e9d6f
push id17172
push userpehrsons@gmail.com
push dateWed, 04 May 2016 14:35:55 +0000
reviewersjib
bugs1208373
milestone49.0a1
Bug 1208373 - Check that we don't get "ended" event for tracks after calling stop(). r?jib MozReview-Commit-ID: K9gOZtUNQ5K
dom/media/tests/mochitest/mediaStreamPlayback.js
--- a/dom/media/tests/mochitest/mediaStreamPlayback.js
+++ b/dom/media/tests/mochitest/mediaStreamPlayback.js
@@ -50,18 +50,23 @@ MediaStreamPlayback.prototype = {
     var elem = this.mediaElement;
     var waitForEnded = () => new Promise(resolve => {
       elem.addEventListener('ended', function ended() {
         elem.removeEventListener('ended', ended);
         resolve();
       });
     });
 
-    // TODO (bug 910249) Also check that all the tracks are local.
-    this.mediaStream.getTracks().forEach(t => t.stop());
+    this.mediaStream.getTracks().filter(t => t.readyState == "live").forEach(t => {
+      t.addEventListener("ended", function endedTrackUnexpected() {
+        ok(false, "Unexpected ended event for track " + t.id);
+      });
+      t.stop();
+      is(t.readyState, "ended", "Stopped track " + t.id + " should be ended");
+    });
 
     // XXX (bug 1208316) When we implement MediaStream.active, do not stop
     // the stream. We just do it now so the media element will raise 'ended'.
     if (!this.mediaStream.stop) {
       return;
     }
     this.mediaStream.stop();
     return timeout(waitForEnded(), ENDED_TIMEOUT_LENGTH, "ended event never fired")