Chromium Code Reviews| 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> |