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 <title>Test closed caption button toggling.</title> | 5 <title>Test closed caption track selection functionality.</title> |
6 <script src=media-file.js></script> | 6 <script src="media-file.js"></script> |
7 <script src=media-controls.js></script> | 7 <script src="media-controls.js"></script> |
8 <script src=video-test.js></script> | 8 <script src="video-test.js"></script> |
9 <script> | 9 <script> |
10 var track; | 10 var track; |
11 | 11 |
12 function addTextTrackThroughJS() | 12 function addTextTrackThroughJS() |
13 { | 13 { |
14 consoleWrite(""); | 14 consoleWrite(""); |
15 consoleWrite("** Add a text track through JS to the video element **
"); | 15 consoleWrite("** Add a text track through JS to the video element **
"); |
16 var t = video.addTextTrack('captions', 'English', 'en'); | 16 var t = video.addTextTrack('captions', 'English', 'en'); |
17 t.addCue(new VTTCue(0.0, 10.0, 'Some random caption text')); | 17 t.addCue(new VTTCue(0.0, 10.0, 'Some random caption text')); |
18 } | 18 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 findMediaElement(); | 61 findMediaElement(); |
62 testClosedCaptionsButtonVisibility(true); | 62 testClosedCaptionsButtonVisibility(true); |
63 | 63 |
64 consoleWrite(""); | 64 consoleWrite(""); |
65 consoleWrite("** The captions track should be listed in textTracks,
but not yet loaded. **"); | 65 consoleWrite("** The captions track should be listed in textTracks,
but not yet loaded. **"); |
66 testExpected("video.textTracks.length", 1); | 66 testExpected("video.textTracks.length", 1); |
67 testExpected("video.textTracks[0].mode", "disabled"); | 67 testExpected("video.textTracks[0].mode", "disabled"); |
68 checkCaptionsDisplay(); | 68 checkCaptionsDisplay(); |
69 | 69 |
70 consoleWrite(""); | 70 consoleWrite(""); |
71 consoleWrite("** Captions track should load and captions should beco
me visible after button is clicked **"); | 71 consoleWrite("** Captions track should load and captions should beco
me visible after a track is selected **"); |
72 | 72 |
73 // Note: the test flow continues with "testCCButtonToggling" when th
e | 73 // Note: the test flow continues with "testCCTrackSelectionFunctiona
lity" when the |
74 // "load" event of the single TextTrack fires up. While the test str
ucture | 74 // "load" event of the single TextTrack fires up. While the test str
ucture |
75 // might seem weird, this avoids timeouts. | 75 // might seem weird, this avoids timeouts. |
76 clickCCButton(); | 76 selectTextTrack(video, 0); |
77 } | 77 } |
78 | 78 |
79 function testCCButtonToggling() | 79 function testCCTrackSelectionFunctionality() |
80 { | 80 { |
81 checkCaptionsDisplay(); | 81 checkCaptionsDisplay(); |
82 | 82 |
83 consoleWrite(""); | 83 consoleWrite(""); |
84 consoleWrite("** Captions should not be visible after button is clic
ked again **"); | 84 consoleWrite("** Captions should not be visible after Off is clicked
**"); |
85 clickCCButton(); | 85 turnClosedCaptionsOff(video); |
86 checkCaptionsDisplay(); | 86 checkCaptionsDisplay(); |
87 | 87 |
88 removeHTMLTrackElement(); | 88 removeHTMLTrackElement(); |
89 testClosedCaptionsButtonVisibility(false); | 89 testClosedCaptionsButtonVisibility(false); |
90 | 90 |
91 addUnloadableHTMLTrackElement(); | 91 addUnloadableHTMLTrackElement(); |
92 testClosedCaptionsButtonVisibility(true); | 92 testClosedCaptionsButtonVisibility(true); |
93 | 93 |
94 consoleWrite(""); | 94 consoleWrite(""); |
95 clickCCButton(); | 95 selectTextTrack(video, 0); |
96 } | 96 } |
97 | 97 |
98 function trackError() | 98 function trackError() |
99 { | 99 { |
100 consoleWrite("** Track failed to load **"); | 100 consoleWrite("** Track failed to load **"); |
101 testClosedCaptionsButtonVisibility(false); | 101 testClosedCaptionsButtonVisibility(false); |
102 | 102 |
103 addTextTrackThroughJS(); | 103 addTextTrackThroughJS(); |
104 testClosedCaptionsButtonVisibility(true); | 104 testClosedCaptionsButtonVisibility(true); |
105 | 105 |
106 endTest(); | 106 endTest(); |
107 } | 107 } |
108 | 108 |
109 function loaded() | 109 function loaded() |
110 { | 110 { |
111 findMediaElement(); | 111 findMediaElement(); |
112 waitForEvent('canplaythrough', startTest); | 112 waitForEvent('canplaythrough', startTest); |
113 | 113 |
114 video.src = findMediaFile('video', 'content/counting'); | 114 video.src = findMediaFile('video', 'content/counting'); |
115 } | 115 } |
116 </script> | 116 </script> |
117 </head> | 117 </head> |
118 <body onload="loaded()"> | 118 <body onload="loaded()"> |
119 <p>Tests that the closed captions button, when toggled, updates the text tra
ck display area.</p> | 119 <p>Tests that the closed captions button enables track switching</p> |
120 <video controls> | 120 <video controls> |
121 <track src="track/captions-webvtt/captions-fast.vtt" kind="captions" onl
oad="testCCButtonToggling()"> | 121 <track src="track/captions-webvtt/captions-fast.vtt" kind="captions" onl
oad="testCCTrackSelectionFunctionality()"> |
122 </video> | 122 </video> |
123 </body> | 123 </body> |
124 </html> | 124 </html> |
OLD | NEW |