Bug 1291946 - Bug 1291953 - Call mozCapturedStreamXXX in onloadedmetadata callback. r?pehrsons. draft
authorctai <ctai@mozilla.com>
Mon, 15 Aug 2016 14:46:30 +0800
changeset 401011 dfa75740c20329094c7ccff649b1a48e4bbf3a61
parent 401010 0c8ab576e6b692354b870713ec481b01f16cb6d9
child 401012 66b179e2098051f32b4de2d57f3c5272ba42ff51
push id26334
push userbmo:ctai@mozilla.com
push dateTue, 16 Aug 2016 05:18:28 +0000
reviewerspehrsons
bugs1291946, 1291953
milestone51.0a1
Bug 1291946 - Bug 1291953 - Call mozCapturedStreamXXX in onloadedmetadata callback. r?pehrsons. MozReview-Commit-ID: 6gLa4OYT9v2
dom/media/test/test_streams_element_capture_createObjectURL.html
--- a/dom/media/test/test_streams_element_capture_createObjectURL.html
+++ b/dom/media/test/test_streams_element_capture_createObjectURL.html
@@ -29,39 +29,43 @@ function isGreaterThanOrEqualEps(a, b, m
 function startTest(test, token) {
   manager.started(token);
 
   var v = document.createElement('video');
   var vout = document.createElement('video');
   vout.token = token;
 
   v.src = test.name;
-  var stream = v.mozCaptureStreamUntilEnded();
-  is(stream.currentTime, 0, test.name + " stream initial currentTime");
-  vout.src = URL.createObjectURL(stream);
+  v.preload = "metadata"
+  var stream;
 
-  var checkEnded = function(test, vout, stream) { return function() {
+  var checkEnded = function() {
     is(stream.currentTime, vout.currentTime, test.name + " stream final currentTime");
     if (test.duration) {
       isGreaterThanOrEqualEps(vout.currentTime, test.duration,
          test.name + " current time at end");
     }
     is(vout.readyState, vout.HAVE_CURRENT_DATA, test.name + " checking readyState");
     ok(vout.ended, test.name + " checking playback has ended");
     if (test.type.match(/^video/)) {
       checkDrawImage(vout);
     }
     vout.parentNode.removeChild(vout);
     URL.revokeObjectURL(vout.src);
     manager.finished(vout.token);
-  }}(test, vout, stream);
+  };
   vout.addEventListener("ended", checkEnded, false);
 
   document.body.appendChild(vout);
-  v.play();
-  vout.play();
+  v.onloadedmetadata = function () {
+    stream = v.mozCaptureStreamUntilEnded();
+    is(stream.currentTime, 0, test.name + " stream initial currentTime");
+    vout.src = URL.createObjectURL(stream);
+    v.play();
+    vout.play();
+  };
 }
 
 manager.runTests([getPlayableVideo(gSmallTests)], startTest);
 </script>
 </pre>
 </body>
 </html>