OLD | NEW |
| (Empty) |
1 Tests TextTrack's addCue and removeCue | |
2 | |
3 | |
4 *** Test cues loaded from the file. | |
5 EXPECTED (cues.length == '4') OK | |
6 EXPECTED (cues.getCueById('1').startTime == '0') OK | |
7 EXPECTED (cues[1].startTime == '31') OK | |
8 EXPECTED (cues[2].startTime == '61') OK | |
9 EXPECTED (cues.getCueById('4').startTime == '121') OK | |
10 EXPECTED (cues.getCueById('junk') == 'undefined') OK | |
11 | |
12 *** Create a new cue, check values | |
13 RUN(textCue = new VTTCue(33, 3.4, 'Sausage?')) | |
14 EXPECTED (textCue.track == 'null') OK | |
15 EXPECTED (textCue.id == '') OK | |
16 EXPECTED (textCue.startTime == '33') OK | |
17 EXPECTED (textCue.endTime == '3.4') OK | |
18 EXPECTED (textCue.pauseOnExit == 'false') OK | |
19 EXPECTED (textCue.vertical == '') OK | |
20 EXPECTED (textCue.snapToLines == 'true') OK | |
21 EXPECTED (textCue.line == 'auto') OK | |
22 EXPECTED (textCue.position == 'auto') OK | |
23 EXPECTED (textCue.size == '100') OK | |
24 EXPECTED (textCue.align == 'middle') OK | |
25 | |
26 *** Remove the unadded track, make sure it throws correctly. | |
27 TEST(testTrack.track.removeCue(textCue)) THROWS("NotFoundError: Failed to execut
e 'removeCue' on 'TextTrack': The specified cue is not listed in the TextTrack's
list of cues.") OK | |
28 | |
29 *** Add the new cue to a track, make sure it is inserted correctly. | |
30 RUN(testTrack.track.addCue(textCue)) | |
31 EXPECTED (textCue.track == '[object TextTrack]') OK | |
32 EXPECTED (cues[1].startTime == '31') OK | |
33 EXPECTED (cues[2].startTime == '33') OK | |
34 EXPECTED (cues[3].startTime == '61') OK | |
35 | |
36 *** create a new cue and add it to a track created with video.addTextTrack, make
sure it is inserted correctly. | |
37 RUN(newTrack = video.addTextTrack("subtitles", "French subtitles", "fr")) | |
38 RUN(newTrack.mode = "showing") | |
39 RUN(newTrack.addCue(new VTTCue(0.0, 1.0, "Test!"))) | |
40 RUN(newCue = newTrack.cues[0]) | |
41 EXPECTED (newCue.track == '[object TextTrack]') OK | |
42 EXPECTED (newCue.id == '') OK | |
43 EXPECTED (newCue.startTime == '0') OK | |
44 EXPECTED (newCue.endTime == '1') OK | |
45 EXPECTED (newCue.pauseOnExit == 'false') OK | |
46 EXPECTED (newCue.vertical == '') OK | |
47 EXPECTED (newCue.snapToLines == 'true') OK | |
48 EXPECTED (newCue.line == 'auto') OK | |
49 EXPECTED (newCue.position == 'auto') OK | |
50 EXPECTED (newCue.size == '100') OK | |
51 EXPECTED (newCue.align == 'middle') OK | |
52 | |
53 *** Remove a cue created with addCue(). | |
54 RUN(testTrack.track.removeCue(textCue)) | |
55 EXPECTED (textCue.track == 'null') OK | |
56 EXPECTED (cues[1].startTime == '31') OK | |
57 EXPECTED (cues[2].startTime == '61') OK | |
58 | |
59 *** Remove a cue added from the WebVTT file. | |
60 RUN(textCue = cues[2]) | |
61 RUN(testTrack.track.removeCue(textCue)) | |
62 EXPECTED (textCue.track == 'null') OK | |
63 EXPECTED (cues[1].startTime == '31') OK | |
64 EXPECTED (cues[2].startTime == '121') OK | |
65 | |
66 *** Try to remove the cue again. | |
67 TEST(testTrack.track.removeCue(textCue)) THROWS(DOMException.NOT_FOUND_ERR: Fail
ed to execute 'removeCue' on 'TextTrack': The specified cue is not listed in the
TextTrack's list of cues.) OK | |
68 | |
69 *** Add a cue before all the existing cues. | |
70 RUN(testTrack.track.addCue(new VTTCue(0, 31, 'I am first'))) | |
71 EXPECTED (cues[0].startTime == '0') OK | |
72 EXPECTED (cues[0].endTime == '31') OK | |
73 EXPECTED (cues[1].startTime == '0') OK | |
74 EXPECTED (cues[1].endTime == '30.5') OK | |
75 EXPECTED (cues[2].startTime == '31') OK | |
76 END OF TEST | |
77 | |
OLD | NEW |