summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/media-source/mediasource-replay.html
blob: 05a8c0a918ab94bc1d4303b85ef3500e3cea9ddb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<!-- Copyright © 2019 Igalia S.L -->
<html>
<head>
    <title>MediaSource replay test case.</title>
    <meta name="timeout" content="long">
    <meta charset="utf-8">
    <link rel="author" title="Alicia Boya García" href="mailto:aboya@igalia.com">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script src="mediasource-util.js"></script>
</head>
<body>
<div id="log"></div>
<script>
    mediasource_testafterdataloaded(function (test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) {
        mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));

        test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');

        sourceBuffer.appendBuffer(mediaData);

        test.waitForExpectedEvents(function () {
            mediaSource.endOfStream();

            // Start playing near the end.
            mediaElement.currentTime = 6.2;
            mediaElement.play();
            test.expectEvent(mediaElement, 'ended', 'mediaElement');
        });

        test.waitForExpectedEvents(function () {
            mediaElement.play();
            assert_equals(mediaElement.currentTime, 0, "currentTime");
            // If currentTime is able to advance, the player did not get stuck and it's a pass.
            test.waitForCurrentTimeChange(mediaElement, test.step_func_done());
        });
    }, "Test replaying video after 'ended'");
</script>
</body>
</html>