Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="/w3c/resources/testharness.js"></script> | |
| 5 <script src="/w3c/resources/testharnessreport.js"></script> | |
| 6 <script src="mediasource-util.js"></script> | |
| 7 <script src="/media/resources/media-source/webm/segment-info.js"></scrip t> | |
| 8 <link rel="stylesheet" href="/w3c/resources/testharness.css"> | |
| 9 </head> | |
| 10 <body> | |
| 11 <div id='log'></div> | |
| 12 | |
| 13 <script> | |
| 14 | |
| 15 function seekBackAfterPlayingTest(testFunction, description, options ) | |
| 16 { | |
| 17 mediasource_test(function(test, mediaElement, mediaSource) | |
| 18 { | |
| 19 var segmentInfo = WebMSegmentInfo.testWebM; | |
| 20 assert_equals(segmentInfo.duration, 6.042, 'Expected test medi a duration'); | |
| 21 test.failOnEvent(mediaElement, 'error'); | |
| 22 | |
| 23 var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.typ e); | |
| 24 MediaSourceUtil.loadBinaryData(test, segmentInfo.url, function (mediaData) | |
| 25 { | |
| 26 testFunction(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData); | |
| 27 }); | |
| 28 }, description, options); | |
| 29 } | |
| 30 | |
| 31 function getSegment(mediaData, info) | |
| 32 { | |
| 33 var start = info.offset; | |
| 34 var end = start + info.size; | |
| 35 return mediaData.subarray(start, end); | |
| 36 } | |
| 37 | |
| 38 seekBackAfterPlayingTest(function(test, mediaElement, mediaSource, s egmentInfo, sourceBuffer, mediaData) | |
| 39 { | |
| 40 | |
| 41 mediaElement.play(); | |
| 42 // Append all the segments | |
| 43 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); | |
| 44 test.expectEvent(mediaElement, 'playing', 'Playing triggered'); | |
| 45 sourceBuffer.appendBuffer(mediaData); | |
| 46 | |
| 47 var playTimeoutID; | |
| 48 | |
| 49 var playTimeoutHandler = test.step_func(function playAndSeek(tes t, mediaElement) | |
|
wolenetz
2013/07/31 01:20:45
nits: remove ' playAndSeek' because the function c
anandc
2013/07/31 19:01:17
Done.
| |
| 50 { | |
| 51 assert_greater_than(mediaElement.currentTime, 0.0, 'Playback has started.'); | |
| 52 test.expectEvent(mediaElement, 'seeking', 'mediaElement'); | |
| 53 mediaElement.currentTime = 0.0; | |
| 54 | |
| 55 test.waitForExpectedEvents(function() | |
| 56 { | |
| 57 assert_true(mediaElement.seeking, 'mediaElement is seeki ng'); | |
| 58 assert_equals(mediaElement.currentTime, 0.0, 'Current ti me is 0.0'); | |
| 59 test.expectEvent(mediaElement, 'timeupdate', 'timeupdate fired.'); | |
| 60 test.expectEvent(mediaElement, 'seeked', 'mediaElement f inished seek'); | |
| 61 var playAfterSeekHandler = test.step_func(function confi rmPlaying(test, mediaElement) | |
|
wolenetz
2013/07/31 01:20:45
nits: anonymize the function and remove redundant
anandc
2013/07/31 19:01:17
Done.
| |
| 62 { | |
| 63 assert_greater_than(mediaElement.currentTime, 0.0, 'Pl ayback has started after seek.'); | |
| 64 clearTimeout(playTimeoutID); | |
|
wolenetz
2013/07/31 01:20:45
See my comments @ line 67 and 74, below. This clea
anandc
2013/07/31 19:01:17
Done.
| |
| 65 test.done(); | |
| 66 }); | |
| 67 setTimeout(function() {playAfterSeekHandler(test, mediaE lement)}, 300); | |
|
wolenetz
2013/07/31 01:20:45
Ditto with my playTimeoutID comment @ line 74, bel
anandc
2013/07/31 19:01:17
Done.
| |
| 68 }); | |
| 69 | |
| 70 }); | |
| 71 | |
| 72 test.waitForExpectedEvents(function() | |
| 73 { | |
| 74 playTimeoutID = setTimeout(function() {playTimeoutHandler(te st, mediaElement)}, 300); | |
|
wolenetz
2013/07/31 01:20:45
If going this route with intent to cancel your not
anandc
2013/07/31 19:01:17
PTAL at updated mediasource-utils.
| |
| 75 }); | |
| 76 | |
| 77 }, 'Test playing then seeking back.'); | |
| 78 </script> | |
| 79 </body> | |
| 80 </html> | |
| OLD | NEW |