Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-align-positioning.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Cue text position and alignment from settings</title>
<script src="track-helpers.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/align-positioning.vtt">
<track src="resources/align-positioning-bad.vtt">
</video>
<script>
async_test(function(t) {
var video = document.querySelector("video");
var trackElements = document.querySelectorAll("track");
assert_equals(trackElements.length, video.textTracks.length);
for (var i = 0; i < trackElements.length; i++)
trackElements[i].onload = t.step_func(trackLoaded);
enableAllTextTracks(video.textTracks);
var numberOfTracksLoaded = 0;
function trackLoaded() {
numberOfTracksLoaded++;
if (numberOfTracksLoaded != 2)
return;
testTrack(0);
testTrackError(1);
t.done();
}
function testTrack(index) {
var expected = [
{ position : 10, align : "start" },
{ position : 20, align : "center" },
{ position : 80, align : "end" }
];
assert_cues_match(video.textTracks[index].cues, expected);
}
function testTrackError(index) {
var expected = [
{ position : 10, align : "center" },
{ position : "auto", align : "center" },
{ position : "auto", align : "center" }
];
assert_cues_match(video.textTracks[index].cues, expected);
}
});
</script>