| 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 on and off.</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 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 8 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 |
| 9 (Please avoid writing new tests using video-test.js) --> | 9 (Please avoid writing new tests using video-test.js) --> |
| 10 <script src=video-test.js></script> | 10 <script src=video-test.js></script> |
| 11 <script> | 11 <script> |
| 12 var text = ["First", "Second", "Third"]; |
| 12 var displayElement; | 13 var displayElement; |
| 13 var track; | |
| 14 var text = ["First", "Second", "Third"]; | |
| 15 | 14 |
| 16 function addTextTrack() | 15 function addTextTrack() |
| 17 { | 16 { |
| 18 track = video.addTextTrack('captions'); | 17 var track = video.addTextTrack('captions'); |
| 19 | 18 |
| 20 for(var i = 0; i < 3; i++) { | 19 for (var i = 0; i < 3; i++) { |
| 21 var cue = new VTTCue(0, 120, text[i]); | 20 var cue = new VTTCue(0, 120, text[i]); |
| 22 track.addCue(cue); | 21 track.addCue(cue); |
| 23 } | 22 } |
| 24 } | 23 } |
| 25 | 24 |
| 26 function checkCaptionsDisplay() | 25 function checkCaptionsDisplay() |
| 27 { | 26 { |
| 28 for (var i = 0; i < 3; i++) { | 27 for (var i = 0; i < 3; i++) { |
| 29 try { | 28 try { |
| 30 displayElement = textTrackDisplayElement(video, 'display', i
); | 29 displayElement = textTrackDisplayElement(video, "display", i
); |
| 31 testExpected("displayElement.innerText", text[i]); | 30 testExpected("displayElement.innerText", text[i]); |
| 32 } catch(e) { | 31 } catch (e) { |
| 33 consoleWrite(e); | 32 consoleWrite(e); |
| 34 } | 33 } |
| 35 } | 34 } |
| 36 } | 35 } |
| 37 | 36 |
| 38 function startTest() | 37 function startTest() |
| 39 { | 38 { |
| 40 if (!window.eventSender) { | 39 if (!window.eventSender) { |
| 41 consoleWrite("No eventSender found."); | 40 consoleWrite("No eventSender found."); |
| 42 failTest(); | 41 failTest(); |
| 43 } | 42 } |
| 44 | 43 |
| 45 addTextTrack(); | 44 addTextTrack(); |
| 46 | 45 |
| 47 findMediaElement(); | 46 findMediaElement(); |
| 48 testClosedCaptionsButtonVisibility(true); | 47 testClosedCaptionsButtonVisibility(true); |
| 49 | 48 |
| 50 consoleWrite(""); | 49 consoleWrite(""); |
| 51 consoleWrite("** The captions track should be listed in textTracks,
but not yet loaded. **"); | 50 consoleWrite("** The captions track should be listed in textTracks,
but not yet loaded. **"); |
| 52 testExpected("video.textTracks.length", 1); | 51 testExpected("video.textTracks.length", 1); |
| 53 testExpected("video.textTracks[0].mode", "hidden"); | 52 testExpected("video.textTracks[0].mode", "hidden"); |
| 54 checkCaptionsDisplay(); | 53 checkCaptionsDisplay(); |
| 55 | 54 |
| 56 consoleWrite(""); | 55 consoleWrite(""); |
| 57 consoleWrite("** Captions track should become visible after button i
s clicked **"); | 56 consoleWrite("** Captions track should become visible after the trac
k is selected **"); |
| 58 clickCCButton(); | 57 selectTextTrack(video, 0); |
| 59 checkCaptionsDisplay(); | 58 checkCaptionsDisplay(); |
| 60 | 59 |
| 61 consoleWrite(""); | 60 consoleWrite(""); |
| 62 consoleWrite("** Captions should not be visible after button is clic
ked again **"); | 61 consoleWrite("** Captions should not be visible after they're turned
off through the menu **"); |
| 63 clickCCButton(); | 62 turnClosedCaptionsOff(video); |
| 64 checkCaptionsDisplay(); | 63 checkCaptionsDisplay(); |
| 65 | 64 |
| 66 consoleWrite(""); | 65 consoleWrite(""); |
| 67 consoleWrite("** Captions should become visible after button is clic
ked again **"); | 66 consoleWrite("** Captions track should become visible after the trac
k is selected again **"); |
| 68 clickCCButton(); | 67 selectTextTrack(video, 0); |
| 69 checkCaptionsDisplay(); | 68 checkCaptionsDisplay(); |
| 70 | 69 |
| 71 consoleWrite(""); | 70 consoleWrite(""); |
| 72 endTest(); | 71 endTest(); |
| 73 } | 72 } |
| 74 | 73 |
| 75 function loaded() | 74 function loaded() |
| 76 { | 75 { |
| 77 findMediaElement(); | 76 findMediaElement(); |
| 78 waitForEvent('canplaythrough', startTest); | 77 waitForEvent('canplaythrough', startTest); |
| 79 | 78 |
| 80 video.src = findMediaFile('video', 'content/counting'); | 79 video.src = findMediaFile('video', 'content/counting'); |
| 81 } | 80 } |
| 82 </script> | 81 </script> |
| 83 </head> | 82 </head> |
| 84 <body onload="loaded()"> | 83 <body onload="loaded()"> |
| 85 <p>Tests that multiple toggles of the closed captions button still display c
aptions</p> | 84 <p>Tests that tracks can be turned on and off through the track selection me
nu</p> |
| 86 <video controls></video> | 85 <video controls></video> |
| 87 </body> | 86 </body> |
| 88 </html> | 87 </html> |
| OLD | NEW |