blob: bb2fef5bf577bacd47b1b428240497040c4c69bd [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src=../video-test.js></script>
<script>
async function testTracks()
{
findMediaElement();
if (window.internals) {
run("internals.settings.setShouldDisplayTrackKind('Captions', false)");
run("internals.settings.setShouldDisplayTrackKind('Subtitles', true)");
run("internals.setUserPreferredLanguages(['en'])");
run("internals.setPrimaryAudioTrackLanguageOverride('fr')");
run("internals.setCaptionDisplayMode('ForcedOnly')");
}
video.src = '../content/CC+Subtitles.mov';
await waitFor(video, 'canplaythrough');
consoleWrite("<br><i>** Forced tracks should be in .textTracks, but not in the menu<" + "/i>");
testExpected("video.textTracks.length", 11);
consoleWrite("<br><i>** Only the 'fr' forced track should be showing<" + "/i>");
testExpected("video.textTracks[0].language", "en");
testExpected("video.textTracks[0].kind", "subtitles");
testExpected("video.textTracks[0].mode", "disabled");
consoleWrite("");
testExpected("video.textTracks[1].language", "en");
testExpected("video.textTracks[1].kind", "forced");
testExpected("video.textTracks[1].mode", "disabled");
consoleWrite("");
testExpected("video.textTracks[2].language", "fr");
testExpected("video.textTracks[2].kind", "subtitles");
testExpected("video.textTracks[2].mode", "disabled");
consoleWrite("");
testExpected("video.textTracks[3].language", "fr");
testExpected("video.textTracks[3].kind", "forced");
testExpected("video.textTracks[3].mode", "showing");
consoleWrite("");
testExpected("video.textTracks[4].language", "es");
testExpected("video.textTracks[4].kind", "subtitles");
testExpected("video.textTracks[4].mode", "disabled");
consoleWrite("");
testExpected("video.textTracks[5].language", "es");
testExpected("video.textTracks[5].kind", "forced");
testExpected("video.textTracks[5].mode", "disabled");
consoleWrite("");
testExpected("video.textTracks[6].language", "de");
testExpected("video.textTracks[6].kind", "subtitles");
testExpected("video.textTracks[6].mode", "disabled");
consoleWrite("");
testExpected("video.textTracks[7].language", "de");
testExpected("video.textTracks[7].kind", "forced");
testExpected("video.textTracks[7].mode", "disabled");
consoleWrite("");
testExpected("video.textTracks[8].language", "en");
testExpected("video.textTracks[8].kind", "captions");
testExpected("video.textTracks[8].mode", "disabled");
consoleWrite("");
testExpected("video.textTracks[9].language", "es");
testExpected("video.textTracks[9].kind", "chapters");
testExpected("video.textTracks[9].mode", "hidden");
consoleWrite("");
testExpected("video.textTracks[10].language", "en");
testExpected("video.textTracks[10].kind", "chapters");
testExpected("video.textTracks[10].mode", "hidden");
consoleWrite("");
consoleWrite("<i>** A cue should become active when current time is within its active range<" + "/i>");
run("video.currentTime = 9.5");
let result = await Promise.race([
Promise.all([
waitFor(video, 'seeked', true),
waitFor(video.textTracks[3], 'cuechange', true)
]),
new Promise((resolve, reject) => { setTimeout(resolve, 5000, 'timeout'); })
]);
if (result === 'timeout') {
consoleWrite('');
failTest('Test timed out.');
}
consoleWrite('EVENT(seeked)');
consoleWrite('EVENT(cuechange)');
testExpected('video.textTracks[3].activeCues.length === 1', true);
consoleWrite('');
endTest();
}
</script>
</head>
<body onload='testTracks()'>
<p>Tests that forced subtitles are enable automatically.</p>
<video width=640 height=360 controls>
</video>
</body>
</html>