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 242983 09df37258699
parent 242982 731843c58e0d
child 242984 677c75e4d519
push id4354
push userrgiles@mozilla.com
push date2015-01-22 18:52 +0000
treeherdermozilla-beta@a48f8c55a98c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, sledru
bugs1123189, 20140717
milestone36.0
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>