OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <title>TextTrack.addCue()</title> | 2 <title>TextTrack.addCue()</title> |
3 <script src=../../../../../resources/testharness.js></script> | 3 <script src=../../../../../resources/testharness.js></script> |
4 <script src=../../../../../resources/testharnessreport.js></script> | 4 <script src=../../../../../resources/testharnessreport.js></script> |
5 <div id=log></div> | 5 <div id=log></div> |
6 <script> | 6 <script> |
7 setup(function(){ | 7 setup(function(){ |
8 window.video = document.createElement('video'); | 8 window.video = document.createElement('video'); |
9 document.body.appendChild(video); | 9 document.body.appendChild(video); |
10 }, {timeout:5000}); | 10 }, {timeout:5000}); |
(...skipping 27 matching lines...) Expand all Loading... |
38 test(function() { | 38 test(function() { |
39 var t1 = video.addTextTrack('subtitles'); | 39 var t1 = video.addTextTrack('subtitles'); |
40 var c1 = new VTTCue(0, 1, 'text1'); | 40 var c1 = new VTTCue(0, 1, 'text1'); |
41 t1.addCue(c1); | 41 t1.addCue(c1); |
42 assert_equals(t1.cues.length, 1, 't1.cues.length after first addition'); | 42 assert_equals(t1.cues.length, 1, 't1.cues.length after first addition'); |
43 t1.removeCue(c1); | 43 t1.removeCue(c1); |
44 assert_equals(t1.cues.length, 0, 't1.cues.length after removal'); | 44 assert_equals(t1.cues.length, 0, 't1.cues.length after removal'); |
45 t1.addCue(c1); | 45 t1.addCue(c1); |
46 assert_equals(t1.cues.length, 1, 't1.cues.length after second addition'); | 46 assert_equals(t1.cues.length, 1, 't1.cues.length after second addition'); |
47 }, document.title+', adding an associated but removed cue to the same track'); | 47 }, document.title+', adding an associated but removed cue to the same track'); |
| 48 test(function() { |
| 49 var t1 = video.addTextTrack('subtitles'); |
| 50 assert_equals(t1.cues.length, 0); |
| 51 assert_throws(new TypeError, function() { t1.addCue(null); }, 'null'); |
| 52 assert_throws(new TypeError, function() { t1.addCue([]); }, 'non-TextTrackCu
e'); |
| 53 assert_equals(t1.cues.length, 0); |
| 54 }, document.title+', invalid values'); |
48 | 55 |
49 var t = async_test(document.title+', adding a cue associated with a track elemen
t to other track'); | 56 var t = async_test(document.title+', adding a cue associated with a track elemen
t to other track'); |
50 t.step(function(){ | 57 t.step(function(){ |
51 var t1 = video.addTextTrack('subtitles'); | 58 var t1 = video.addTextTrack('subtitles'); |
52 var track = document.createElement('track'); | 59 var track = document.createElement('track'); |
53 track.onload = t.step_func(function(){ | 60 track.onload = t.step_func(function(){ |
54 var cue = track.track.cues[0]; | 61 var cue = track.track.cues[0]; |
55 track.track.removeCue(cue); | 62 track.track.removeCue(cue); |
56 t1.addCue(cue); | 63 t1.addCue(cue); |
57 assert_equals(cue.track, t1); | 64 assert_equals(cue.track, t1); |
58 t.done(); | 65 t.done(); |
59 }); | 66 }); |
60 track.src= 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 0
0:00:01.000\ntest\n'); | 67 track.src= 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 0
0:00:01.000\ntest\n'); |
61 track.kind = 'subtitles'; | 68 track.kind = 'subtitles'; |
62 track.track.mode = 'hidden'; | 69 track.track.mode = 'hidden'; |
63 video.appendChild(track); | 70 video.appendChild(track); |
64 }); | 71 }); |
65 </script> | 72 </script> |
OLD | NEW |