Bug 1274221 - Test that multiple tracks of the same source all end when in the same stream. r?jib draft
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 24 May 2016 13:24:04 +0200
changeset 370265 c539999a334d1f357da0d85b189883dfdd5394b8
parent 370262 9781ba476376cfb81cf0f60c9ead358973511d7a
child 370266 78e184e8cbc312b14dad6d5e4a0b993df7bcc67d
push id19025
push userpehrsons@gmail.com
push dateTue, 24 May 2016 12:18:19 +0000
reviewersjib
bugs1274221
milestone49.0a1
Bug 1274221 - Test that multiple tracks of the same source all end when in the same stream. r?jib MozReview-Commit-ID: 64T6I4RDrKH
dom/media/tests/mochitest/test_getUserMedia_trackEnded.html
--- a/dom/media/tests/mochitest/test_getUserMedia_trackEnded.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_trackEnded.html
@@ -22,18 +22,23 @@
   runTest(() => {
     let iframe = document.getElementById("iframe");
     let stream;
     // We're passing callbacks into a method in the iframe here, because
     // a Promise created in the iframe is unusable after the iframe has
     // navigated away (see bug 1269400 for details).
     return new Promise((resolve, reject) =>
         iframe.contentDocument.gUM({audio: true, video: true}, resolve, reject))
-      .then(s => stream = s)
-      .then(() => {
+      .then(s => {
+        // We're cloning a stream containing identical tracks (an original
+        // and its clone) to test that ended works both for originals
+        // clones when they're both owned by the same MediaStream.
+        // (Bug 1274221)
+        stream = new MediaStream([].concat(s.getTracks(), s.getTracks())
+                                   .map(t => t.clone())).clone();
         var allTracksEnded = Promise.all(stream.getTracks().map(t => {
           info("Set up ended handler for track " + t.id);
           return haveEvent(t, "ended", wait(5000))
             .then(event => {
               info("ended handler invoked for track " + t.id);
               is(event.target, t, "Target should be correct");
             }, e => e ? Promise.reject(e)
                       : ok(false, "ended event never raised for track " + t.id));