Bug 1293613: Don't assume that all videos start at 0. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 10 Aug 2016 13:22:35 +1000
changeset 399475 ef996bbb17007f826e57f507e59d0b019e77551a
parent 399474 8ed9693ad9d11492ab0f1e2c1f93c813d57f4e1b
child 399476 e51fb05e733356cc2de7555793ae4319a0849822
push id25846
push userbmo:jyavenard@mozilla.com
push dateThu, 11 Aug 2016 05:48:53 +0000
reviewersgerald
bugs1293613
milestone51.0a1
Bug 1293613: Don't assume that all videos start at 0. r?gerald See issue https://github.com/w3c/web-platform-tests/issues/1939 MozReview-Commit-ID: LgDQRS8Xz3L
testing/web-platform/tests/media-source/mediasource-remove.html
--- a/testing/web-platform/tests/media-source/mediasource-remove.html
+++ b/testing/web-platform/tests/media-source/mediasource-remove.html
@@ -222,21 +222,22 @@
                   test.expectEvent(sourceBuffer, "updateend");
                   sourceBuffer.appendBuffer(mediaData);
 
                   test.waitForExpectedEvents(function()
                   {
                       mediaSource.endOfStream();
                       assert_false(sourceBuffer.updating, "updating");
 
+                      var start = Math.max(segmentInfo.media[0].timev, segmentInfo.media[0].timea).toFixed(3);
                       var duration = mediaElement.duration.toFixed(3);
                       var subType = MediaSourceUtil.getSubType(segmentInfo.type);
 
-                      assertBufferedEquals(sourceBuffer, "{ [0.000, " + duration + ") }", "Initial buffered range.");
-                      callback(test, mediaSource, sourceBuffer, duration, subType);
+                      assertBufferedEquals(sourceBuffer, "{ [" + start + ", " + duration + ") }", "Initial buffered range.");
+                      callback(test, mediaSource, sourceBuffer, duration, subType, segmentInfo);
                   });
               }, description);
           };
           function removeAndCheckBufferedRanges(test, mediaSource, sourceBuffer, start, end, expected)
           {
               test.expectEvent(sourceBuffer, "updatestart");
               test.expectEvent(sourceBuffer, "update");
               test.expectEvent(sourceBuffer, "updateend");
@@ -247,50 +248,52 @@
                   mediaSource.endOfStream();
                   assert_false(sourceBuffer.updating, "updating");
 
                   assertBufferedEquals(sourceBuffer, expected, "Buffered ranges after remove().");
                   test.done();
               });
           }
 
-          removeAppendedDataTests(function(test, mediaSource, sourceBuffer, duration, subType)
+          removeAppendedDataTests(function(test, mediaSource, sourceBuffer, duration, subType, segmentInfo)
           {
               removeAndCheckBufferedRanges(test, mediaSource, sourceBuffer, 0, Number.POSITIVE_INFINITY, "{ }");
           }, "Test removing all appended data.");
 
-          removeAppendedDataTests(function(test, mediaSource, sourceBuffer, duration, subType)
+          removeAppendedDataTests(function(test, mediaSource, sourceBuffer, duration, subType, segmentInfo)
           {
               var expectations = {
                 webm: ("{ [3.187, " + duration + ") }"),
-                mp4: ("{ [3.154, " + duration + ") }"),
+                mp4: ("{ [3.187, " + duration + ") }"),
               };
 
               // Note: Range doesn't start exactly at the end of the remove range because there isn't
               // a keyframe there. The resulting range starts at the first keyframe >= the end time.
               removeAndCheckBufferedRanges(test, mediaSource, sourceBuffer, 0, 3, expectations[subType]);
           }, "Test removing beginning of appended data.");
 
-          removeAppendedDataTests(function(test, mediaSource, sourceBuffer, duration, subType)
+          removeAppendedDataTests(function(test, mediaSource, sourceBuffer, duration, subType, segmentInfo)
           {
+              var start = Math.max(segmentInfo.media[0].timev, segmentInfo.media[0].timea).toFixed(3);
               var expectations = {
-                webm: ("{ [0.000, 1.012) [3.187, " + duration + ") }"),
-                mp4: ("{ [0.000, 1.022) [3.154, " + duration + ") }"),
+                webm: ("{ [" + start + ", 1.012) [3.187, " + duration + ") }"),
+                mp4: ("{ [" + start + ", 0.996) [3.187, " + duration + ") }"),
               };
 
               // Note: The first resulting range ends slightly after start because the removal algorithm only removes
               // frames with a timestamp >= the start time. If a frame starts before and ends after the remove() start
               // timestamp, then it stays in the buffer.
               removeAndCheckBufferedRanges(test, mediaSource, sourceBuffer, 1, 3, expectations[subType]);
           }, "Test removing the middle of appended data.");
 
-          removeAppendedDataTests(function(test, mediaSource, sourceBuffer, duration, subType)
+          removeAppendedDataTests(function(test, mediaSource, sourceBuffer, duration, subType, segmentInfo)
           {
+              var start = Math.max(segmentInfo.media[0].timev, segmentInfo.media[0].timea).toFixed(3);
               var expectations = {
-                webm: "{ [0.000, 1.012) }",
-                mp4: "{ [0.000, 1.029) }",
+                webm: "{ [" + start + ", 1.029) }",
+                mp4: "{ [" + start + ", 1.022) }",
               };
 
               removeAndCheckBufferedRanges(test, mediaSource, sourceBuffer, 1, Number.POSITIVE_INFINITY, expectations[subType]);
           }, "Test removing the end of appended data.");
         </script>
     </body>
 </html>