Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that disables it given conditions:
- os == "win" : https://bugzilla.mozilla.org/show_bug.cgi?id=1550381
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/embedded-content/media-elements/track/track-element/track-cues-cuechange.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>TextTrack's cues are indexed and updated in order during video playback</title>
<meta name="timeout" content="long">
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/cues-chrono-order.vtt" kind="captions" default>
<script>
// Use the cuechange event on TextTrack.
async_test(function(t) {
var video = document.querySelector("video");
var testTrack = document.querySelector("track");
video.src = getVideoURI("/media/test");
video.oncanplaythrough = t.step_func(attemptTests);
function attemptTests() {
assert_equals(testTrack.track.cues.length, 3);
testTrack.oncuechange = t.step_func(cueChangedFromTrackElement);
video.play();
}
var currentCueIndex;
var cueChangeCount = 0;
function cueChangedFromTrackElement() {
currentCueIndex = Math.floor(cueChangeCount / 2);
currentCue = event.target.track.cues[currentCueIndex];
if (cueChangeCount % 2 == 0) {
// Cue entered.
assert_equals(currentCue, testTrack.track.activeCues[0]);
assert_equals(currentCue.id, (currentCueIndex + 1).toString());
}
++cueChangeCount;
if (cueChangeCount == testTrack.track.cues.length * 2)
t.done();
}
});
</script>
</video>