blob: 462bddda72ee7450ffa7cf949b968843690583b4 [file] [log] [blame]
<!DOCTYPE html>
<title>Test "video" element size with and without "src" and "poster" attributes.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="media-file.js"></script>
<body>
<script>
var movieInfo = [
{
src: null,
poster: null,
description: "no 'src' and no 'poster', with 'width' and 'height' attributes",
width: 640,
height: 480,
videoWidth: 0,
videoHeight: 0,
setSize: true
},
{
src: null,
poster: null,
description: "no 'src' and no 'poster', with no 'width' and 'height' attributes, should be default size",
width: 300,
height: 150,
videoWidth: 0,
videoHeight: 0
},
{
src: null,
poster: "content/abe.png",
description: "'poster' but no 'src', should be 'poster' size",
width: 76,
height: 103,
videoWidth: 0,
videoHeight: 0
},
{
src: "content/test",
poster: "content/abe.png",
description: "'poster' and 'src', should be 'video' size",
width: 320,
height: 240,
videoWidth: 320,
videoHeight: 240
},
{
src: "content/bogus",
poster: "content/greenbox.png",
description: "'poster' and invalid 'src', should be 'poster' size",
width: 25,
height: 25,
videoWidth: 0,
videoHeight: 0
}
];
movieInfo.forEach(function(movie) {
async_test(function(t) {
if (movie.poster) {
var image = document.createElement("img");
image.src = movie.poster;
document.body.appendChild(image);
image.onload = t.step_func(runTest);
} else {
runTest();
}
function runTest() {
var video = document.createElement("video");
document.body.appendChild(video);
if (movie.setSize) {
video.setAttribute("width", "640");
video.setAttribute("height", "480");
}
if (movie.src)
video.src = findMediaFile("video", movie.src);
if (movie.poster)
video.poster = movie.poster;
video.onloadedmetadata = t.step_func_done(testMovieSize);
if (!movie.src || movie.src.indexOf("bogus") >= 0) {
setTimeout(t.step_func_done(testMovieSize), 0);
}
function testMovieSize() {
assert_equals(video.clientWidth, movie.width);
assert_equals(video.clientHeight, movie.height);
assert_equals(video.videoWidth, movie.videoWidth);
assert_equals(video.videoHeight, movie.videoHeight);
}
}
}, movie.description);
});
</script>