--- 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.');