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

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

Issue 2121613002: Convert video-controls-[captions, overlay, track]* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address philip's comments Created 4 years, 5 months 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 <html> 2 <title>Tests that tracks can be turned on and off through the track selection me nu.</title>
3 <head> 3 <script src="../resources/testharness.js"></script>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <script src="../resources/testharnessreport.js"></script>
5 <title>Test closed caption track selection on and off.</title> 5 <script src="media-file.js"></script>
6 <script src=media-file.js></script> 6 <script src="media-controls.js"></script>
7 <script src=media-controls.js></script> 7 <video controls></video>
8 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 8 <script>
9 (Please avoid writing new tests using video-test.js) --> 9 async_test(function(t) {
10 <script src=video-test.js></script> 10 var text = ["First", "Second", "Third"];
11 <script> 11 var video = document.querySelector("video");
12 var text = ["First", "Second", "Third"];
13 var displayElement;
14 12
15 function addTextTrack() 13 video.oncanplaythrough = t.step_func_done(function() {
16 { 14 var track = video.addTextTrack("captions");
17 var track = video.addTextTrack('captions');
18 15
19 for (var i = 0; i < 3; i++) { 16 for (var i = 0; i < 3; i++) {
foolip 2016/07/06 10:00:47 The hard-coded 3 is a bit unsightly, but oh well.
Srirama 2016/07/06 11:35:49 Replaced with text.length.
20 var cue = new VTTCue(0, 120, text[i]); 17 var cue = new VTTCue(0, 120, text[i]);
21 track.addCue(cue); 18 track.addCue(cue);
22 }
23 } 19 }
20 assert_true(isClosedCaptionsButtonVisible(video));
24 21
25 function checkCaptionsDisplay() 22 // The captions track should be listed in textTracks, but not yet loaded .
26 { 23 assert_equals(video.textTracks.length, 1);
27 for (var i = 0; i < 3; i++) { 24 assert_equals(video.textTracks[0].mode, "hidden");
28 try { 25 checkCaptionsHidden();
29 displayElement = textTrackDisplayElement(video, "display", i );
30 testExpected("displayElement.innerText", text[i]);
31 } catch (e) {
32 consoleWrite(e);
33 }
34 }
35 }
36 26
37 function startTest() 27 // Captions track should become visible after the track is selected.
38 { 28 clickTextTrackAtIndex(video, 0);
39 if (!window.eventSender) { 29 checkCaptionsVisible();
40 consoleWrite("No eventSender found.");
41 failTest();
42 }
43 30
44 addTextTrack(); 31 // Captions should not be visible after they're turned off through the m enu.
32 turnClosedCaptionsOff(video);
33 checkCaptionsHidden();
45 34
46 findMediaElement(); 35 // Captions track should become visible after the track is selected agai n.
47 testClosedCaptionsButtonVisibility(true); 36 clickTextTrackAtIndex(video, 0);
37 checkCaptionsVisible();
38 });
48 39
49 consoleWrite(""); 40 function checkCaptionsVisible() {
50 consoleWrite("** The captions track should be listed in textTracks, but not yet loaded. **"); 41 for (var i = 0; i < 3; i++)
51 testExpected("video.textTracks.length", 1); 42 assert_equals(textTrackCueElementByIndex(video, i).innerText, text[i ]);
52 testExpected("video.textTracks[0].mode", "hidden"); 43 }
53 checkCaptionsDisplay();
54 44
55 consoleWrite(""); 45 function checkCaptionsHidden() {
56 consoleWrite("** Captions track should become visible after the trac k is selected **"); 46 for (var i = 0; i < 3; i++)
57 selectTextTrack(video, 0); 47 assert_equals(textTrackCueElementByIndex(video, i), null);
foolip 2016/07/06 10:00:47 Simplify this to just assert_equals(textTrackCueEl
Srirama 2016/07/06 11:35:49 Done.
58 checkCaptionsDisplay(); 48 }
59 49
60 consoleWrite(""); 50 video.src = findMediaFile("video", "content/counting");
61 consoleWrite("** Captions should not be visible after they're turned off through the menu **"); 51 });
62 turnClosedCaptionsOff(video); 52 </script>
63 checkCaptionsDisplay();
64
65 consoleWrite("");
66 consoleWrite("** Captions track should become visible after the trac k is selected again **");
67 selectTextTrack(video, 0);
68 checkCaptionsDisplay();
69
70 consoleWrite("");
71 endTest();
72 }
73
74 function loaded()
75 {
76 findMediaElement();
77 waitForEvent('canplaythrough', startTest);
78
79 video.src = findMediaFile('video', 'content/counting');
80 }
81 </script>
82 </head>
83 <body onload="loaded()">
84 <p>Tests that tracks can be turned on and off through the track selection me nu</p>
85 <video controls></video>
86 </body>
87 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698