Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-size.html

Issue 2126753002: Convert video-[default, size, timeupdate]* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <!DOCTYPE html>
2 <head> 2 <title>Test "video" element size with and without "src" and "poster" attributes. </title>
3 <title>&lt;video&gt; 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");
13 movies: 61 image.src = movie.poster;
14 [ 62 document.body.appendChild(image);
15 { 63 image.onload = t.step_func(runTest);
16 src:null, 64 } else {
17 poster:null, 65 runTest();
18 description:"no 'src' and no 'poster', with 'width' and 'height' attributes", 66 }
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 &lt;video&gt ; 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 67
63 function setupNextConfiguration() 68 function runTest() {
64 { 69 var video = document.createElement("video");
65 consoleWrite(""); 70 document.body.appendChild(video);
66 if (movieInfo.current >= movieInfo.movies.length) 71 if (movie.setSize) {
67 { 72 video.setAttribute("width", "640");
68 endTest(); 73 video.setAttribute("height", "480");
69 return;
70 }
71
72 var movie = movieInfo.movies[movieInfo.current];
73 if (movie.src || movie.poster) {
74 var desc = "<b>Setting ";
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
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 } 74 }
96 75
97 function testMovie() 76 if (movie.src)
98 { 77 video.src = findMediaFile("video", movie.src);
99 if (movieInfo.current >= movieInfo.movies.length)
100 return;
101 78
102 var temp = document.body.offsetWidth; 79 if (movie.poster)
103 var movie = movieInfo.movies[movieInfo.current]; 80 video.poster = movie.poster;
104 81
105 var desc = "<b>Testing movie with " + movie.description + ".</b> "; 82 video.onloadedmetadata = t.step_func_done(testMovieSize);
106 consoleWrite(desc);
107 83
108 testExpected("video.clientWidth", movie.width); 84 if (!movie.src || movie.src.indexOf("bogus") >= 0) {
109 testExpected("video.clientHeight", movie.height); 85 setTimeout(t.step_func_done(testMovieSize), 0);
foolip 2016/07/07 13:37:32 This is now assuming that the poster image will lo
Srirama 2016/07/07 13:48:17 Working fine both in release and debug builds in m
foolip 2016/07/07 13:55:40 No need I think until it's proven to be flaky. But
Srirama 2016/07/07 13:57:42 Acknowledged.
110 testExpected("video.videoWidth", movie.videoWidth);
111 testExpected("video.videoHeight", movie.videoHeight);
112
113 movieInfo.current++;
114 setupNextConfiguration();
115 } 86 }
116 87
117 function test() 88 function testMovieSize() {
118 { 89 assert_equals(video.clientWidth, movie.width);
119 findMediaElement(); 90 assert_equals(video.clientHeight, movie.height);
120 testMovie(); 91 assert_equals(video.videoWidth, movie.videoWidth);
92 assert_equals(video.videoHeight, movie.videoHeight);
121 } 93 }
122 </script> 94 }
123 </head> 95 }, movie.description);
124 96 });
125 <body onload="setTimeout(test, 100)"> 97 </script>
126
127 <video controls width=640 height=480 onloadedmetadata="testMovie()"></vi deo>
128 <p>Test &lt;video&gt; element size with and without 'src' and 'poster' a ttributes.</p>
129
130 </body>
131 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698