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..6a8fdb6d2ea06147cf772ebe3f65ec192d84b81f |
--- /dev/null |
+++ b/LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back.html |
@@ -0,0 +1,63 @@ |
+<!DOCTYPE html> |
+<html> |
+ <head> |
+ <script src="/w3c/resources/testharness.js"></script> |
+ <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> |
+ var segmentInfo = WebMSegmentInfo.testWebM; |
+ |
+ function seekBackAfterPlayingTest(callback, description) |
+ { |
+ mediasource_test(function(test, mediaElement, mediaSource) |
+ { |
+ var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type); |
+ MediaSourceUtil.loadBinaryData(test, segmentInfo.url, function(mediaData) |
+ { |
+ callback(test, mediaElement, mediaSource, sourceBuffer, mediaData); |
+ }); |
+ }, description, {timeout: 10000} ); |
+ } |
+ |
+ seekBackAfterPlayingTest(function(test, mediaElement, mediaSource, sourceBuffer, mediaData) |
+ { |
+ test.failOnEvent(mediaElement, 'error'); |
+ |
+ mediaElement.play(); |
+ |
+ // Append all media segments. |
+ // Expect playing and timeupdate events. |
+ test.expectEvent(mediaElement, "playing", "Playing triggered"); |
wolenetz
2013/07/24 23:16:43
style nit: prefer ' over " in js (multiple places
anandc
2013/07/25 22:48:00
Done.
|
+ test.expectEvent(mediaElement, "timeupdate", "timeupdate fired."); |
+ sourceBuffer.appendBuffer(mediaData); |
+ |
+ test.waitForExpectedEvents(function() |
+ { |
+ if (mediaElement.currentTime > 0.5 ) { |
wolenetz
2013/07/24 23:16:43
style nit: 4-space indent (multiple places in this
anandc
2013/07/25 22:48:00
Done.
|
+ assert_greater_than(mediaElement.currentTime, 0.1); |
wolenetz
2013/07/24 23:16:43
Why are we asserting within a conditional that alr
anandc
2013/07/25 22:48:00
Yes, that was pretty stupid. :-) Gone.
|
+ assert_true(mediaElement.playing, "mediaElement is playing"); |
+ // Seek back to 0.0 |
+ test.expectEvent(mediaElement, "seeking", "mediaElement"); |
+ test.expectEvent(mediaElement, "seeked", "mediaElement finished seek"); |
wolenetz
2013/07/24 23:16:43
You'll need a 'timeupdate' expectation between 'se
anandc
2013/07/25 22:48:00
Based on all your comments, adding an explicit wai
|
+ test.expectEvent(mediaElement, "playing", "Playing triggered"); |
wolenetz
2013/07/24 23:16:43
I don't think 'playing' is expected here, unless t
anandc
2013/07/26 18:49:22
Correct, rearranged the flow now.
|
+ test.expectEvent(mediaElement, "timeupdate", "timeupdate fired."); |
wolenetz
2013/07/24 23:16:43
Note for future: you'll actually get lots and lots
anandc
2013/07/26 18:49:22
ok
|
+ mediaElement.currentTime = 0.0; |
+ } |
+ }); |
+ |
+ test.waitForExpectedEvents(function() |
wolenetz
2013/07/24 23:16:43
It's highly likely that the previous currentTime >
anandc
2013/07/26 18:49:22
Done.
|
+ { |
+ assert_greater_than(mediaElement.readyState, |
+ mediaElement.HAVE_FUTURE_DATA, "Greater than HAVE_FUTURE_DATA"); |
wolenetz
2013/07/24 23:16:43
I'm not sure all implementations can guarantee the
anandc
2013/07/26 18:49:22
Removed.
|
+ test.done(); |
+ }); |
+ |
+ }, "Test playing then seeking back."); |
+ </script> |
+ </body> |
+</html> |