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

Side by Side Diff: LayoutTests/media/track/track-kind-user-preference.html

Issue 1118613002: Hook up Android closed captions 'enabled' setting to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed lgtm comment and rebased Created 5 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
« no previous file with comments | « no previous file | LayoutTests/media/track/track-kind-user-preference-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src=../media-file.js></script>
3 <script src=../video-test.js></script>
4 <script src=../media-controls.js></script>
5 <script>
6
7 var tracks;
8 var expectedTrack;
9 function setPreferences() {
10 if (!window.internals) {
11 consoleWrite("<b>** This test only works in DRT! **<" + "/b>");
12 return;
13 }
14 run("internals.setUserPreferredLanguages(['jp', 'es', 'en', 'fr'])");
15 }
16
17 function checkExpected(mode, kind, language) {
18 testExpected("expectedTrack.mode", mode);
19 testExpected("expectedTrack.kind", kind);
20 testExpected("expectedTrack.language", language);
21 }
22
23 function runTests() {
24 consoleWrite("");
25 tracks = video.textTracks;
26 testExpected("tracks.length", 7);
27 testUserPrefersDefault();
28 testUserPrefersSubtitles();
29 testUserPrefersCaptions();
30 }
31
32 function testUserPrefersDefault() {
33 consoleWrite("");
34 // User preference is initialized to pick tracks marked as default.
35 // When multiple default tracks exist, pick the first default track.
36 expectedTrack = tracks[5];
37 checkExpected("showing", "subtitles", "ar");
38 }
39
40 function testUserPrefersSubtitles() {
41 if (window.internals)
42 internals.settings.setTextTrackKindUserPreference("subtitles");
43 consoleWrite("");
44 // Displays subtitle track over caption track when both exist in the sam e language.
45 expectedTrack = tracks[4];
46 checkExpected("showing", "subtitles", "es");
47 }
48
49 function testUserPrefersCaptions() {
50 if (window.internals)
51 internals.settings.setTextTrackKindUserPreference("captions");
52 consoleWrite("");
53 expectedTrack = tracks[1];
54 checkExpected("showing", "captions", "es");
55
56 consoleWrite("");
57 // Add a subtitle track in user's first preferred language "jp". This tr ack must
58 // be displayed over a caption track with a language less preferred by t he user.
59 var track = document.createElement('track');
60 track.setAttribute('kind', "subtitles");
61 track.setAttribute('src', "captions-webvtt/styling.vtt");
62 track.setAttribute('srclang', "jp");
63 track.setAttribute('onload', 'trackLoaded()');
64 video.appendChild(track);
65 }
66
67 function trackLoaded() {
68 consoleWrite("EVENT(load)");
69
70 // Don't log the event name because the order of the two events in not p redictable.
71 track = event.target;
72 expectedTrack = track.track;
73 testExpected("track.readyState", HTMLTrackElement.LOADED);
74 checkExpected("showing", "subtitles", "jp");
75 consoleWrite("");
76 endTest();
77 }
78
79 window.onload = function() {
80 consoleWrite("Test that user preference for text track kind is honored") ;
81 findMediaElement();
82 setPreferences();
83 video.src = findMediaFile('video', '../content/test');
84 video.currentTime = 0.1;
85 waitForEvent('canplaythrough', runTests);
86 }
87 </script>
88 <video>
89 <track src="captions-webvtt/styling.vtt" kind="captions" srclang="de">
90 <track src="captions-webvtt/styling.vtt" kind="captions" srclang="es">
91 <track src="captions-webvtt/styling.vtt" kind="captions" srclang="en">
92 <track src="captions-webvtt/styling.vtt" kind="subtitles" srclang="fr">
93 <track src="captions-webvtt/styling.vtt" kind="subtitles" srclang="es">
94 <track src="captions-webvtt/styling.vtt" kind="subtitles" srclang="ar" defau lt>
95 <track src="captions-webvtt/styling.vtt" kind="captions" srclang="fr" defaul t>
96 </video>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/media/track/track-kind-user-preference-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698