OLD | NEW |
---|---|
1 <html> | 1 <!DOCTYPE html> |
2 <head> | 2 <title>Test "video" element size with and without "src" and "poster" attributes. </title> |
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 <body> |
7 <script src=media-file.js></script> | 7 <script> |
8 var movieInfo = [ | |
9 { | |
10 src: null, | |
11 poster: null, | |
12 description: "no 'src' and no 'poster', with 'width' and 'height' attrib utes", | |
13 width: 640, | |
14 height: 480, | |
15 videoWidth: 0, | |
16 videoHeight: 0, | |
17 setSize: true | |
18 }, | |
19 { | |
20 src: null, | |
21 poster: null, | |
22 description: "no 'src' and no 'poster', with no 'width' and 'height' att ributes, should be default size", | |
23 width: 300, | |
24 height: 150, | |
25 videoWidth: 0, | |
26 videoHeight: 0 | |
27 }, | |
28 { | |
29 src: null, | |
30 poster: "content/abe.png", | |
31 description: "'poster' but no 'src', should be 'poster' size", | |
32 width: 76, | |
33 height: 103, | |
34 videoWidth: 0, | |
35 videoHeight: 0 | |
36 }, | |
37 { | |
38 src: "content/test", | |
39 poster: "content/abe.png", | |
40 description: "'poster' and 'src', should be 'video' size", | |
41 width: 320, | |
42 height: 240, | |
43 videoWidth: 320, | |
44 videoHeight: 240 | |
45 }, | |
46 { | |
47 src: "content/bogus", | |
48 poster: "content/greenbox.png", | |
49 description: "'poster' and invalid 'src', should be 'poster' size", | |
50 width: 25, | |
51 height: 25, | |
52 videoWidth: 0, | |
53 videoHeight: 0 | |
54 } | |
55 ]; | |
8 | 56 |
9 <script> | 57 movieInfo.forEach(function(movie) { |
10 var movieInfo = | 58 async_test(function(t) { |
11 { | 59 if (movie.poster) { |
12 current:0, | 60 var image = document.createElement("img"); |
foolip
2016/07/07 12:33:08
A very clever implementation might be able to see
Srirama
2016/07/07 13:17:48
Done, it is working
| |
13 movies: | 61 image.src = movie.poster; |
14 [ | |
15 { | |
16 src:null, | |
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 | 62 |
63 function setupNextConfiguration() | 63 image.onload = t.step_func(function() { |
64 { | 64 setTimeout(runTest, 0); |
foolip
2016/07/07 12:33:08
Need to wrap t.step_func(runTest), and since you l
Srirama
2016/07/07 13:17:47
Done.
| |
65 consoleWrite(""); | 65 }); |
66 if (movieInfo.current >= movieInfo.movies.length) | 66 } else { |
67 { | 67 runTest(); |
68 endTest(); | 68 } |
69 return; | |
70 } | |
71 | 69 |
72 var movie = movieInfo.movies[movieInfo.current]; | 70 function runTest() { |
73 if (movie.src || movie.poster) { | 71 var video = document.createElement("video"); |
74 var desc = "<b>Setting "; | 72 document.body.appendChild(video); |
75 if (movie.src && relativeURL(video.src) != movie.src) { | 73 if (movie.setSize) { |
76 video.src = findMediaFile("video", movie.src); | 74 video.setAttribute("width", "640"); |
77 desc += "'src' to <em>\""+ movie.src + ".[extension]\"</ em> "; | 75 video.setAttribute("height", "480"); |
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 | |
86 // Remove width/height attributes if present | |
87 if (video.width || video.height) { | |
88 consoleWrite("<b>Removing 'width' and 'height' attributes.</ b>"); | |
89 video.removeAttribute('width'); | |
90 video.removeAttribute('height'); | |
91 } | |
92 | |
93 if (!movie.src || movie.src.indexOf('bogus') >= 0) | |
94 setTimeout(testMovie, 100); | |
95 } | 76 } |
96 | 77 |
97 function testMovie() | 78 if (movie.src) |
98 { | 79 video.src = findMediaFile("video", movie.src); |
99 if (movieInfo.current >= movieInfo.movies.length) | |
100 return; | |
101 | 80 |
102 var temp = document.body.offsetWidth; | 81 if (movie.poster) |
103 var movie = movieInfo.movies[movieInfo.current]; | 82 video.poster = movie.poster; |
104 | 83 |
105 var desc = "<b>Testing movie with " + movie.description + ".</b> "; | 84 video.onloadedmetadata = t.step_func_done(function() { |
106 consoleWrite(desc); | 85 testMovieSize(); |
foolip
2016/07/07 12:33:08
function(){x()} => x here and below.
Srirama
2016/07/07 13:17:47
Done.
| |
86 }); | |
107 | 87 |
108 testExpected("video.clientWidth", movie.width); | 88 if (!movie.src || movie.src.indexOf("bogus") >= 0) { |
109 testExpected("video.clientHeight", movie.height); | 89 setTimeout(t.step_func_done(function() { |
110 testExpected("video.videoWidth", movie.videoWidth); | 90 testMovieSize(); |
111 testExpected("video.videoHeight", movie.videoHeight); | 91 }), 0); |
112 | |
113 movieInfo.current++; | |
114 setupNextConfiguration(); | |
115 } | 92 } |
116 | 93 |
117 function test() | 94 function testMovieSize() { |
118 { | 95 assert_equals(video.clientWidth, movie.width); |
119 findMediaElement(); | 96 assert_equals(video.clientHeight, movie.height); |
120 testMovie(); | 97 assert_equals(video.videoWidth, movie.videoWidth); |
98 assert_equals(video.videoHeight, movie.videoHeight); | |
121 } | 99 } |
122 </script> | 100 } |
123 </head> | 101 }, movie.description); |
124 | 102 }); |
125 <body onload="setTimeout(test, 100)"> | 103 </script> |
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 |