| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 | 5 |
| 6 <script src=../media-file.js></script> | 6 <script src=../media-file.js></script> |
| 7 <script src=../video-test.js></script> | 7 <script src=../video-test.js></script> |
| 8 <script> | 8 <script> |
| 9 | 9 |
| 10 var cues; | 10 var cues; |
| 11 | 11 |
| 12 function trackLoaded() | 12 function trackLoaded() |
| 13 { | 13 { |
| 14 var testTrack = document.getElementById('testTrack'); | 14 var testTrack = document.getElementById('testTrack'); |
| 15 cues = testTrack.track.cues; | 15 cues = testTrack.track.cues; |
| 16 | 16 |
| 17 consoleWrite("<br>*** Test cues loaded from the file."); | 17 consoleWrite("<br>*** Test cues loaded from the file."); |
| 18 testExpected("cues.length", 4); | 18 testExpected("cues.length", 4); |
| 19 testExpected("cues.getCueById('1').startTime", 0); | 19 testExpected("cues.getCueById('1').startTime", 0); |
| 20 testExpected("cues[1].startTime", 31); | 20 testExpected("cues[1].startTime", 31); |
| 21 testExpected("cues[2].startTime", 61); | 21 testExpected("cues[2].startTime", 61); |
| 22 testExpected("cues.getCueById('4').startTime", 121); | 22 testExpected("cues.getCueById('4').startTime", 121); |
| 23 testExpected("cues.getCueById('junk')", undefined); | 23 testExpected("cues.getCueById('junk')", undefined); |
| 24 | 24 |
| 25 consoleWrite("<br>*** Create a new cue, check values"); | 25 consoleWrite("<br>*** Create a new cue, check values"); |
| 26 run("textCue = new TextTrackCue(33, 3.4, 'Sausage?')"); | 26 run("textCue = new VTTCue(33, 3.4, 'Sausage?')"); |
| 27 testExpected("textCue.track", null); | 27 testExpected("textCue.track", null); |
| 28 testExpected("textCue.id", ''); | 28 testExpected("textCue.id", ''); |
| 29 testExpected("textCue.startTime", 33); | 29 testExpected("textCue.startTime", 33); |
| 30 testExpected("textCue.endTime", 3.4); | 30 testExpected("textCue.endTime", 3.4); |
| 31 testExpected("textCue.pauseOnExit", false); | 31 testExpected("textCue.pauseOnExit", false); |
| 32 testExpected("textCue.vertical", ""); | 32 testExpected("textCue.vertical", ""); |
| 33 testExpected("textCue.snapToLines", true); | 33 testExpected("textCue.snapToLines", true); |
| 34 testExpected("textCue.line", -1); | 34 testExpected("textCue.line", -1); |
| 35 testExpected("textCue.position", 50); | 35 testExpected("textCue.position", 50); |
| 36 testExpected("textCue.size", 100); | 36 testExpected("textCue.size", 100); |
| 37 testExpected("textCue.align", "middle"); | 37 testExpected("textCue.align", "middle"); |
| 38 | 38 |
| 39 consoleWrite("<br>*** Add the new cue to a track, make sure it i
s inserted correctly."); | 39 consoleWrite("<br>*** Add the new cue to a track, make sure it i
s inserted correctly."); |
| 40 run("testTrack.track.addCue(textCue)"); | 40 run("testTrack.track.addCue(textCue)"); |
| 41 testExpected("textCue.track", testTrack.track); | 41 testExpected("textCue.track", testTrack.track); |
| 42 testExpected("cues[1].startTime", 31); | 42 testExpected("cues[1].startTime", 31); |
| 43 testExpected("cues[2].startTime", 33); | 43 testExpected("cues[2].startTime", 33); |
| 44 testExpected("cues[3].startTime", 61); | 44 testExpected("cues[3].startTime", 61); |
| 45 | 45 |
| 46 consoleWrite("<br>*** create a new cue and add it to a track cre
ated with video.addTextTrack, make sure it is inserted correctly."); | 46 consoleWrite("<br>*** create a new cue and add it to a track cre
ated with video.addTextTrack, make sure it is inserted correctly."); |
| 47 findMediaElement(); | 47 findMediaElement(); |
| 48 run('newTrack = video.addTextTrack("subtitles", "French subtitle
s", "fr")'); | 48 run('newTrack = video.addTextTrack("subtitles", "French subtitle
s", "fr")'); |
| 49 newTrack.mode = 2; | 49 newTrack.mode = 2; |
| 50 run('newTrack.addCue(new TextTrackCue(0.0, 1.0, "Test!"))'); | 50 run('newTrack.addCue(new VTTCue(0.0, 1.0, "Test!"))'); |
| 51 run('newCue = newTrack.cues[0]'); | 51 run('newCue = newTrack.cues[0]'); |
| 52 testExpected("newCue.track", newTrack); | 52 testExpected("newCue.track", newTrack); |
| 53 testExpected("newCue.id", ""); | 53 testExpected("newCue.id", ""); |
| 54 testExpected("newCue.startTime", 0.0); | 54 testExpected("newCue.startTime", 0.0); |
| 55 testExpected("newCue.endTime", 1.0); | 55 testExpected("newCue.endTime", 1.0); |
| 56 testExpected("newCue.pauseOnExit", false); | 56 testExpected("newCue.pauseOnExit", false); |
| 57 testExpected("newCue.vertical", ""); | 57 testExpected("newCue.vertical", ""); |
| 58 testExpected("newCue.snapToLines", true); | 58 testExpected("newCue.snapToLines", true); |
| 59 testExpected("newCue.line", -1); | 59 testExpected("newCue.line", -1); |
| 60 testExpected("newCue.position", 50); | 60 testExpected("newCue.position", 50); |
| 61 testExpected("newCue.size", 100); | 61 testExpected("newCue.size", 100); |
| 62 testExpected("newCue.align", "middle"); | 62 testExpected("newCue.align", "middle"); |
| 63 | 63 |
| 64 consoleWrite("<br>*** Create an old-style cue with an id."); | 64 consoleWrite("<br>*** Create an old-style cue with an id."); |
| 65 run("oldStyleCue = new TextTrackCue('sausage-cue', 33, 3.4, 'Sau
sage?')"); | 65 run("oldStyleCue = new VTTCue('sausage-cue', 33, 3.4, 'Sausage?'
)"); |
| 66 testExpected("oldStyleCue.id", ""); | 66 testExpected("oldStyleCue.id", ""); |
| 67 testExpected("oldStyleCue.startTime.toString()", "NaN"); | 67 testExpected("oldStyleCue.startTime.toString()", "NaN"); |
| 68 testExpected("oldStyleCue.endTime", 33); | 68 testExpected("oldStyleCue.endTime", 33); |
| 69 consoleWrite("*** Make sure the old-style cue is not inserted be
cause its start time is not a number."); | 69 consoleWrite("*** Make sure the old-style cue is not inserted be
cause its start time is not a number."); |
| 70 testExpected("testTrack.track.cues.length", 5); | 70 testExpected("testTrack.track.cues.length", 5); |
| 71 run("testTrack.track.addCue(oldStyleCue)"); | 71 run("testTrack.track.addCue(oldStyleCue)"); |
| 72 testExpected("testTrack.track.cues.length", 5); | 72 testExpected("testTrack.track.cues.length", 5); |
| 73 | 73 |
| 74 consoleWrite("<br>*** Remove a cue created with addCue()."); | 74 consoleWrite("<br>*** Remove a cue created with addCue()."); |
| 75 run("testTrack.track.removeCue(textCue)"); | 75 run("testTrack.track.removeCue(textCue)"); |
| 76 testExpected("textCue.track", null); | 76 testExpected("textCue.track", null); |
| 77 testExpected("cues[1].startTime", 31); | 77 testExpected("cues[1].startTime", 31); |
| 78 testExpected("cues[2].startTime", 61); | 78 testExpected("cues[2].startTime", 61); |
| 79 | 79 |
| 80 consoleWrite("<br>*** Remove a cue added from the WebVTT file.")
; | 80 consoleWrite("<br>*** Remove a cue added from the WebVTT file.")
; |
| 81 run("textCue = cues[2]"); | 81 run("textCue = cues[2]"); |
| 82 run("testTrack.track.removeCue(textCue)"); | 82 run("testTrack.track.removeCue(textCue)"); |
| 83 testExpected("textCue.track", null); | 83 testExpected("textCue.track", null); |
| 84 testExpected("cues[1].startTime", 31); | 84 testExpected("cues[1].startTime", 31); |
| 85 testExpected("cues[2].startTime", 121); | 85 testExpected("cues[2].startTime", 121); |
| 86 | 86 |
| 87 consoleWrite("<br>*** Try to remove the cue again."); | 87 consoleWrite("<br>*** Try to remove the cue again."); |
| 88 testDOMException("testTrack.track.removeCue(textCue)", "DOMExcep
tion.NOT_FOUND_ERR"); | 88 testDOMException("testTrack.track.removeCue(textCue)", "DOMExcep
tion.NOT_FOUND_ERR"); |
| 89 | 89 |
| 90 consoleWrite("<br>*** Add a cue before all the existing cues."); | 90 consoleWrite("<br>*** Add a cue before all the existing cues."); |
| 91 run("testTrack.track.addCue(new TextTrackCue(0, 31, 'I am first'
))"); | 91 run("testTrack.track.addCue(new VTTCue(0, 31, 'I am first'))"); |
| 92 testExpected("cues[0].startTime", 0); | 92 testExpected("cues[0].startTime", 0); |
| 93 testExpected("cues[0].endTime", 31); | 93 testExpected("cues[0].endTime", 31); |
| 94 testExpected("cues[1].startTime", 0); | 94 testExpected("cues[1].startTime", 0); |
| 95 testExpected("cues[1].endTime", 30.5); | 95 testExpected("cues[1].endTime", 30.5); |
| 96 testExpected("cues[2].startTime", 31); | 96 testExpected("cues[2].startTime", 31); |
| 97 endTest(); | 97 endTest(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 </script> | 100 </script> |
| 101 </head> | 101 </head> |
| 102 <body> | 102 <body> |
| 103 <p>Tests TextTrackCue's addCue and removeCue</p> | 103 <p>Tests TextTrack's addCue and removeCue</p> |
| 104 <video> | 104 <video> |
| 105 <track id="testTrack" src="captions-webvtt/tc013-settings.vtt" kind=
"captions" onload="trackLoaded()" default> | 105 <track id="testTrack" src="captions-webvtt/tc013-settings.vtt" kind=
"captions" onload="trackLoaded()" default> |
| 106 </video> | 106 </video> |
| 107 </body> | 107 </body> |
| 108 </html> | 108 </html> |
| OLD | NEW |