OLD | NEW |
1 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 1 <!DOCTYPE html> |
2 (Please avoid writing new tests using video-test.js) --> | 2 <title>Test that media dimensions are equal to poster dimensions when "src" is i
nvalid.</title> |
3 <script src=video-test.js></script> | 3 <script src="../resources/testharness.js"></script> |
4 <video poster="content/abe.png"> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <source src="content/bogus" type="bogus"> | 5 <video poster="content/abe.png"></video> |
6 </video> | |
7 <script> | 6 <script> |
8 findMediaElement(); | 7 async_test(function(t) { |
| 8 var video = document.querySelector("video"); |
9 | 9 |
10 function listenForWidthAndHeight(expectedWidth, expectedHeight, callback) { | 10 video.onloadstart = t.step_func(function () { |
11 if (video.clientWidth == expectedWidth && video.clientHeight == expected
Height) { | 11 var image = document.createElement("img"); |
12 callback(); | 12 image.src = "content/abe.png"; |
13 } else { | 13 // With this we can be reasonably sure that the poster is loaded. |
14 // This uses a 20ms sleep loop to accomplish the wait, since the | 14 image.onload = t.step_func_done(function() { |
15 // standard specifies no events that fire on poster load or error. | 15 assert_equals(video.clientWidth, 76); |
16 window.setTimeout(listenForWidthAndHeight, 20, expectedWidth, expect
edHeight, callback); | 16 assert_equals(video.clientHeight, 103); |
17 } | 17 }); |
18 } | 18 }); |
19 | 19 |
20 function expected() { | 20 video.src = "content/bogus"; |
21 testExpected("video.clientWidth", 76); | 21 }); |
22 testExpected("video.clientHeight", 103); | 22 </script> |
23 endTest(); | |
24 } | |
25 | |
26 run("video.load()"); | |
27 waitForEvent("loadstart", function () { | |
28 listenForWidthAndHeight(76, 103, expected); | |
29 }); | |
30 </script> | |
OLD | NEW |