| 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..dc9d80d2a318eea4a14210838f026edf8397cdd6
 | 
| --- /dev/null
 | 
| +++ b/third_party/WebKit/LayoutTests/media/controls/closed-captions-dynamic-update.html
 | 
| @@ -0,0 +1,72 @@
 | 
| +<!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');
 | 
| +    assert_equals(video.textTracks[1].mode, 'disabled');
 | 
| +    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 the track elements.
 | 
| +      tracks[1].remove();
 | 
| +      tracks[0].remove();
 | 
| +
 | 
| +      // The controls are updated asynchronously.
 | 
| +      setTimeout(t.step_func(_ => {
 | 
| +        assert_false(isClosedCaptionsButtonVisible(video));
 | 
| +
 | 
| +        // Add non-default text track through HTML with unloadable URI.
 | 
| +        var track = document.createElement('track');
 | 
| +        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);
 | 
| +
 | 
| +        setTimeout(t.step_func(_ => {
 | 
| +          assert_true(isClosedCaptionsButtonVisible(video));
 | 
| +          clickTextTrackAtIndex(video, 0);
 | 
| +        }));
 | 
| +      }));
 | 
| +    });
 | 
| +
 | 
| +    // Captions track should load and captions should become visible after a track is selected.
 | 
| +    clickTextTrackAtIndex(video, 0);
 | 
| +  });
 | 
| +
 | 
| +  video.src = findMediaFile('video', '../content/counting');
 | 
| +});
 | 
| +</script>
 | 
| 
 |