summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-remove-active-cue.html
blob: 176e0065c590f14541e515f5f10a550fbb0b088c (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
<!DOCTYPE html>
<title>Removing an active cue</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video></video>
<script>
async_test(function(t) {
    var video = document.querySelector("video");
    video.src = getVideoURI("/media/test");

    // Add a text track to the video element.
    video.addTextTrack("captions", "regular captions track", "en");

    // Add a cue to the track with enter event listener.
    var cue = new VTTCue(0, 4, "Random");
    cue.onenter = t.step_func_done(removeActiveCue);

    var track = video.textTracks[0];
    track.addCue(cue);

    function removeActiveCue() {
        assert_equals(track.activeCues.length, 1);

        // Remove the cue while it is active.
        track.removeCue(track.activeCues[0]);

        // No crash. PASS.
    }

    // Play the video and remove cue when it becomes active.
    video.play();
    track.mode = "showing";
});
</script>