mediasource-redundant-seek.html (3811B)
1 <!DOCTYPE html> 2 <!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> 3 <html> 4 <head> 5 <title>Test MediaSource behavior when receiving multiple seek requests during a pending seek.</title> 6 <meta name="timeout" content="long"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="mediasource-util.js"></script> 10 </head> 11 <body> 12 <div id="log"></div> 13 <script> 14 15 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) 16 { 17 mediaElement.play(); 18 19 // Append all media data for complete playback. 20 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer end update.'); 21 test.expectEvent(mediaElement, 'loadedmetadata', 'Reached HAVE_METADATA'); 22 test.expectEvent(mediaElement, 'playing', 'Playing media.'); 23 sourceBuffer.appendBuffer(mediaData); 24 25 test.waitForExpectedEvents(function() 26 { 27 var bufferedRanges = mediaElement.buffered; 28 29 assert_greater_than_equal(mediaElement.duration, 4.0, 'Duration is >= 4.0s'); 30 assert_equals(bufferedRanges.length, 1, 'Just one buffered range'); 31 assert_less_than_equal(bufferedRanges.start(0), 1.0, 'Buffered range starts <= 1.0s'); 32 assert_greater_than_equal(bufferedRanges.end(0), 4.0, 'Buffered range ends >= 4.0s'); 33 34 test.expectEvent(mediaElement, 'seeking', 'seeking'); 35 test.expectEvent(mediaElement, 'timeupdate', 'timeupdate'); 36 test.expectEvent(mediaElement, 'seeked', 'seeked'); 37 38 // Request seeks. 39 mediaElement.currentTime = 1.0; 40 41 // This 'ephemeral' seek should be invisible to javascript, except any latency incurred in its processing. 42 mediaElement.currentTime = 3.0; 43 44 mediaElement.currentTime = 1.0; 45 46 assert_true(mediaElement.seeking, 'Element is seeking'); 47 assert_equals(mediaElement.currentTime, 1.0, 'Element time is at last seek time'); 48 }); 49 50 test.waitForExpectedEvents(function() 51 { 52 // No more seeking or seeked events should occur. 53 mediaElement.addEventListener('seeking', test.unreached_func("Unexpected event 'seeking'")); 54 mediaElement.addEventListener('seeked', test.unreached_func("Unexpected event 'seeked'")); 55 56 assert_false(mediaElement.seeking, 'Element is not seeking'); 57 assert_greater_than_equal(mediaElement.currentTime, 1.0, 'Element time is at or after last seek time'); 58 assert_less_than(mediaElement.currentTime, 3.0, 'Element time is before the ephemeral seek time'); 59 60 var timeBeforeWait = mediaElement.currentTime; 61 test.waitForCurrentTimeChange(mediaElement, function() 62 { 63 // Time should have advanced a little, but not yet reached the ephemeral seek time. 64 assert_greater_than(mediaElement.currentTime, timeBeforeWait, 'Element time has increased'); 65 assert_less_than(mediaElement.currentTime, 3.0, 'Element time is still before the ephemeral seek time'); 66 test.done(); 67 }); 68 }); 69 }, 'Test redundant fully prebuffered seek'); 70 71 </script> 72 </body> 73 </html>