OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Test that we can add multiple tracks and select between them from the tra
ck selection menu.</title> | 2 <title>Test that we can add multiple tracks and select between them from the tra
ck 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></video> | 7 <video controls></video> |
8 <script> | 8 <script> |
9 async_test(function(t) { | 9 async_test(function(t) { |
10 var video = document.querySelector("video"); | 10 var video = document.querySelector("video"); |
11 var trackLanguages = ["en", "ru", "fr", "jp", "de"]; | 11 var trackLanguages = ["en", "ru", "fr", "jp", "de"]; |
12 var trackCueText = ["English", "Russian", "French", "Japanese", "German"]; | 12 var trackCueText = ["English", "Russian", "French", "Japanese", "German"]; |
13 | 13 |
14 video.oncanplaythrough = t.step_func_done(function() { | 14 video.oncanplaythrough = t.step_func_done(function() { |
15 for (var i = 0; i < trackLanguages.length; i++) { | 15 for (var i = 0; i < trackLanguages.length; i++) { |
16 var track = video.addTextTrack("captions", trackCueText[i], trackLan
guages[i]); | 16 var track = video.addTextTrack("captions", trackCueText[i], trackLan
guages[i]); |
17 track.addCue(new VTTCue(0, 1, trackCueText[i])); | 17 track.addCue(new VTTCue(0, 1, trackCueText[i])); |
18 track.mode = "disabled"; | 18 track.mode = "disabled"; |
19 } | 19 } |
20 assert_true(isClosedCaptionsButtonVisible(video)); | 20 assert_true(isClosedCaptionsButtonVisible(video)); |
21 assert_equals(video.textTracks.length, trackLanguages.length); | 21 assert_equals(video.textTracks.length, trackLanguages.length); |
22 | 22 |
23 for (var i = 0; i < trackLanguages.length; i++) { | 23 for (var i = 0; i < trackLanguages.length; i++) { |
24 clickTextTrackAtIndex(video, i); | 24 clickTextTrackAtIndex(video, i); |
25 assert_equals(video.textTracks[i].mode, "showing"); | 25 assert_equals(video.textTracks[i].mode, "showing"); |
26 assert_equals(textTrackCueDisplayElement(video).innerText, trackCueT
ext[i]); | 26 assert_equals(textTrackDisplayElement(video).innerText, trackCueText
[i]); |
27 for (var j = 0; j < trackLanguages.length; j++) { | 27 for (var j = 0; j < trackLanguages.length; j++) { |
28 if (j != i) | 28 if (j != i) |
29 assert_equals(video.textTracks[j].mode, "disabled"); | 29 assert_equals(video.textTracks[j].mode, "disabled"); |
30 } | 30 } |
31 } | 31 } |
32 }); | 32 }); |
33 | 33 |
34 video.src = findMediaFile("video", "../content/test"); | 34 video.src = findMediaFile("video", "../content/test"); |
35 }); | 35 }); |
36 </script> | 36 </script> |
OLD | NEW |