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

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 comments from fs Created 5 years, 6 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
(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 in u ser's
36 // preferred language if any. If not, pick the first default track.
37 expectedTrack = tracks[6];
38 checkExpected("showing", "captions", "fr");
39 }
40
41 function testUserPrefersSubtitles() {
42 if (window.internals)
43 internals.settings.setTextTrackKindUserPreference("subtitles");
44 consoleWrite("");
45 expectedTrack = tracks[4];
46 checkExpected("showing", "subtitles", "en");
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()');
philipj_slow 2015/06/24 09:54:19 Hmm, why is this track being loaded when it hasn't
srivats 2015/07/02 01:41:19 It's a subtitle track in a language that has the h
philipj_slow 2015/07/09 15:20:49 Acknowledged.
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="en">
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') | Source/core/dom/Document.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698