blob: 69a09cf65eb597f8533962839df62dfbdd8c7487 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src=../media-file.js></script>
<script src=../video-test.js></script>
<script src=../media-controls.js></script>
<script>
var testTrack;
var seekedCount = 0;
var info = [ "Lorem", "ipsum", "dolor", "sit" ];
function testFontSize(width, height)
{
run("video.width = " + width);
run("video.height = " + height);
document.body.offsetTop;
testExpected("getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize", parseInt(height * 0.05) + "px");
consoleWrite("");
}
function testCueStyle()
{
consoleWrite("<br>Test the cue display colors and font.");
testFontSize(320, 240);
testFontSize(640, 480);
testFontSize(1280, 960);
testFontSize(2560, 1440);
testExpected("getComputedStyle(textTrackDisplayElement(video, 'container')).fontFamily", "sans-serif");
testExpected("getComputedStyle(textTrackDisplayElement(video, 'container')).color", "rgba(255, 255, 255, 0)");
testExpected("getComputedStyle(textTrackDisplayElement(video, 'display')).backgroundColor", "rgba(0, 0, 0, 0.796875)");
endTest();
// Resize the video so it is easier to interact with it manually, if necessary.
video.width = 320;
video.height = 240;
}
function seeked()
{
if (testEnded)
return;
testExpected("video.currentTime", seekedCount + .5);
testExpected("testTrack.track.activeCues.length", 1);
testExpected("testTrack.track.activeCues[0].text", info[seekedCount]);
testExpected("textTrackDisplayElement(video, 'display').innerText", info[seekedCount]);
if (++seekedCount == info.length)
testCueStyle();
else {
consoleWrite("");
run("video.currentTime = " + (video.currentTime + 1));
return;
}
}
function loaded()
{
consoleWrite("Test that TextTrack's cues are rendered correctly.");
findMediaElement();
testTrack = document.querySelector('track');
video.src = findMediaFile('video', '../content/test');
waitForEvent('seeked', seeked);
waitForEvent('canplaythrough', function() { video.currentTime = .5; });
}
</script>
</head>
<body onload="loaded()">
<video controls >
<track src="captions-webvtt/captions.vtt" kind="captions" default>
</video>
</body>
</html>