blob: 83b9d773770f81c78823303d5934e186e7e542dc [file] [log] [blame]
<!doctype html>
<title>TextTrack.cues</title>
<script src=../../../../../resources/testharness.js></script>
<script src=../../../../../resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
window.track = document.createElement('track');
track['default'] = true;
video.appendChild(track); // queues a task to "honor user preferences...", media element event task source
window.t2 = track.track;
window.t1_cues = t1.cues
window.t2_cues = t2.cues
});
test(function(){
assert_equals(t1.cues, t1_cues, 't1.cues should return same object');
assert_not_equals(t1.cues, null, 't1.cues should not be null');
assert_equals(t1.cues.length, 0, 't1.cues should have length 0');
}, document.title+', empty list');
test(function(){
var c = new VTTCue(0, 1, "text");
c.id = "id";
t1.addCue(c);
assert_equals(t1.cues, t1_cues, "t1.cues should return same object");
assert_equals(t1.cues.length, 1, "t1.cues.length");
var c2 = new VTTCue(1, 2, "text2");
c2.id = "id2";
t1.addCue(c2);
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after adding a second cue");
assert_equals(t1.cues.length, 2, "t1.cues.length after adding a second cue");
assert_equals(t1.cues[0].id, "id");
assert_equals(t1.cues[1].id, "id2");
}, document.title+', after addCue()');
test(function(){
t1.mode = 'showing';
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'showing'");
t1.mode = 'hidden';
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'hidden'");
t1.mode = 'disabled';
assert_equals(t1.cues, null, "t1.cues should be null when mode is 'disabled'");
assert_equals(t1_cues.length, 2, "t1_cues should still be intact after setting mode to 'disabled'");
assert_equals(t1_cues[0].id, "id", "t1_cues first cue should still be intact after setting mode to 'disabled'");
assert_equals(t1_cues[1].id, "id2", "t1_cues second cue should still be intact after setting mode to 'disabled'");
t1.mode = 'hidden';
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'disabled' and then 'hidden'");
t1.mode = 'disabled';
assert_equals(t1.cues, null, "t1.cues should be null when mode is set to 'disabled' again");
assert_equals(t1_cues.length, 2, "t1_cues should still be intact after setting mode to 'disabled' again");
assert_equals(t1_cues[0].id, "id", "t1_cues first cue should still be intact after setting mode to 'disabled' again");
assert_equals(t1_cues[1].id, "id2", "t1_cues second cue should still be intact after setting mode to 'disabled' again");
t1.mode = 'showing';
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'disabled' and then 'showing'");
}, document.title+', different modes');
test(function(){
t1.mode = 'showing';
t1.cues[1].startTime = 0; // this should change the text track cue order
assert_equals(t1.cues[0].id, 'id2');
assert_equals(t1.cues[1].id, 'id');
t1.cues[0].startTime = 0.5; // this should change it back
assert_equals(t1.cues[0].id, 'id');
assert_equals(t1.cues[1].id, 'id2');
}, document.title+', changing order');
</script>