Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/controls/closed-captions-dynamic-update.html |
| diff --git a/third_party/WebKit/LayoutTests/media/controls/closed-captions-dynamic-update.html b/third_party/WebKit/LayoutTests/media/controls/closed-captions-dynamic-update.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..02670cdab4642df1041dbf6e64ab235f23372d27 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/media/controls/closed-captions-dynamic-update.html |
| @@ -0,0 +1,77 @@ |
| +<!DOCTYPE html> |
| +<title>Tests that the closed captions button enables track switching.</title> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script src="../media-file.js"></script> |
| +<script src="../media-controls.js"></script> |
| +<video controls> |
| + <track src="../track/captions-webvtt/captions-fast.vtt" kind="captions"> |
| + <track src="../track/captions-webvtt/captions-rtl.vtt" kind="captions"> |
| +</video> |
| +<script> |
| +async_test(t => { |
| + var video = document.querySelector("video"); |
| + |
| + video.oncanplaythrough = t.step_func(_ => { |
| + assert_true(isClosedCaptionsButtonVisible(video)); |
| + |
| + // The captions track should be listed in textTracks, but not yet loaded. |
| + assert_equals(video.textTracks.length, 2); |
| + assert_equals(video.textTracks[0].mode, "disabled"); |
|
foolip
2016/12/02 11:29:17
Also assert_equals(video.textTracks[1].mode, "disa
mlamouri (slow - plz ping)
2016/12/05 15:17:56
Done.
|
| + assert_equals(textTrackContainerElement(video), null); |
| + |
| + var tracks = document.querySelectorAll("track"); |
| + tracks[0].onload = t.step_func(_ => { |
| + assert_equals(textTrackDisplayElement(video).innerText, "Lorem"); |
| + |
| + // Captions should not be visible after Off is clicked. |
| + turnClosedCaptionsOff(video); |
| + assert_equals(textTrackDisplayElement(video), null); |
| + |
| + // Remove DOM node representing the track element. |
|
foolip
2016/12/02 11:29:17
The DOM node is the element, so "Remove the track
mlamouri (slow - plz ping)
2016/12/05 15:17:56
Done.
|
| + tracks[1].remove(); |
| + tracks[0].remove(); |
| + |
| + // The controls are updated asynchronously. |
| + setTimeout(t.step_func(_ => { |
| + assert_false(isClosedCaptionsButtonVisible(video)); |
| + |
| + addUnloadableHTMLTrackElement(); |
| + |
| + setTimeout(t.step_func(_ => { |
|
foolip
2016/12/02 11:29:17
Comment that this is guaranteed to run before the
mlamouri (slow - plz ping)
2016/12/05 15:17:56
I removed the function.
|
| + assert_true(isClosedCaptionsButtonVisible(video)); |
| + clickTextTrackAtIndex(video, 0); |
| + })); |
| + })); |
| + }); |
| + |
| + // Captions track should load and captions should become visible after a track is selected. |
| + clickTextTrackAtIndex(video, 0); |
| + }); |
| + |
| + function addUnloadableHTMLTrackElement() { |
| + // Add non-default text track through HTML with unloadable URI. |
| + var track = document.createElement("track"); |
| + track.setAttribute("kind", "captions"); |
|
foolip
2016/12/02 11:29:17
Don't really need kind or srclang?
mlamouri (slow - plz ping)
2016/12/05 15:17:56
Sure.
|
| + track.setAttribute("srclang", "en"); |
| + track.setAttribute("src", "invalid.vtt"); |
| + |
| + track.onerror = t.step_func(_ => { |
| + // Track failed to load. |
| + assert_false(isClosedCaptionsButtonVisible(video)); |
| + // Add a text track through JS to the video element. |
| + var newTrack = video.addTextTrack("captions", "English", "en"); |
| + setTimeout(t.step_func_done(_ => { |
| + assert_true(isClosedCaptionsButtonVisible(video)); |
| + })); |
| + }); |
| + |
| + video.appendChild(track); |
| + assert_equals(track.readyState, HTMLTrackElement.NONE); |
| + assert_equals(track.track.mode, "disabled"); |
| + assert_equals(video.textTracks.length, 1); |
| + } |
| + |
| + video.src = findMediaFile("video", "../content/counting"); |
| +}); |
| +</script> |