| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 1 | <!DOCTYPE html> |
| Matt Wolenetz | 74803c6 | 2016-08-19 01:46:40 | [diff] [blame^] | 2 | <!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 3 | <html> |
| 4 | <head> |
| Aaron Colwell | aa3c90b | 2014-08-04 17:58:37 | [diff] [blame] | 5 | <title>Test MediaSource behavior when receiving multiple seek requests during a pending seek.</title> |
| Bobby Holley | 4861696 | 2015-02-04 17:05:23 | [diff] [blame] | 6 | <meta name="timeout" content="long"> |
| Aaron Colwell | 06f8ec2 | 2014-03-07 18:09:47 | [diff] [blame] | 7 | <script src="/resources/testharness.js"></script> |
| 8 | <script src="/resources/testharnessreport.js"></script> |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 9 | <script src="mediasource-util.js"></script> |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 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 | |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 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. |
| Ms2ger | 979de36 | 2015-06-29 10:21:19 | [diff] [blame] | 53 | mediaElement.addEventListener('seeking', test.unreached_func("Unexpected event 'seeking'")); |
| 54 | mediaElement.addEventListener('seeked', test.unreached_func("Unexpected event 'seeked'")); |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 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> |