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

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-controls-track-selection-menu.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 nit 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 <title>Test that we can display a track list menu and select tracks from the lis t.</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="track/track-helpers.js"></script>
2 <script src="media-file.js"></script> 6 <script src="media-file.js"></script>
3 <!-- TODO(srivats): Convert test to testharness.js. crbug.com/588956
4 (Please avoid writing new tests using video-test.js) -->
5 <script src="video-test.js"></script>
6 <script src="media-controls.js"></script> 7 <script src="media-controls.js"></script>
7 <script>
8
9 function startTest()
10 {
11 findMediaElement();
12 testClosedCaptionsButtonVisibility(true);
13 consoleWrite("");
14 testExpected("video.textTracks.length", 2);
15 testExpected("video.textTracks[0].mode", "hidden");
16 testExpected("video.textTracks[1].mode", "hidden");
17
18 consoleWrite("");
19 consoleWrite("Select track 0 and verify it is displayed");
20 selectTextTrack(video, 0);
21 testExpected("video.textTracks[0].mode", "showing");
22 testExpected("video.textTracks[1].mode", "hidden");
23 testExpected("textTrackDisplayElement(video, 'display').innerText", "Lor em");
24
25 consoleWrite("");
26 consoleWrite("Select track 1 and verify it is displayed");
27 selectTextTrack(video, 1);
28 testExpected("video.textTracks[0].mode", "disabled");
29 testExpected("video.textTracks[1].mode", "showing");
30 testExpected("textTrackDisplayElement(video, 'display').innerText", "fir st caption");
31
32 consoleWrite("");
33 endTest();
34 }
35
36 window.onload = function()
37 {
38 consoleWrite("Test that we can display a track list menu and select trac ks from the list");
39 findMediaElement();
40 video.src = findMediaFile("video", "content/test");
41 enableAllTextTracks();
42 waitForEvent("canplaythrough", startTest);
43 }
44
45 </script>
46 <video controls> 8 <video controls>
47 <track src="track/captions-webvtt/captions.vtt" kind="captions" label="Track 1"> 9 <track src="track/captions-webvtt/captions.vtt" kind="captions" label="Track 1">
48 <track src="track/captions-webvtt/long-word.vtt" kind="captions" label="Trac k2"> 10 <track src="track/captions-webvtt/long-word.vtt" kind="captions" label="Trac k2">
49 </video> 11 </video>
12 <script>
13 async_test(function(t) {
14 var video = document.querySelector("video");
15
16 var trackElements = document.querySelectorAll("track");
17 for (var i = 0; i < video.textTracks.length; i++)
18 trackElements[i].onload = t.step_func(trackLoaded);
19
20 enableAllTextTracks(video.textTracks);
21
22 var numberOfTracksLoaded = 0;
23 function trackLoaded() {
24 numberOfTracksLoaded++;
25 if (numberOfTracksLoaded != 2)
26 return;
27
28 video.oncanplaythrough = t.step_func_done(function() {
29 assert_true(isClosedCaptionsButtonVisible(video));
30 assert_equals(video.textTracks.length, 2);
31 assert_equals(video.textTracks[0].mode, "hidden");
32 assert_equals(video.textTracks[1].mode, "hidden");
33
34 // Select track 0 and verify it is displayed.
35 clickTextTrackAtIndex(video, 0);
36 assert_equals(video.textTracks[0].mode, "showing");
37 assert_equals(video.textTracks[1].mode, "hidden");
38 assert_equals(textTrackCueElementByIndex(video, 0).innerText, "Lorem ");
39
40 // Select track 1 and verify it is displayed.
41 clickTextTrackAtIndex(video, 1);
42 assert_equals(video.textTracks[0].mode, "disabled");
43 assert_equals(video.textTracks[1].mode, "showing");
44 assert_equals(textTrackCueElementByIndex(video, 0).innerText, "first caption");
45 });
46
47 video.src = findMediaFile("video", "content/test");
48 }
49 });
50 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698