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

Side by Side Diff: third_party/WebKit/LayoutTests/media/controls/closed-captions-dynamic-update.html

Issue 2539023002: Media Controls: Use events to update controls for closed captions. (Closed)
Patch Set: zqzhang review comments Created 4 years 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
(Empty)
1 <!DOCTYPE html>
2 <title>Tests that the closed captions button enables track switching.</title>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../media-file.js"></script>
6 <script src="../media-controls.js"></script>
7 <video controls>
8 <track src="../track/captions-webvtt/captions-fast.vtt" kind="captions">
9 <track src="../track/captions-webvtt/captions-rtl.vtt" kind="captions">
10 </video>
11 <script>
12 async_test(t => {
13 var video = document.querySelector("video");
14
15 video.oncanplaythrough = t.step_func(_ => {
16 assert_true(isClosedCaptionsButtonVisible(video));
17
18 // The captions track should be listed in textTracks, but not yet loaded.
19 assert_equals(video.textTracks.length, 2);
20 assert_equals(video.textTracks[0].mode, "disabled");
foolip 2016/12/02 11:29:17 Also assert_equals(video.textTracks[1].mode, "disa
mlamouri (slow - plz ping) 2016/12/05 15:17:56 Done.
21 assert_equals(textTrackContainerElement(video), null);
22
23 var tracks = document.querySelectorAll("track");
24 tracks[0].onload = t.step_func(_ => {
25 assert_equals(textTrackDisplayElement(video).innerText, "Lorem");
26
27 // Captions should not be visible after Off is clicked.
28 turnClosedCaptionsOff(video);
29 assert_equals(textTrackDisplayElement(video), null);
30
31 // Remove DOM node representing the track element.
foolip 2016/12/02 11:29:17 The DOM node is the element, so "Remove the track
mlamouri (slow - plz ping) 2016/12/05 15:17:56 Done.
32 tracks[1].remove();
33 tracks[0].remove();
34
35 // The controls are updated asynchronously.
36 setTimeout(t.step_func(_ => {
37 assert_false(isClosedCaptionsButtonVisible(video));
38
39 addUnloadableHTMLTrackElement();
40
41 setTimeout(t.step_func(_ => {
foolip 2016/12/02 11:29:17 Comment that this is guaranteed to run before the
mlamouri (slow - plz ping) 2016/12/05 15:17:56 I removed the function.
42 assert_true(isClosedCaptionsButtonVisible(video));
43 clickTextTrackAtIndex(video, 0);
44 }));
45 }));
46 });
47
48 // Captions track should load and captions should become visible after a tra ck is selected.
49 clickTextTrackAtIndex(video, 0);
50 });
51
52 function addUnloadableHTMLTrackElement() {
53 // Add non-default text track through HTML with unloadable URI.
54 var track = document.createElement("track");
55 track.setAttribute("kind", "captions");
foolip 2016/12/02 11:29:17 Don't really need kind or srclang?
mlamouri (slow - plz ping) 2016/12/05 15:17:56 Sure.
56 track.setAttribute("srclang", "en");
57 track.setAttribute("src", "invalid.vtt");
58
59 track.onerror = t.step_func(_ => {
60 // Track failed to load.
61 assert_false(isClosedCaptionsButtonVisible(video));
62 // Add a text track through JS to the video element.
63 var newTrack = video.addTextTrack("captions", "English", "en");
64 setTimeout(t.step_func_done(_ => {
65 assert_true(isClosedCaptionsButtonVisible(video));
66 }));
67 });
68
69 video.appendChild(track);
70 assert_equals(track.readyState, HTMLTrackElement.NONE);
71 assert_equals(track.track.mode, "disabled");
72 assert_equals(video.textTracks.length, 1);
73 }
74
75 video.src = findMediaFile("video", "../content/counting");
76 });
77 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698