Bug 1539614 [wpt PR 16077] - HTML: move textarea tests together, a=testonly
[gecko.git] / testing / web-platform / tests / media-source / mediasource-redundant-seek.html
blob05eae9714f9c2aeb4e949b7fec3fee77608f7bb9
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>
15 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
17 mediaElement.play();
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);
25 test.waitForExpectedEvents(function()
27 var bufferedRanges = mediaElement.buffered;
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');
34 test.expectEvent(mediaElement, 'seeking', 'seeking');
35 test.expectEvent(mediaElement, 'timeupdate', 'timeupdate');
36 test.expectEvent(mediaElement, 'seeked', 'seeked');
38 // Request seeks.
39 mediaElement.currentTime = 1.0;
41 // This 'ephemeral' seek should be invisible to javascript, except any latency incurred in its processing.
42 mediaElement.currentTime = 3.0;
44 mediaElement.currentTime = 1.0;
46 assert_true(mediaElement.seeking, 'Element is seeking');
47 assert_equals(mediaElement.currentTime, 1.0, 'Element time is at last seek time');
48 });
50 test.waitForExpectedEvents(function()
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'"));
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');
60 var timeBeforeWait = mediaElement.currentTime;
61 test.waitForCurrentTimeChange(mediaElement, function()
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');
71 </script>
72 </body>
73 </html>