OLD | NEW |
---|---|
1 <html> | 1 <!DOCTYPE html> |
2 <head> | 2 <title>Test "video" element size with and without "src" and "poster" attributes. </title> |
foolip
2016/07/06 09:22:22
This test is flaky, see https://bugs.chromium.org/
Srirama
2016/07/06 15:03:45
Acknowledged.
| |
3 <title><video> element size and resize test</title> | 3 <script src="../resources/testharness.js"></script> |
4 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 4 <script src="../resources/testharnessreport.js"></script> |
5 (Please avoid writing new tests using video-test.js) --> | 5 <script src="media-file.js"></script> |
6 <script src=video-test.js></script> | 6 <script> |
7 <script src=media-file.js></script> | 7 var movieInfo = [ |
8 { | |
9 src: null, | |
10 poster: null, | |
11 description: "no 'src' and no 'poster', with 'width' and 'height' attrib utes", | |
12 width: 640, | |
13 height: 480, | |
14 videoWidth: 0, | |
15 videoHeight: 0, | |
16 setSize: true | |
17 }, | |
18 { | |
19 src: null, | |
20 poster: null, | |
21 description: "no 'src' and no 'poster', with no 'width' and 'height' att ributes, should be default size", | |
22 width: 300, | |
23 height: 150, | |
24 videoWidth: 0, | |
25 videoHeight: 0 | |
26 }, | |
27 { | |
28 src: null, | |
29 poster: "content/abe.png", | |
30 description: "'poster' but no 'src', should be 'poster' size", | |
31 width: 76, | |
32 height: 103, | |
33 videoWidth: 0, | |
34 videoHeight: 0 | |
35 }, | |
36 { | |
37 src: "content/test", | |
38 poster: "content/abe.png", | |
39 description: "'poster' and 'src', should be 'video' size", | |
40 width: 320, | |
41 height: 240, | |
42 videoWidth: 320, | |
43 videoHeight: 240 | |
44 }, | |
45 { | |
46 src: "content/bogus", | |
47 poster: "content/greenbox.png", | |
48 description: "'poster' and invalid 'src', should be 'poster' size", | |
49 width: 25, | |
50 height: 25, | |
51 videoWidth: 0, | |
52 videoHeight: 0 | |
53 } | |
54 ]; | |
8 | 55 |
9 <script> | 56 movieInfo.forEach(function(movie) { |
10 var movieInfo = | 57 async_test(function(t) { |
11 { | 58 var video = document.createElement("video"); |
12 current:0, | 59 document.documentElement.appendChild(video); |
13 movies: | 60 if (movie.setSize) { |
14 [ | 61 video.setAttribute("width", "640"); |
15 { | 62 video.setAttribute("height", "480"); |
16 src:null, | 63 } |
17 poster:null, | |
18 description:"no 'src' and no 'poster', with 'width' and 'height' attributes", | |
19 width:640, | |
20 height:480, | |
21 videoWidth:0, | |
22 videoHeight:0 | |
23 }, | |
24 { | |
25 src:null, | |
26 poster:null, | |
27 description:"no 'src' and no 'poster', with NO 'width' a nd 'height' attributes, should be default size", | |
28 width:300, | |
29 height:150, | |
30 videoWidth:0, | |
31 videoHeight:0 | |
32 }, | |
33 { | |
34 src:null, | |
35 poster:"content/abe.png", | |
36 description:"'poster' but no 'src', should be image siz e", | |
37 width:76, | |
38 height:103, | |
39 videoWidth:0, | |
40 videoHeight:0 | |
41 }, | |
42 { | |
43 src:"content/test", | |
44 poster:"content/abe.png", | |
45 description:"'poster' and 'src', should be <video> ; size", | |
46 width:320, | |
47 height:240, | |
48 videoWidth:320, | |
49 videoHeight:240 | |
50 }, | |
51 { | |
52 src:"content/bogus", | |
53 poster:"content/greenbox.png", | |
54 description:"'poster' and invalid 'src', should be image size", | |
55 width:25, | |
56 height:25, | |
57 videoWidth:0, | |
58 videoHeight:0 | |
59 }, | |
60 ] | |
61 }; | |
62 | 64 |
63 function setupNextConfiguration() | 65 if (movie.src || movie.poster) { |
64 { | 66 if (movie.src) |
65 consoleWrite(""); | 67 video.src = findMediaFile("video", movie.src); |
66 if (movieInfo.current >= movieInfo.movies.length) | |
67 { | |
68 endTest(); | |
69 return; | |
70 } | |
71 | 68 |
72 var movie = movieInfo.movies[movieInfo.current]; | 69 if (movie.poster) |
73 if (movie.src || movie.poster) { | 70 video.poster = movie.poster; |
74 var desc = "<b>Setting "; | 71 } |
75 if (movie.src && relativeURL(video.src) != movie.src) { | |
76 video.src = findMediaFile("video", movie.src); | |
77 desc += "'src' to <em>\""+ movie.src + ".[extension]\"</ em> "; | |
78 } | |
79 if (movie.poster && relativeURL(video.poster) != movie.poste r) { | |
80 video.poster = movie.poster; | |
81 desc += "'poster' to <em>\""+ movie.poster + "\"</em>"; | |
82 } | |
83 consoleWrite(desc + "</b>"); | |
84 } | |
85 | 72 |
86 // Remove width/height attributes if present | 73 video.onloadedmetadata = t.step_func_done(function() { |
87 if (video.width || video.height) { | 74 testMovieSize(); |
88 consoleWrite("<b>Removing 'width' and 'height' attributes.</ b>"); | 75 }); |
89 video.removeAttribute('width'); | |
90 video.removeAttribute('height'); | |
91 } | |
92 | 76 |
93 if (!movie.src || movie.src.indexOf('bogus') >= 0) | 77 if (!movie.src || movie.src.indexOf("bogus") >= 0) { |
94 setTimeout(testMovie, 100); | 78 setTimeout(t.step_func_done(function() { |
foolip
2016/07/06 09:22:22
This is why it is flaky. As I said on the bug, "Th
Srirama
2016/07/06 15:03:45
Done.
| |
95 } | 79 testMovieSize(); |
80 }), 100); | |
81 } | |
96 | 82 |
97 function testMovie() | 83 function testMovieSize() { |
98 { | 84 assert_equals(video.clientWidth, movie.width); |
99 if (movieInfo.current >= movieInfo.movies.length) | 85 assert_equals(video.clientHeight, movie.height); |
100 return; | 86 assert_equals(video.videoWidth, movie.videoWidth); |
101 | 87 assert_equals(video.videoHeight, movie.videoHeight); |
102 var temp = document.body.offsetWidth; | 88 } |
103 var movie = movieInfo.movies[movieInfo.current]; | 89 }, movie.description); |
104 | 90 }); |
105 var desc = "<b>Testing movie with " + movie.description + ".</b> "; | 91 </script> |
106 consoleWrite(desc); | |
107 | |
108 testExpected("video.clientWidth", movie.width); | |
109 testExpected("video.clientHeight", movie.height); | |
110 testExpected("video.videoWidth", movie.videoWidth); | |
111 testExpected("video.videoHeight", movie.videoHeight); | |
112 | |
113 movieInfo.current++; | |
114 setupNextConfiguration(); | |
115 } | |
116 | |
117 function test() | |
118 { | |
119 findMediaElement(); | |
120 testMovie(); | |
121 } | |
122 </script> | |
123 </head> | |
124 | |
125 <body onload="setTimeout(test, 100)"> | |
126 | |
127 <video controls width=640 height=480 onloadedmetadata="testMovie()"></vi deo> | |
128 <p>Test <video> element size with and without 'src' and 'poster' a ttributes.</p> | |
129 | |
130 </body> | |
131 </html> | |
OLD | NEW |