OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Test that we can add a track dynamically and it is displayed on the track
selection menu.</title> | 2 <title>Test that we can add a track dynamically and it is displayed on the track
selection menu.</title> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <script src="../media-file.js"></script> | 5 <script src="../media-file.js"></script> |
6 <script src="../media-controls.js"></script> | 6 <script src="../media-controls.js"></script> |
7 <video controls> | 7 <video controls> |
8 <track src="captions-webvtt/captions.vtt" kind="captions" label="English" sr
clang="en" default> | 8 <track src="captions-webvtt/captions.vtt" kind="captions" label="English" sr
clang="en" default> |
9 </video> | 9 </video> |
10 <script> | 10 <script> |
11 async_test(function(t) { | 11 async_test(function(t) { |
12 var trackCueText = "Bonjour"; | 12 var trackCueText = "Bonjour"; |
13 var video = document.querySelector("video"); | 13 var video = document.querySelector("video"); |
14 | 14 |
15 video.oncanplaythrough = t.step_func_done(function() { | 15 video.oncanplaythrough = t.step_func_done(function() { |
16 var track = video.addTextTrack("captions", "French", "fr"); | 16 var track = video.addTextTrack("captions", "French", "fr"); |
17 track.addCue(new VTTCue(0, 1, trackCueText)); | 17 track.addCue(new VTTCue(0, 1, trackCueText)); |
18 assert_true(isClosedCaptionsButtonVisible(video)); | 18 assert_true(isClosedCaptionsButtonVisible(video)); |
19 assert_equals(video.textTracks.length, 2); | 19 assert_equals(video.textTracks.length, 2); |
20 assert_equals(video.textTracks[0].mode, "showing"); | 20 assert_equals(video.textTracks[0].mode, "showing"); |
21 assert_equals(video.textTracks[1].mode, "hidden"); | 21 assert_equals(video.textTracks[1].mode, "hidden"); |
22 | 22 |
23 // Verify the default track is being displayed. | 23 // Verify the default track is being displayed. |
24 assert_equals(textTrackCueDisplayElement(video).innerText, "Lorem"); | 24 assert_equals(textTrackDisplayElement(video).innerText, "Lorem"); |
25 | 25 |
26 // Click the newly added track. | 26 // Click the newly added track. |
27 clickTextTrackAtIndex(video, 1); | 27 clickTextTrackAtIndex(video, 1); |
28 assert_equals(video.textTracks[1].mode, "showing"); | 28 assert_equals(video.textTracks[1].mode, "showing"); |
29 assert_equals(video.textTracks[0].mode, "disabled"); | 29 assert_equals(video.textTracks[0].mode, "disabled"); |
30 assert_equals(textTrackCueDisplayElement(video).innerText, trackCueText)
; | 30 assert_equals(textTrackDisplayElement(video).innerText, trackCueText); |
31 }); | 31 }); |
32 | 32 |
33 video.src = findMediaFile("video", "../content/test"); | 33 video.src = findMediaFile("video", "../content/test"); |
34 }) | 34 }) |
35 </script> | 35 </script> |
OLD | NEW |