Bug 1293613: Don't assume that once playing event has fired, the earlier appendBuffer has completed. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 10 Aug 2016 15:10:47 +1000
changeset 399478 cb4aec06a8883d385c9fc3df4ec890b7fc18de8e
parent 399477 f443d14ebdb69af1503788f481d130e842cd5244
child 399479 6af48593fbb4d39d6d0bb9006501de8bda8fa573
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 once playing event has fired, the earlier appendBuffer has completed. r?gerald The two operations are asynchronous and independent. MozReview-Commit-ID: D2woSoIzE6p
testing/web-platform/tests/media-source/mediasource-seek-during-pending-seek.html
--- a/testing/web-platform/tests/media-source/mediasource-seek-during-pending-seek.html
+++ b/testing/web-platform/tests/media-source/mediasource-seek-during-pending-seek.html
@@ -48,18 +48,32 @@
                   test.expectEvent(mediaElement, 'seeked', 'mediaElement finished seek');
                   test.expectEvent(mediaElement, 'playing', 'mediaElement playing');
 
                   MediaSourceUtil.appendUntilEventFires(test, mediaElement, 'playing', sourceBuffer, mediaData, segmentInfo, segmentIndex);
               });
 
               test.waitForExpectedEvents(function()
               {
-                  test.expectEvent(mediaSource, 'sourceended', 'mediaSource ended');
-                  mediaSource.endOfStream();
+                  if (sourceBuffer.updating)
+                  {
+                      // The event playing was fired prior to the appendBuffer completing.
+                      test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
+                      test.waitForExpectedEvents(function()
+                      {
+                          assert_false(sourceBuffer.updating, 'append have compleded');
+                          test.expectEvent(mediaSource, 'sourceended', 'mediaSource ended');
+                          mediaSource.endOfStream();
+                      });
+                  }
+                  else
+                  {
+                      test.expectEvent(mediaSource, 'sourceended', 'mediaSource ended');
+                      mediaSource.endOfStream();
+                  }
               });
 
               test.waitForExpectedEvents(function()
               {
                   assert_greater_than(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA, 'Greater than HAVE_CURRENT_DATA');
                   test.done();
               });
 
@@ -114,27 +128,40 @@
               });
 
               test.waitForExpectedEvents(function()
               {
                   // Note that we can't assume that the element is still seeking
                   // when the seeking event is fired as the operation is asynchronous.
 
                   // Append media data for the second seek position.
-                  test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
                   test.expectEvent(mediaElement, 'seeked', 'mediaElement finished seek');
                   MediaSourceUtil.appendUntilEventFires(test, mediaElement, 'seeked', sourceBuffer, mediaData, segmentInfo, segmentIndex);
               });
 
               test.waitForExpectedEvents(function()
               {
                   assert_false(mediaElement.seeking, 'mediaElement is no longer seeking');
 
-                  test.expectEvent(mediaSource, 'sourceended', 'mediaSource ended');
-                  mediaSource.endOfStream();
+                  if (sourceBuffer.updating)
+                  {
+                      // The event seeked was fired prior to the appendBuffer completing.
+                      test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
+                      test.waitForExpectedEvents(function()
+                      {
+                          assert_false(sourceBuffer.updating, 'append have compleded');
+                          test.expectEvent(mediaSource, 'sourceended', 'mediaSource ended');
+                          mediaSource.endOfStream();
+                      });
+                  }
+                  else
+                  {
+                      test.expectEvent(mediaSource, 'sourceended', 'mediaSource ended');
+                      mediaSource.endOfStream();
+                  }
               });
 
               test.waitForExpectedEvents(function()
               {
                   assert_greater_than(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA, 'Greater than HAVE_CURRENT_DATA');
                   test.done();
               });
           }, 'Test seeking to a new location during a pending seek.');