Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html

Issue 2456993003: Improve caption button behavior for video player. (Closed)
Patch Set: Addresss feedback Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Tests that tracks can be turned on and off through the track selection me nu.</title> 2 <title>Tests that tracks can be turned on and off through the track selection me nu.</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-controls.js"></script>
5 <script src="media-file.js"></script> 6 <script src="media-file.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 text = ["First", "Second", "Third"]; 10 var captions = ["First", "Second", "Third"];
11 var video = document.querySelector("video"); 11 var video = document.querySelector("video");
12 12
13 video.oncanplaythrough = t.step_func_done(function() { 13 video.oncanplaythrough = t.step_func_done(function() {
14 var track = video.addTextTrack("captions"); 14 var track1 = video.addTextTrack("captions");
15 var track2 = video.addTextTrack("captions");
15 16
16 for (var i = 0; i < text.length; i++) { 17 for (var i = 0; i < captions.length; i++) {
17 var cue = new VTTCue(0, 120, text[i]); 18 track1.addCue(new VTTCue(0, 120, captions[i]));
18 track.addCue(cue); 19 track2.addCue(new VTTCue(0, 120, captions[i]));
19 } 20 }
20 assert_true(isClosedCaptionsButtonVisible(video)); 21 assert_true(isClosedCaptionsButtonVisible(video));
21 22
22 // The captions track should be listed in textTracks, but not yet loaded . 23 // The captions track should be listed in textTracks, but not yet loaded .
23 assert_equals(video.textTracks.length, 1); 24 assert_equals(video.textTracks.length, 2);
24 assert_equals(video.textTracks[0].mode, "hidden"); 25 assert_equals(video.textTracks[0].mode, "hidden");
25 checkCaptionsHidden(); 26 checkCaptionsHidden(video);
26 27
27 // Captions track should become visible after the track is selected. 28 // Captions track should become visible after the track is selected.
28 clickTextTrackAtIndex(video, 0); 29 clickTextTrackAtIndex(video, 0);
29 checkCaptionsVisible(); 30 checkCaptionsVisible(video, captions);
30 31
31 // Captions should not be visible after they're turned off through the m enu. 32 // Captions should not be visible after they're turned off through the m enu.
32 turnClosedCaptionsOff(video); 33 turnClosedCaptionsOff(video);
33 checkCaptionsHidden(); 34 checkCaptionsHidden(video);
34 35
35 // Captions track should become visible after the track is selected agai n. 36 // Captions track should become visible after the track is selected agai n.
36 clickTextTrackAtIndex(video, 0); 37 clickTextTrackAtIndex(video, 0);
37 checkCaptionsVisible(); 38 checkCaptionsVisible(video, captions);
38 }); 39 });
39 40
40 function checkCaptionsVisible() {
41 for (var i = 0; i < text.length; i++)
42 assert_equals(textTrackCueElementByIndex(video, i).innerText, text[i ]);
43 }
44
45 function checkCaptionsHidden() {
46 assert_equals(textTrackDisplayElement(video), null);
47 }
48
49 video.src = findMediaFile("video", "content/counting"); 41 video.src = findMediaFile("video", "content/counting");
50 }); 42 });
51 </script> 43 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698