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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/media/track/track-kind-user-preference.html
diff --git a/LayoutTests/media/track/track-kind-user-preference.html b/LayoutTests/media/track/track-kind-user-preference.html
new file mode 100644
index 0000000000000000000000000000000000000000..f134ae0ab116d7a755541575354d62052927b855
--- /dev/null
+++ b/LayoutTests/media/track/track-kind-user-preference.html
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<script src=../media-file.js></script>
+<script src=../video-test.js></script>
+<script src=../media-controls.js></script>
+<script>
+
+ var tracks;
+ var expectedTrack;
+ function setPreferences() {
+ if (!window.internals) {
+ consoleWrite("<b>** This test only works in DRT! **<" + "/b>");
+ return;
+ }
+ run("internals.setUserPreferredLanguages(['jp', 'es', 'en', 'fr'])");
+ }
+
+ function checkExpected(mode, kind, language) {
+ testExpected("expectedTrack.mode", mode);
+ testExpected("expectedTrack.kind", kind);
+ testExpected("expectedTrack.language", language);
+ }
+
+ function runTests() {
+ consoleWrite("");
+ tracks = video.textTracks;
+ testExpected("tracks.length", 7);
+ testUserPrefersDefault();
+ testUserPrefersSubtitles();
+ testUserPrefersCaptions();
+ }
+
+ function testUserPrefersDefault() {
+ consoleWrite("");
+ // User preference is initialized to pick tracks marked as default.
+ // When multiple default tracks exist, pick the first default track in user's
+ // preferred language if any. If not, pick the first default track.
+ expectedTrack = tracks[6];
+ checkExpected("showing", "captions", "fr");
+ }
+
+ function testUserPrefersSubtitles() {
+ if (window.internals)
+ internals.settings.setTextTrackKindUserPreference("subtitles");
+ consoleWrite("");
+ expectedTrack = tracks[4];
+ checkExpected("showing", "subtitles", "en");
+ }
+
+ function testUserPrefersCaptions() {
+ if (window.internals)
+ internals.settings.setTextTrackKindUserPreference("captions");
+ consoleWrite("");
+ expectedTrack = tracks[1];
+ checkExpected("showing", "captions", "es");
+
+ consoleWrite("");
+ // Add a subtitle track in user's first preferred language "jp". This track must
+ // be displayed over a caption track with a language less preferred by the user.
+ var track = document.createElement('track');
+ track.setAttribute('kind', "subtitles");
+ track.setAttribute('src', "captions-webvtt/styling.vtt");
+ track.setAttribute('srclang', "jp");
+ 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.
+ video.appendChild(track);
+ }
+
+ function trackLoaded() {
+ consoleWrite("EVENT(load)");
+
+ // Don't log the event name because the order of the two events in not predictable.
+ track = event.target;
+ expectedTrack = track.track;
+ testExpected("track.readyState", HTMLTrackElement.LOADED);
+ checkExpected("showing", "subtitles", "jp");
+ consoleWrite("");
+ endTest();
+ }
+
+ window.onload = function() {
+ consoleWrite("Test that user preference for text track kind is honored");
+ findMediaElement();
+ setPreferences();
+ video.src = findMediaFile('video', '../content/test');
+ video.currentTime = 0.1;
+ waitForEvent('canplaythrough', runTests);
+ }
+</script>
+<video>
+ <track src="captions-webvtt/styling.vtt" kind="captions" srclang="de">
+ <track src="captions-webvtt/styling.vtt" kind="captions" srclang="es">
+ <track src="captions-webvtt/styling.vtt" kind="captions" srclang="en">
+ <track src="captions-webvtt/styling.vtt" kind="subtitles" srclang="fr">
+ <track src="captions-webvtt/styling.vtt" kind="subtitles" srclang="en">
+ <track src="captions-webvtt/styling.vtt" kind="subtitles" srclang="ar" default>
+ <track src="captions-webvtt/styling.vtt" kind="captions" srclang="fr" default>
+</video>
« 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