track-cues-enter-seeking.html (1484B)
1 <!DOCTYPE html> 2 <title>TextTrack's cue onenter handler called when seeked onto</title> 3 <meta name="timeout" content="long"> 4 <script src="/common/media.js"></script> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <video> 8 <track src="resources/cues-chrono-order.vtt" kind="captions" default> 9 <script> 10 // Check that the onenter event is called for the right cue when seeking on the video element. 11 // Based on the spec step 4 [1], after a seek happens, the missed cues should be empty, 12 // so any cues before the target time should not receive enter event. 13 // [1] https://html.spec.whatwg.org/multipage/media.html#time-marches-on 14 async_test(function(t) { 15 var video = document.querySelector("video"); 16 var testTrack = document.querySelector("track"); 17 18 video.src = getVideoURI("/media/test"); 19 20 video.oncanplaythrough = t.step_func(attemptTests); 21 22 function attemptTests() { 23 assert_equals(testTrack.track.cues.length, 3); 24 const targetTime = 4.0000000004; 25 26 for (let cue of testTrack.track.cues) { 27 if (cue.endTime > targetTime) { 28 cue.onenter = t.step_func(_=>t.done()); 29 } else { 30 cue.onenter = t.unreached_func("onenter called for wrong cue"); 31 } 32 } 33 34 video.currentTime = targetTime; 35 } 36 }); 37 </script> 38 </video>