OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 <title>Test closed caption button toggling.</title> |
| 6 <script src=media-file.js></script> |
| 7 <script src=media-controls.js></script> |
| 8 <script src=video-test.js></script> |
| 9 <script> |
| 10 var displayElement; |
| 11 var track; |
| 12 var text = ["First", "Second", "Third"]; |
| 13 |
| 14 function addTextTrack() |
| 15 { |
| 16 track = video.addTextTrack('captions'); |
| 17 |
| 18 for(var i = 0; i < 3; i++) { |
| 19 var cue = new TextTrackCue(0, 120, text[i]); |
| 20 track.addCue(cue); |
| 21 } |
| 22 } |
| 23 |
| 24 function checkCaptionsDisplay() |
| 25 { |
| 26 for (var i = 0; i < 3; i++) { |
| 27 try { |
| 28 displayElement = textTrackDisplayElement(video, 'display', i
); |
| 29 testExpected("displayElement.innerText", text[i]); |
| 30 } catch(e) { |
| 31 consoleWrite(e); |
| 32 } |
| 33 } |
| 34 } |
| 35 |
| 36 function startTest() |
| 37 { |
| 38 if (!window.eventSender) { |
| 39 consoleWrite("No eventSender found."); |
| 40 failTest(); |
| 41 } |
| 42 |
| 43 addTextTrack(); |
| 44 |
| 45 findMediaElement(); |
| 46 testClosedCaptionsButtonVisibility(true); |
| 47 |
| 48 consoleWrite(""); |
| 49 consoleWrite("** The captions track should be listed in textTracks,
but not yet loaded. **"); |
| 50 testExpected("video.textTracks.length", 1); |
| 51 testExpected("video.textTracks[0].mode", "hidden"); |
| 52 checkCaptionsDisplay(); |
| 53 |
| 54 consoleWrite(""); |
| 55 consoleWrite("** Captions track should become visible after button i
s clicked **"); |
| 56 clickCCButton(); |
| 57 checkCaptionsDisplay(); |
| 58 |
| 59 consoleWrite(""); |
| 60 consoleWrite("** Captions should not be visible after button is clic
ked again **"); |
| 61 clickCCButton(); |
| 62 checkCaptionsDisplay(); |
| 63 |
| 64 consoleWrite(""); |
| 65 consoleWrite("** Captions should become visible after button is clic
ked again **"); |
| 66 clickCCButton(); |
| 67 checkCaptionsDisplay(); |
| 68 |
| 69 consoleWrite(""); |
| 70 endTest(); |
| 71 } |
| 72 |
| 73 function loaded() |
| 74 { |
| 75 findMediaElement(); |
| 76 waitForEvent('canplaythrough', startTest); |
| 77 |
| 78 video.src = findMediaFile('video', 'content/counting'); |
| 79 } |
| 80 </script> |
| 81 </head> |
| 82 <body onload="loaded()"> |
| 83 <p>Tests that multiple toggles of the closed captions button still display c
aptions</p> |
| 84 <video controls></video> |
| 85 </body> |
| 86 </html> |
OLD | NEW |