Index: third_party/WebKit/LayoutTests/media/video-size.html |
diff --git a/third_party/WebKit/LayoutTests/media/video-size.html b/third_party/WebKit/LayoutTests/media/video-size.html |
index 9446d96daa2eb9e7a75474912984fb6cc5239079..462bddda72ee7450ffa7cf949b968843690583b4 100644 |
--- a/third_party/WebKit/LayoutTests/media/video-size.html |
+++ b/third_party/WebKit/LayoutTests/media/video-size.html |
@@ -1,131 +1,97 @@ |
-<html> |
- <head> |
- <title><video> element size and resize test</title> |
- <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 |
- (Please avoid writing new tests using video-test.js) --> |
- <script src=video-test.js></script> |
- <script src=media-file.js></script> |
+<!DOCTYPE html> |
+<title>Test "video" element size with and without "src" and "poster" attributes.</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="media-file.js"></script> |
+<body> |
+<script> |
+var movieInfo = [ |
+ { |
+ src: null, |
+ poster: null, |
+ description: "no 'src' and no 'poster', with 'width' and 'height' attributes", |
+ width: 640, |
+ height: 480, |
+ videoWidth: 0, |
+ videoHeight: 0, |
+ setSize: true |
+ }, |
+ { |
+ src: null, |
+ poster: null, |
+ description: "no 'src' and no 'poster', with no 'width' and 'height' attributes, should be default size", |
+ width: 300, |
+ height: 150, |
+ videoWidth: 0, |
+ videoHeight: 0 |
+ }, |
+ { |
+ src: null, |
+ poster: "content/abe.png", |
+ description: "'poster' but no 'src', should be 'poster' size", |
+ width: 76, |
+ height: 103, |
+ videoWidth: 0, |
+ videoHeight: 0 |
+ }, |
+ { |
+ src: "content/test", |
+ poster: "content/abe.png", |
+ description: "'poster' and 'src', should be 'video' size", |
+ width: 320, |
+ height: 240, |
+ videoWidth: 320, |
+ videoHeight: 240 |
+ }, |
+ { |
+ src: "content/bogus", |
+ poster: "content/greenbox.png", |
+ description: "'poster' and invalid 'src', should be 'poster' size", |
+ width: 25, |
+ height: 25, |
+ videoWidth: 0, |
+ videoHeight: 0 |
+ } |
+]; |
- <script> |
- var movieInfo = |
- { |
- current:0, |
- movies: |
- [ |
- { |
- src:null, |
- poster:null, |
- description:"no 'src' and no 'poster', with 'width' and 'height' attributes", |
- width:640, |
- height:480, |
- videoWidth:0, |
- videoHeight:0 |
- }, |
- { |
- src:null, |
- poster:null, |
- description:"no 'src' and no 'poster', with NO 'width' and 'height' attributes, should be default size", |
- width:300, |
- height:150, |
- videoWidth:0, |
- videoHeight:0 |
- }, |
- { |
- src:null, |
- poster:"content/abe.png", |
- description:"'poster' but no 'src', should be image size", |
- width:76, |
- height:103, |
- videoWidth:0, |
- videoHeight:0 |
- }, |
- { |
- src:"content/test", |
- poster:"content/abe.png", |
- description:"'poster' and 'src', should be <video> size", |
- width:320, |
- height:240, |
- videoWidth:320, |
- videoHeight:240 |
- }, |
- { |
- src:"content/bogus", |
- poster:"content/greenbox.png", |
- description:"'poster' and invalid 'src', should be image size", |
- width:25, |
- height:25, |
- videoWidth:0, |
- videoHeight:0 |
- }, |
- ] |
- }; |
+movieInfo.forEach(function(movie) { |
+ async_test(function(t) { |
+ if (movie.poster) { |
+ var image = document.createElement("img"); |
+ image.src = movie.poster; |
+ document.body.appendChild(image); |
+ image.onload = t.step_func(runTest); |
+ } else { |
+ runTest(); |
+ } |
- function setupNextConfiguration() |
- { |
- consoleWrite(""); |
- if (movieInfo.current >= movieInfo.movies.length) |
- { |
- endTest(); |
- return; |
- } |
- |
- var movie = movieInfo.movies[movieInfo.current]; |
- if (movie.src || movie.poster) { |
- var desc = "<b>Setting "; |
- if (movie.src && relativeURL(video.src) != movie.src) { |
- video.src = findMediaFile("video", movie.src); |
- desc += "'src' to <em>\""+ movie.src + ".[extension]\"</em> "; |
- } |
- if (movie.poster && relativeURL(video.poster) != movie.poster) { |
- video.poster = movie.poster; |
- desc += "'poster' to <em>\""+ movie.poster + "\"</em>"; |
- } |
- consoleWrite(desc + "</b>"); |
- } |
- |
- // Remove width/height attributes if present |
- if (video.width || video.height) { |
- consoleWrite("<b>Removing 'width' and 'height' attributes.</b>"); |
- video.removeAttribute('width'); |
- video.removeAttribute('height'); |
- } |
- |
- if (!movie.src || movie.src.indexOf('bogus') >= 0) |
- setTimeout(testMovie, 100); |
+ function runTest() { |
+ var video = document.createElement("video"); |
+ document.body.appendChild(video); |
+ if (movie.setSize) { |
+ video.setAttribute("width", "640"); |
+ video.setAttribute("height", "480"); |
} |
- function testMovie() |
- { |
- if (movieInfo.current >= movieInfo.movies.length) |
- return; |
- |
- var temp = document.body.offsetWidth; |
- var movie = movieInfo.movies[movieInfo.current]; |
+ if (movie.src) |
+ video.src = findMediaFile("video", movie.src); |
- var desc = "<b>Testing movie with " + movie.description + ".</b>"; |
- consoleWrite(desc); |
+ if (movie.poster) |
+ video.poster = movie.poster; |
- testExpected("video.clientWidth", movie.width); |
- testExpected("video.clientHeight", movie.height); |
- testExpected("video.videoWidth", movie.videoWidth); |
- testExpected("video.videoHeight", movie.videoHeight); |
+ video.onloadedmetadata = t.step_func_done(testMovieSize); |
- movieInfo.current++; |
- setupNextConfiguration(); |
+ if (!movie.src || movie.src.indexOf("bogus") >= 0) { |
+ 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.
|
} |
- function test() |
- { |
- findMediaElement(); |
- testMovie(); |
+ function testMovieSize() { |
+ assert_equals(video.clientWidth, movie.width); |
+ assert_equals(video.clientHeight, movie.height); |
+ assert_equals(video.videoWidth, movie.videoWidth); |
+ assert_equals(video.videoHeight, movie.videoHeight); |
} |
- </script> |
- </head> |
- |
- <body onload="setTimeout(test, 100)"> |
- |
- <video controls width=640 height=480 onloadedmetadata="testMovie()"></video> |
- <p>Test <video> element size with and without 'src' and 'poster' attributes.</p> |
- |
- </body> |
-</html> |
+ } |
+ }, movie.description); |
+}); |
+</script> |