Chromium Code Reviews| 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..aef8c42de9ee2fa9e0e4f36b85b29f644af54bd9 100644 |
| --- a/third_party/WebKit/LayoutTests/media/video-size.html |
| +++ b/third_party/WebKit/LayoutTests/media/video-size.html |
| @@ -1,131 +1,91 @@ |
| -<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> |
|
foolip
2016/07/06 09:22:22
This test is flaky, see https://bugs.chromium.org/
Srirama
2016/07/06 15:03:45
Acknowledged.
|
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="media-file.js"></script> |
| +<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) { |
| + var video = document.createElement("video"); |
| + document.documentElement.appendChild(video); |
| + if (movie.setSize) { |
| + video.setAttribute("width", "640"); |
| + video.setAttribute("height", "480"); |
| + } |
| - function setupNextConfiguration() |
| - { |
| - consoleWrite(""); |
| - if (movieInfo.current >= movieInfo.movies.length) |
| - { |
| - endTest(); |
| - return; |
| - } |
| + if (movie.src || movie.poster) { |
| + if (movie.src) |
| + video.src = findMediaFile("video", movie.src); |
| - 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>"); |
| - } |
| + if (movie.poster) |
| + video.poster = movie.poster; |
| + } |
| - // 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'); |
| - } |
| + video.onloadedmetadata = t.step_func_done(function() { |
| + testMovieSize(); |
| + }); |
| - if (!movie.src || movie.src.indexOf('bogus') >= 0) |
| - setTimeout(testMovie, 100); |
| - } |
| + if (!movie.src || movie.src.indexOf("bogus") >= 0) { |
| + 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.
|
| + testMovieSize(); |
| + }), 100); |
| + } |
| - function testMovie() |
| - { |
| - if (movieInfo.current >= movieInfo.movies.length) |
| - return; |
| - |
| - var temp = document.body.offsetWidth; |
| - var movie = movieInfo.movies[movieInfo.current]; |
| - |
| - var desc = "<b>Testing movie with " + movie.description + ".</b>"; |
| - consoleWrite(desc); |
| - |
| - testExpected("video.clientWidth", movie.width); |
| - testExpected("video.clientHeight", movie.height); |
| - testExpected("video.videoWidth", movie.videoWidth); |
| - testExpected("video.videoHeight", movie.videoHeight); |
| - |
| - movieInfo.current++; |
| - setupNextConfiguration(); |
| - } |
| - |
| - function test() |
| - { |
| - findMediaElement(); |
| - testMovie(); |
| - } |
| - </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> |
| + 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); |
| + } |
| + }, movie.description); |
| +}); |
| +</script> |