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",
44 description
:", with only a 'width' attribute so size should have the same aspect ratio as <video> default",
46 reflectedUrl
:"video-poster.html",
52 description
:", with only a 'width' attribute so size should equal a scaled up image size with the same aspect ratio as the original image",
53 url
:"content/abe.png",
59 description
:", invalid url w/ width attribute so size should have the same aspect ratio as <video> default",
60 url
:"content/bogus.png",
68 // Wait for |video| to have the |expectedWidth| and |expectedHeight|
69 // and invoke |callback()|.
70 function listenForWidthAndHeight(expectedWidth
, expectedHeight
, callback
) {
71 if (video
.clientWidth
== expectedWidth
&& video
.clientHeight
== expectedHeight
) {
74 // This uses a 20ms sleep loop to accomplish the wait, since the
75 // standard specifies no events that fire on poster load or error.
76 window
.setTimeout(listenForWidthAndHeight
, 20, expectedWidth
, expectedHeight
, callback
);
82 var temp
= document
.body
.offsetWidth
;
83 var poster
= posterInfo
.posters
[posterInfo
.current
];
85 var size
= poster
.url
? (" " + poster
.width
+ "x" + poster
.height
) : "";
86 var urlStr
= typeof(poster
.url
) == "string" ? ("'" + poster
.url
+ "'") : 'null';
87 var desc
= "<b>Testing" + size
+ " poster <em>"+ urlStr
+ "</em>" + poster
.description
+ ".</b>";
90 testExpected("video.getAttribute('poster')", poster
.url
);
91 testExpected("relativeURL(video.poster)", poster
.hasOwnProperty("reflectedUrl") ? poster
.reflectedUrl
: poster
.url
);
92 testExpected("video.clientWidth", poster
.width
);
93 testExpected("video.clientHeight", poster
.height
);
95 // Remove width/height attributes if present
97 video
.removeAttribute('width');
99 video
.removeAttribute('height');
101 posterInfo
.current
++;
103 if (posterInfo
.current
>= posterInfo
.posters
.length
) {
107 var currentPoster
= posterInfo
.posters
[posterInfo
.current
];
109 if (currentPoster
.widthAttr
)
110 video
.width
= currentPoster
.widthAttr
;
112 var url
= currentPoster
.url
;
113 var desc
= "<b>Setting poster to <em>\""+ url
+ "\"</em></b>";
116 listenForWidthAndHeight(currentPoster
.width
, currentPoster
.height
, testPoster
);
119 function unexpectedEvent(evt
)
122 failTest("Unexpected '" + evt
.type
+ "' event fired!");
127 document
.addEventListener("error", unexpectedEvent
);
128 document
.addEventListener("load", unexpectedEvent
);
136 <video controls width=
320 height=
240></video>
137 <p>Test
<video
> element with and without a poster.
</p>
138 <script>setup();</script>