blob: 2aa9bccfb746b2a35c16d9c8d86c4d12226c7c36 [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 seekCount = 0;
function seeked()
{
var currentCue = textTrackDisplayElement(video, 'cue');
consoleWrite("<br>** Check style in .vtt file **");
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).color", "rgb(255, 255, 255)");
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor", "rgba(0, 0, 0, 0.8)");
consoleWrite("<br>** Add style to the document **");
var styleElement = document.createElement("style");
document.head.appendChild(styleElement);
stylesheet = styleElement.sheet;
run("stylesheet.insertRule('video::cue { color: purple; background-color: lime; }', 0)");
document.body.offsetTop;
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).color", "rgb(128, 0, 128)");
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor", "rgb(0, 255, 0)");
consoleWrite("<br>** Add an override, without '!important' **");
document.body.offsetTop;
run("internals.setCaptionsStyleSheetOverride('video::cue { color: blue; background-color: yellow; }')");
consoleWrite("internals.captionsStyleSheetOverride = " + internals.captionsStyleSheetOverride());
document.body.offsetTop;
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).color", "rgb(128, 0, 128)");
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor", "rgb(0, 255, 0)");
consoleWrite("<br>** Mark background-color '!important' **");
run("internals.setCaptionsStyleSheetOverride('video::cue { color: blue ; background-color: yellow !important; }')");
// The style is not immediately updated, schedule the rest of the test with a zero timeout timer.
setTimeout(function() {
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).color", "rgb(128, 0, 128)");
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor", "rgb(255, 255, 0)");
consoleWrite("<br>** Mark color '!important' **");
run("stylesheet.insertRule('video::cue { color: blue !important; background-color: yellow !important; }', 0)");
document.body.offsetTop;
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).color", "rgb(0, 0, 255)");
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor", "rgb(255, 255, 0)");
consoleWrite("");
endTest();
}, 100);
}
function loaded()
{
consoleWrite("<br>internals.captionsStyleSheetOverride = " + internals.captionsStyleSheetOverride());
consoleWrite("Test that style to all cues is applied correctly.");
findMediaElement();
video.src = findMediaFile('video', '../content/test');
waitForEvent('seeked', seeked);
waitForEvent('canplaythrough', function() { video.currentTime = .5; });
}
setCaptionDisplayMode('Automatic');
</script>
</head>
<body onload="loaded()">
<video controls >
<track src="captions-webvtt/styling.vtt" kind="captions" default>
</video>
</body>
</html>