track-remove-active-cue.html (1006B)
1 <!DOCTYPE html> 2 <title>Removing an active cue</title> 3 <script src="/common/media.js"></script> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <video></video> 7 <script> 8 async_test(function(t) { 9 var video = document.querySelector("video"); 10 video.src = getVideoURI("/media/test"); 11 12 // Add a text track to the video element. 13 video.addTextTrack("captions", "regular captions track", "en"); 14 15 // Add a cue to the track with enter event listener. 16 var cue = new VTTCue(0, 4, "Random"); 17 cue.onenter = t.step_func_done(removeActiveCue); 18 19 var track = video.textTracks[0]; 20 track.addCue(cue); 21 22 function removeActiveCue() { 23 assert_equals(track.activeCues.length, 1); 24 25 // Remove the cue while it is active. 26 track.removeCue(track.activeCues[0]); 27 28 // No crash. PASS. 29 } 30 31 // Play the video and remove cue when it becomes active. 32 video.play(); 33 track.mode = "showing"; 34 }); 35 </script>