Bug 1123189: Use sourceended instead of loadeddata to check durationchanged count r=karlt
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 20 Jan 2015 16:22:27 +1100
changeset 242324 bddb69ed8cae4452ab2758fb3a9175eff0e2a628
parent 242323 8220056219546b8089b4a75321a9419d338396dc
child 242325 077140ba65d0ffab8395545496e21d963c01baf5
push id7677
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 18:11:24 +0000
treeherdermozilla-aurora@f531d838c055 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1123189, 20140717
milestone38.0a1
Bug 1123189: Use sourceended instead of loadeddata to check durationchanged count r=karlt http://www.w3.org/TR/2014/CR-media-source-20140717/#h4_sourcebuffer-coded-frame-processing indicates that durationchange should be queued after loadeddata, which happens sometimes when durationchange is queued instead of dispatched synchronously.
dom/media/mediasource/test/test_DurationUpdated.html
--- a/dom/media/mediasource/test/test_DurationUpdated.html
+++ b/dom/media/mediasource/test/test_DurationUpdated.html
@@ -22,35 +22,35 @@ runWithMSE(function (ms, v) {
     fetchWithXHR("seek.webm", function (arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
       sb.addEventListener("updateend", function () {
         updateCount++;
         if (updateCount == 1) {
           v.addEventListener("loadedmetadata", function () {
             v.addEventListener("durationchange", function () {
               durationChangeCount++;
-              if (durationChangeCount == 1) {
-                sb.addEventListener('updateend', function(e) {
-                  sb.removeEventListener('updateend', arguments.callee);
-                  sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
-                });
-              }
             });
             // Set mediasource duration to 0, so future appendBuffer
             // will update the mediasource duration
             // setting ms.duration will fire updatestart/update/updateend
-            //  event as per w3c spec
+            // event as per w3c spec followed by a durationchange
             ms.duration = 0;
           });
+        } else if (updateCount == 2) {
+          // will fire updatestart/update/updateend
+          // and a durationchange
+          sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
+        } else if (updateCount == 3) {
+          // this will not fire durationchange as new duration == old duration
+          ms.endOfStream();
         }
       });
     });
   });
-
-  v.addEventListener("loadeddata", function () {
+  ms.addEventListener("sourceended", function () {
     // XXX: Duration should be exactly 4.0, see bug 1065207.
     is(durationChangeCount, 2, "durationchange not fired as many times as expected");
     ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
     SimpleTest.finish();
   });
 });
 
 </script>