Index: LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back.html |
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back.html b/LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..da75348cd589f10ccb1f85928155c47f60a43594 |
--- /dev/null |
+++ b/LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back.html |
@@ -0,0 +1,77 @@ |
+<!DOCTYPE html> |
+<html> |
+ <head> |
+ <script src='/w3c/resources/testharness.js'></script> |
wolenetz
2013/07/29 21:23:40
consistency/interoperability nit: Our other tests
anandc
2013/07/29 22:55:51
Thanks. Done.
|
+ <script src='/w3c/resources/testharnessreport.js'></script> |
+ <script src='mediasource-util.js'></script> |
+ <script src='/media/resources/media-source/webm/segment-info.js'></script> |
+ <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
+ </head> |
+ <body> |
+ <div id='log'></div> |
+ |
+ <script> |
+ |
+ function seekBackAfterPlayingTest(testFunction, description, options) |
+ { |
+ mediasource_test(function(test, mediaElement, mediaSource) |
+ { |
+ var segmentInfo = WebMSegmentInfo.testWebM; |
+ assert_equals(segmentInfo.duration, 6.042, 'Expected test media duration'); |
+ test.failOnEvent(mediaElement, 'error'); |
+ |
+ var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type); |
+ MediaSourceUtil.loadBinaryData(test, segmentInfo.url, function(mediaData) |
+ { |
+ testFunction(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData); |
+ }); |
+ }, description, options); |
+ } |
+ |
+ function getSegment(mediaData, info) |
+ { |
+ var start = info.offset; |
+ var end = start + info.size; |
+ return mediaData.subarray(start, end); |
+ } |
+ |
+ seekBackAfterPlayingTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
+ { |
+ |
+ mediaElement.play(); |
+ // Append all the segments |
+ test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); |
+ test.expectEvent(mediaElement, 'playing', 'Playing triggered'); |
+ sourceBuffer.appendBuffer(mediaData); |
+ |
+ function playAndSeek(test, mediaElement) |
+ { |
+ test.waitForExpectedEvents(function() |
+ { |
+ assert_greater_than(mediaElement.currentTime, 0.0, 'Playback has started.'); |
wolenetz
2013/07/29 21:23:40
This assert could be flaky because playback may ha
anandc
2013/07/29 22:55:51
Not sure if PS#4 captures what you are recommendin
wolenetz
2013/07/30 18:44:21
Yes, you've captured my recommendation well :). Re
|
+ test.expectEvent(mediaElement, 'seeking', 'mediaElement'); |
+ mediaElement.currentTime = 0.0; |
+ assert_true(mediaElement.seeking, 'mediaElement is seeking'); |
+ }); |
+ |
+ test.waitForExpectedEvents(function() |
+ { |
+ assert_equals(mediaElement.currentTime, 0.0, 'Current time is 0.0'); |
+ test.expectEvent(mediaElement, 'timeupdate', 'timeupdate fired.'); |
+ test.expectEvent(mediaElement, 'seeked', 'mediaElement finished seek'); |
+ function confirmPlaying(test, mediaElement) |
+ { |
+ assert_greater_than(mediaElement.currentTime, 0.0, 'Playback has started after seek.'); |
+ test.done(); |
+ } |
+ setTimeout(function() {confirmPlaying(test, mediaElement)}, 300); |
+ }); |
+ |
+ } |
+ |
+ setTimeout(function() {playAndSeek(test, mediaElement)}, 300); |
+ |
+ }, 'Test playing then seeking back.'); |
+ </script> |
+ </body> |
+</html> |