Bug 1293613: don't assume playback won't be finished by the time the seeked event is fired. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 10 Aug 2016 22:11:43 +1000
changeset 399502 12b020aa6691b3ece98c4a39e4cbfe8632f03a23
parent 399501 103bf788adb0bba0c1d665f851c580fb0688b9e6
child 527948 cf1e3e742d5536b18efb8286aeec3e71ae9853ab
push id25858
push userbmo:jyavenard@mozilla.com
push dateThu, 11 Aug 2016 08:40:14 +0000
reviewersgerald
bugs1293613
milestone51.0a1
Bug 1293613: don't assume playback won't be finished by the time the seeked event is fired. r?gerald The data added in the sourcebuffer is very short (less than one second); it is possible that playback has completed prior the event being fired. MozReview-Commit-ID: INHAFmEhSut
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
@@ -68,17 +68,26 @@
                   {
                       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');
+              	  // Note: we just completed the seek. However, we only have less than a second worth of data to play. It is possible that
+              	  // playback has reached the end since the seek completed.
+              	  if (!mediaElement.paused)
+              	  {
+                      assert_greater_than_equal(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA, 'Greater or equal than HAVE_CURRENT_DATA');
+                  }
+                  else
+                  {
+                      assert_true(mediaElement.ended);
+                  }
                   test.done();
               });
 
           }, 'Test seeking to a new location before transitioning beyond HAVE_METADATA.');
 
           mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
           {
               mediaElement.play();
@@ -156,15 +165,24 @@
                   {
                       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');
+              	  // Note: we just completed the seek. However, we only have less than a second worth of data to play. It is possible that
+              	  // playback has reached the end since the seek completed.
+              	  if (!mediaElement.paused)
+              	  {
+                      assert_greater_than_equal(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA, 'Greater or equal than HAVE_CURRENT_DATA');
+                  }
+                  else
+                  {
+                      assert_true(mediaElement.ended);
+                  }
                   test.done();
               });
           }, 'Test seeking to a new location during a pending seek.');
         </script>
     </body>
 </html>