OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Tests TextTrack's addCue and removeCue.</title> | 2 <title>Tests TextTrack's addCue and removeCue.</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 <script> | 5 <script> |
6 async_test(function(t) { | 6 async_test(function(t) { |
7 var video = document.createElement("video"); | 7 var video = document.createElement("video"); |
8 var trackElement = document.createElement("track"); | 8 var trackElement = document.createElement("track"); |
9 | 9 |
10 trackElement.onload = t.step_func_done(function() { | 10 trackElement.onload = t.step_func_done(function() { |
(...skipping 11 matching lines...) Expand all Loading... |
22 assert_equals(textCue.track, null); | 22 assert_equals(textCue.track, null); |
23 assert_equals(textCue.id, ""); | 23 assert_equals(textCue.id, ""); |
24 assert_equals(textCue.startTime, 33); | 24 assert_equals(textCue.startTime, 33); |
25 assert_equals(textCue.endTime, 3.4); | 25 assert_equals(textCue.endTime, 3.4); |
26 assert_equals(textCue.pauseOnExit, false); | 26 assert_equals(textCue.pauseOnExit, false); |
27 assert_equals(textCue.vertical, ""); | 27 assert_equals(textCue.vertical, ""); |
28 assert_equals(textCue.snapToLines, true); | 28 assert_equals(textCue.snapToLines, true); |
29 assert_equals(textCue.line, "auto"); | 29 assert_equals(textCue.line, "auto"); |
30 assert_equals(textCue.position, "auto"); | 30 assert_equals(textCue.position, "auto"); |
31 assert_equals(textCue.size, 100); | 31 assert_equals(textCue.size, 100); |
32 assert_equals(textCue.align, "middle"); | 32 assert_equals(textCue.align, "center"); |
33 | 33 |
34 // Remove the unadded track, make sure it throws correctly. | 34 // Remove the unadded track, make sure it throws correctly. |
35 assert_throws("NotFoundError", function() { trackElement.track.removeCue
(textCue); }); | 35 assert_throws("NotFoundError", function() { trackElement.track.removeCue
(textCue); }); |
36 | 36 |
37 // Add the new cue to a track, make sure it is inserted correctly. | 37 // Add the new cue to a track, make sure it is inserted correctly. |
38 trackElement.track.addCue(textCue); | 38 trackElement.track.addCue(textCue); |
39 assert_equals(textCue.track, trackElement.track); | 39 assert_equals(textCue.track, trackElement.track); |
40 assert_equals(cues[1].startTime, 31); | 40 assert_equals(cues[1].startTime, 31); |
41 assert_equals(cues[2].startTime, 33); | 41 assert_equals(cues[2].startTime, 33); |
42 assert_equals(cues[3].startTime, 61); | 42 assert_equals(cues[3].startTime, 61); |
43 | 43 |
44 // create a new cue and add it to a track created with | 44 // create a new cue and add it to a track created with |
45 // video.addTextTrack, make sure it is inserted correctly. | 45 // video.addTextTrack, make sure it is inserted correctly. |
46 var newTrack = video.addTextTrack("subtitles", "French subtitles", "fr")
; | 46 var newTrack = video.addTextTrack("subtitles", "French subtitles", "fr")
; |
47 newTrack.mode = "showing"; | 47 newTrack.mode = "showing"; |
48 var newCue = new VTTCue(0, 1, "Test!"); | 48 var newCue = new VTTCue(0, 1, "Test!"); |
49 newTrack.addCue(newCue); | 49 newTrack.addCue(newCue); |
50 assert_equals(newCue, newTrack.cues[0]) | 50 assert_equals(newCue, newTrack.cues[0]) |
51 assert_equals(newCue.track, newTrack); | 51 assert_equals(newCue.track, newTrack); |
52 assert_equals(newCue.id, ""); | 52 assert_equals(newCue.id, ""); |
53 assert_equals(newCue.startTime, 0); | 53 assert_equals(newCue.startTime, 0); |
54 assert_equals(newCue.endTime, 1); | 54 assert_equals(newCue.endTime, 1); |
55 assert_equals(newCue.pauseOnExit, false); | 55 assert_equals(newCue.pauseOnExit, false); |
56 assert_equals(newCue.vertical, ""); | 56 assert_equals(newCue.vertical, ""); |
57 assert_equals(newCue.snapToLines, true); | 57 assert_equals(newCue.snapToLines, true); |
58 assert_equals(newCue.line, "auto"); | 58 assert_equals(newCue.line, "auto"); |
59 assert_equals(newCue.position, "auto"); | 59 assert_equals(newCue.position, "auto"); |
60 assert_equals(newCue.size, 100); | 60 assert_equals(newCue.size, 100); |
61 assert_equals(newCue.align, "middle"); | 61 assert_equals(newCue.align, "center"); |
62 | 62 |
63 trackElement.track.removeCue(textCue); | 63 trackElement.track.removeCue(textCue); |
64 assert_equals(textCue.track, null); | 64 assert_equals(textCue.track, null); |
65 assert_equals(cues[1].startTime, 31); | 65 assert_equals(cues[1].startTime, 31); |
66 assert_equals(cues[2].startTime, 61); | 66 assert_equals(cues[2].startTime, 61); |
67 | 67 |
68 // Remove a cue added from the WebVTT file. | 68 // Remove a cue added from the WebVTT file. |
69 textCue = cues[2]; | 69 textCue = cues[2]; |
70 trackElement.track.removeCue(textCue); | 70 trackElement.track.removeCue(textCue); |
71 assert_equals(textCue.track, null); | 71 assert_equals(textCue.track, null); |
(...skipping 10 matching lines...) Expand all Loading... |
82 assert_equals(cues[1].startTime, 0); | 82 assert_equals(cues[1].startTime, 0); |
83 assert_equals(cues[1].endTime, 30.5); | 83 assert_equals(cues[1].endTime, 30.5); |
84 assert_equals(cues[2].startTime, 31); | 84 assert_equals(cues[2].startTime, 31); |
85 }); | 85 }); |
86 | 86 |
87 trackElement.src = "captions-webvtt/tc013-settings.vtt"; | 87 trackElement.src = "captions-webvtt/tc013-settings.vtt"; |
88 trackElement.kind = "captions"; | 88 trackElement.kind = "captions"; |
89 trackElement.default = true; | 89 trackElement.default = true; |
90 video.appendChild(trackElement); | 90 video.appendChild(trackElement); |
91 }); | 91 }); |
92 </script> | 92 </script> |
OLD | NEW |