Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/video-src-remove.html |
| diff --git a/third_party/WebKit/LayoutTests/media/video-src-remove.html b/third_party/WebKit/LayoutTests/media/video-src-remove.html |
| index 730aa81157158b8d3858f82e10c8014941dde49a..3031dc53bb78a9b53668d400bf4606aa34a474c2 100644 |
| --- a/third_party/WebKit/LayoutTests/media/video-src-remove.html |
| +++ b/third_party/WebKit/LayoutTests/media/video-src-remove.html |
| @@ -1,58 +1,37 @@ |
| -<html> |
| -<body> |
| - <script src=media-file.js></script> |
| - <!-- 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> |
| - <div id=panel></div> |
| - <script> |
| - var panel = document.getElementById("panel"); |
| - var mediaFile = findMediaFile("video", "content/test"); |
| - panel.innerHTML = "<video src=" + mediaFile + " controls onloadedmetadata='loadedmetadata()'><source src=content/counting.mp4></video>"; |
| - </script> |
| - |
| - <p>Test that removing valid 'src' attribute DOES NOT trigger load of <source> elements</p> |
| - |
| - <script> |
| - findMediaElement(); |
| - |
| - var loadCount = 0; |
| - |
| - function testSrc() |
| - { |
| - testExpected("stripExtension(relativeURL(video.currentSrc))", stripExtension(mediaFile)); |
| - testExpected("isNaN(video.duration)", false); |
| - consoleWrite(""); |
| - } |
| - |
| - function loadedmetadata() |
| - { |
| - consoleWrite("EVENT(loadedmetadata)"); |
| - |
| - ++loadCount; |
| - if (loadCount == 1) |
| - { |
| - testSrc(); |
| - run("video.removeAttribute('src')"); |
| - } |
| - else |
| - { |
| - consoleWrite("<span style='color:red'>FAIL</span> : 'loadCount' fired " + loadCount + "times" ); |
| - endTest(); |
| - } |
| - consoleWrite(""); |
| - setTimeout(someTimeLater, 100) ; |
| - } |
| - |
| - function someTimeLater() |
| - { |
| +<!DOCTYPE html> |
| +<title>Test that removing valid "src" attribute doesn't trigger load of "source" elements.</title> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="media-file.js"></script> |
| +<video> |
| + <source></source> |
| +</video> |
| +<script> |
| +async_test(function(t) { |
| + var loadCount = 0; |
| + var video = document.querySelector("video"); |
| + |
| + video.onloadedmetadata = t.step_func(function() { |
| + ++loadCount; |
| + if (loadCount == 1) { |
| testSrc(); |
| - endTest(); |
| - consoleWrite(""); |
| + video.removeAttribute("src"); |
| + video.onloadedmetadata = t.unreached_func(); |
|
fs
2016/06/26 15:10:43
Because of this we should never "re-enter" this fu
Srirama
2016/06/26 18:14:03
I think the loadCount check doesn't make sense as
|
| } |
| - consoleWrite(""); |
| - </script> |
| - |
| -</body> |
| -</html> |
| + setTimeout(t.step_func_done(function() { |
| + testSrc(); |
| + }), 100) ; |
| + }); |
| + |
| + function testSrc() { |
| + var url = video.currentSrc; |
| + assert_equals(url.substr(url.lastIndexOf("/media/")+7), mediaFile); |
| + assert_false(isNaN(video.duration)); |
| + } |
| + |
| + document.querySelector("source").src = findMediaFile("video", "content/counting"); |
| + var mediaFile = findMediaFile("video", "content/test"); |
| + video.src = mediaFile; |
| +}); |
| +</script> |