blob: e8f15414fee938f2d25c8a1faa9dab7980ff603a [file] [log] [blame]
<!DOCTYPE html>
<title>Test that WebVTT objects are being styled correctly based on author settings that should override user settings.</title>
<script src="../media-controls.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
/* Author settings for the cues */
video::cue(c) {
color: rgb(255, 0, 0);
background-color: rgb(0, 128, 0);
text-shadow: rgb(0, 255, 0) 3px 3px 0px;
font-size: 20px;
font-family: arial;
}
</style>
<div id="container"></div>
<script>
function addVideoTo(container) {
var video = document.createElement("video");
video.src = "../content/test.ogv";
video.autoplay = true;
var track = document.createElement("track");
track.src = "captions-webvtt/styling.vtt";
track.kind = "captions";
track.default = "true";
video.appendChild(track);
container.appendChild(video);
return video;
}
async_test(function(t) {
var container = document.getElementById("container");
// Test a video without user settings applied.
var video1 = addVideoTo(container);
video1.oncanplaythrough = t.step_func_done(function() {
var cue = textTrackCueElementByIndex(video1, 0).firstChild.firstElementChild;
var cueStyle = getComputedStyle(cue);
assert_equals(cueStyle.color, "rgb(255, 0, 0)");
assert_equals(cueStyle.backgroundColor, "rgb(0, 128, 0)");
assert_equals(cueStyle.textShadow, "rgb(0, 255, 0) 3px 3px 0px");
assert_equals(cueStyle.fontSize, "20px");
assert_equals(cueStyle.fontFamily, "arial");
testApplyUserSettings();
});
// Apply user settings and verify that the author settings are retained, when they exist.
function testApplyUserSettings() {
internals.settings.setTextTrackTextColor("rgb(0, 255, 255)");
internals.settings.setTextTrackBackgroundColor("rgb(0, 255, 0)");
internals.settings.setTextTrackTextShadow("rgb(255, 0, 0) 2px 2px")
internals.settings.setTextTrackTextSize("14px");
internals.settings.setTextTrackFontFamily("fantasy");
internals.settings.setTextTrackFontStyle("italic");
internals.settings.setTextTrackFontVariant("small-caps");
video2 = addVideoTo(container);
video2.oncanplaythrough = t.step_func_done(function() {
var cue = textTrackCueElementByIndex(video2, 0).firstChild.firstElementChild;
var cueStyle = getComputedStyle(cue);
assert_equals(cueStyle.color, "rgb(255, 0, 0)");
assert_equals(cueStyle.backgroundColor, "rgb(0, 128, 0)");
assert_equals(cueStyle.textShadow, "rgb(0, 255, 0) 3px 3px 0px");
assert_equals(cueStyle.fontSize, "20px");
assert_equals(cueStyle.fontFamily, "arial");
assert_equals(cueStyle.fontStyle, "italic");
assert_equals(cueStyle.fontVariant, "small-caps");
});
}
});
</script>