| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Tests that the closed captions button enables track switching.</title> |
| 3 <script src='../../resources/testharness.js'></script> |
| 4 <script src='../../resources/testharnessreport.js'></script> |
| 5 <script src='../media-file.js'></script> |
| 6 <script src='../media-controls.js'></script> |
| 7 <video controls> |
| 8 <track src='../track/captions-webvtt/captions-fast.vtt' kind='captions'> |
| 9 <track src='../track/captions-webvtt/captions-rtl.vtt' kind='captions'> |
| 10 </video> |
| 11 <script> |
| 12 async_test(t => { |
| 13 var video = document.querySelector('video'); |
| 14 |
| 15 video.oncanplaythrough = t.step_func(_ => { |
| 16 assert_true(isClosedCaptionsButtonVisible(video)); |
| 17 |
| 18 // The captions track should be listed in textTracks, but not yet loaded. |
| 19 assert_equals(video.textTracks.length, 2); |
| 20 assert_equals(video.textTracks[0].mode, 'disabled'); |
| 21 assert_equals(video.textTracks[1].mode, 'disabled'); |
| 22 assert_equals(textTrackContainerElement(video), null); |
| 23 |
| 24 var tracks = document.querySelectorAll('track'); |
| 25 tracks[0].onload = t.step_func(_ => { |
| 26 assert_equals(textTrackDisplayElement(video).innerText, 'Lorem'); |
| 27 |
| 28 // Captions should not be visible after Off is clicked. |
| 29 turnClosedCaptionsOff(video); |
| 30 assert_equals(textTrackDisplayElement(video), null); |
| 31 |
| 32 // Remove the track elements. |
| 33 tracks[1].remove(); |
| 34 tracks[0].remove(); |
| 35 |
| 36 // The controls are updated asynchronously. |
| 37 setTimeout(t.step_func(_ => { |
| 38 assert_false(isClosedCaptionsButtonVisible(video)); |
| 39 |
| 40 // Add non-default text track through HTML with unloadable URI. |
| 41 var track = document.createElement('track'); |
| 42 track.setAttribute('src', 'invalid.vtt'); |
| 43 |
| 44 track.onerror = t.step_func(_ => { |
| 45 // Track failed to load. |
| 46 assert_false(isClosedCaptionsButtonVisible(video)); |
| 47 // Add a text track through JS to the video element. |
| 48 var newTrack = video.addTextTrack('captions', 'English', 'en'); |
| 49 setTimeout(t.step_func_done(_ => { |
| 50 assert_true(isClosedCaptionsButtonVisible(video)); |
| 51 })); |
| 52 }); |
| 53 |
| 54 video.appendChild(track); |
| 55 assert_equals(track.readyState, HTMLTrackElement.NONE); |
| 56 assert_equals(track.track.mode, 'disabled'); |
| 57 assert_equals(video.textTracks.length, 1); |
| 58 |
| 59 setTimeout(t.step_func(_ => { |
| 60 assert_true(isClosedCaptionsButtonVisible(video)); |
| 61 clickTextTrackAtIndex(video, 0); |
| 62 })); |
| 63 })); |
| 64 }); |
| 65 |
| 66 // Captions track should load and captions should become visible after a tra
ck is selected. |
| 67 clickTextTrackAtIndex(video, 0); |
| 68 }); |
| 69 |
| 70 video.src = findMediaFile('video', '../content/counting'); |
| 71 }); |
| 72 </script> |
| OLD | NEW |