3 <title><video> element with poster size test</title>
4 <script src=video-test.js></script>
12 description:", with 'width' and 'height' attributes",
19 description:", size should equal image size",
20 url:"content/greenbox.png",
25 description:", with NO 'width' or 'height' attributes so size should be <video> default",
27 reflectedUrl:"video-poster.html",
32 description:", size should equal image size",
33 url:"content/abe.png",
38 description:", invalid url so size should revert to <video> default",
39 url:"content/bogus.png",
46 // Wait for |video| to have the |expectedWidth| and |expectedHeight|
47 // and invoke |callback()|.
48 function listenForWidthAndHeight(expectedWidth, expectedHeight, callback) {
49 if (video.clientWidth == expectedWidth && video.clientHeight == expectedHeight) {
52 // This uses a 20ms sleep loop to accomplish the wait, since the
53 // standard specifies no events that fire on poster load or error.
54 window.setTimeout(listenForWidthAndHeight, 20, expectedWidth, expectedHeight, callback);
60 var temp = document.body.offsetWidth;
61 var poster = posterInfo.posters[posterInfo.current];
63 var size = poster.url ? (" " + poster.width + "x" + poster.height) : "";
64 var urlStr = typeof(poster.url) == "string" ? ("'" + poster.url + "'") : 'null';
65 var desc = "<b>Testing" + size + " poster <em>"+ urlStr + "</em>" + poster.description + ".</b>";
68 testExpected("video.getAttribute('poster')", poster.url);
69 testExpected("relativeURL(video.poster)", poster.hasOwnProperty("reflectedUrl") ? poster.reflectedUrl : poster.url);
70 testExpected("video.clientWidth", poster.width);
71 testExpected("video.clientHeight", poster.height);
73 // Remove width/height attributes if present
75 video.removeAttribute('width');
77 video.removeAttribute('height');
81 if (posterInfo.current >= posterInfo.posters.length) {
85 var currentPoster = posterInfo.posters[posterInfo.current];
86 listenForWidthAndHeight(currentPoster.width, currentPoster.height, testPoster);
87 var url = currentPoster.url;
88 var desc = "<b>Setting poster to <em>\""+ url + "\"</em></b>";
93 function unexpectedEvent(evt)
96 failTest("Unexpected '" + evt.type + "' event fired!");
101 document.addEventListener("error", unexpectedEvent);
102 document.addEventListener("load", unexpectedEvent);
110 <video controls width=320 height=240></video>
111 <p>Test <video> element with and without a poster.</p>
112 <script>setup();</script>