4 <script src=
"/w3c/resources/testharness.js"></script>
5 <script src=
"/w3c/resources/testharnessreport.js"></script>
6 <script src=
"mediasource-util.js"></script>
7 <link rel=
"stylesheet" href=
"/w3c/resources/testharness.css">
13 mediasource_testafterdataloaded(function(test
, mediaElement
, mediaSource
, segmentInfo
, sourceBuffer
, mediaData
)
17 // Append all media data for complete playback.
18 test
.expectEvent(sourceBuffer
, 'updateend', 'sourceBuffer end update.');
19 test
.expectEvent(mediaElement
, 'loadedmetadata', 'Reached HAVE_METADATA');
20 test
.expectEvent(mediaElement
, 'playing', 'Playing media.');
21 sourceBuffer
.appendBuffer(mediaData
);
23 test
.waitForExpectedEvents(function()
25 var bufferedRanges
= mediaElement
.buffered
;
27 // TODO: Add coverage by varying which of the two seek times have buffered data, including neither, and by
28 // varying seek redundancy, like 1+1, 1+3+3+1, 3+1+1, 3+3+1, or large number of 1+3+1+3+...
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');
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');
50 test
.waitForExpectedEvents(function()
52 // No more seeking or seeked events should occur.
53 test
.failOnEvent(mediaElement
, 'seeking');
54 test
.failOnEvent(mediaElement
, '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');
69 }, 'Test redundant fully prebuffered seek');