| 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(function(t) { | |
| 13 var video = document.querySelector("video"); | |
| 14 | |
| 15 video.oncanplaythrough = t.step_func(function() { | |
| 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(textTrackContainerElement(video), null); | |
| 22 | |
| 23 var tracks = document.querySelectorAll("track"); | |
| 24 tracks[0].onload = t.step_func(function() { | |
| 25 assert_equals(textTrackDisplayElement(video).innerText, "Lorem"); | |
| 26 | |
| 27 // Captions should not be visible after Off is clicked. | |
| 28 turnClosedCaptionsOff(video); | |
| 29 assert_equals(textTrackDisplayElement(video), null); | |
| 30 | |
| 31 // Remove DOM node representing the track element. | |
| 32 tracks[1].remove(); | |
| 33 tracks[0].remove(); | |
| 34 assert_false(isClosedCaptionsButtonVisible(video)); | |
| 35 | |
| 36 addUnloadableHTMLTrackElement(); | |
| 37 assert_true(isClosedCaptionsButtonVisible(video)); | |
| 38 | |
| 39 clickTextTrackAtIndex(video, 0); | |
| 40 }); | |
| 41 | |
| 42 // Captions track should load and captions should become visible after a
track is selected. | |
| 43 clickTextTrackAtIndex(video, 0); | |
| 44 }); | |
| 45 | |
| 46 function addUnloadableHTMLTrackElement() { | |
| 47 // Add non-default text track through HTML with unloadable URI. | |
| 48 var track = document.createElement("track"); | |
| 49 track.setAttribute("kind", "captions"); | |
| 50 track.setAttribute("srclang", "en"); | |
| 51 track.setAttribute("src", "invalid.vtt"); | |
| 52 | |
| 53 track.onerror = t.step_func_done(function() { | |
| 54 // Track failed to load. | |
| 55 assert_false(isClosedCaptionsButtonVisible(video)); | |
| 56 // Add a text track through JS to the video element. | |
| 57 var newTrack = video.addTextTrack("captions", "English", "en"); | |
| 58 assert_true(isClosedCaptionsButtonVisible(video)); | |
| 59 }); | |
| 60 | |
| 61 video.appendChild(track); | |
| 62 assert_equals(track.readyState, HTMLTrackElement.NONE); | |
| 63 assert_equals(track.track.mode, "disabled"); | |
| 64 assert_equals(video.textTracks.length, 1); | |
| 65 } | |
| 66 | |
| 67 video.src = findMediaFile("video", "content/counting"); | |
| 68 }); | |
| 69 </script> | |
| OLD | NEW |