Bug 1123189: Use sourceended instead of loadeddata to check durationchanged count r=karlt a=sledru
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 20 Jan 2015 16:22:27 +1100
changeset 249354 c32a06cb18a58154b4e96087f589e07b84fa8e27
parent 249353 2d16e1cc65da65ca260826f711e846f2cff2606c
child 249355 044f52a1b4e070c9ae3da31247cca1a0726762f9
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, sledru
bugs1123189, 20140717
milestone37.0a2
Bug 1123189: Use sourceended instead of loadeddata to check durationchanged count r=karlt a=sledru 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>