Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/video-delay-load-event.html |
| diff --git a/third_party/WebKit/LayoutTests/media/video-delay-load-event.html b/third_party/WebKit/LayoutTests/media/video-delay-load-event.html |
| index 7de7b4b2f2b2afed00e5f265f65748e2f0c6c42f..338ef18c13543af9ff37b154def3ec8e18f74ac0 100644 |
| --- a/third_party/WebKit/LayoutTests/media/video-delay-load-event.html |
| +++ b/third_party/WebKit/LayoutTests/media/video-delay-load-event.html |
| @@ -1,72 +1,46 @@ |
| -<!doctype html> |
| -<html> |
| - <head> |
| - <title>delay document 'load' event test</title> |
| - <style> video { border: 3px solid red; } </style> |
| - <!-- 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> |
| - <script> |
| - var video; |
| - |
| - function testMovieWithNoSource(elem) |
| - { |
| - video = elem; // Need it in a global for testExpected() to see it. |
| - consoleWrite("<em>no 'src'.</em>"); |
| - testExpected("video.networkState", HTMLMediaElement.prototype.NETWORK_EMPTY, "=="); |
| - testExpected("video.readyState", HTMLMediaElement.prototype.HAVE_NOTHING, "=="); |
| - } |
| - |
| - function testMovieWithSource(elem, hasLoaded, msg) |
| - { |
| - video = elem; // Need it in a global for testExpected() to see it. |
| - consoleWrite(msg); |
| - if (hasLoaded) { |
| - // The movie should have loaded at least to HAVE_CURRENT_DATA |
| - testExpected("video.networkState", HTMLMediaElement.prototype.NETWORK_NO_SOURCE, "!="); |
| - testExpected("video.networkState", HTMLMediaElement.prototype.NETWORK_IDLE, ">="); |
| - testExpected("video.readyState", HTMLMediaElement.prototype.HAVE_CURRENT_DATA, ">="); |
| - } else { |
| - testExpected("video.networkState", HTMLMediaElement.prototype.NETWORK_NO_SOURCE, "=="); |
| - testExpected("video.readyState", HTMLMediaElement.prototype.HAVE_NOTHING, "=="); |
| - } |
| - } |
| - |
| - function loaded() |
| - { |
| - consoleWrite("<br><b>document <em>'load'<" + "/em> event handler</b>"); |
| - |
| - testMovieWithNoSource(document.getElementById('video-1')); |
| - testMovieWithSource(document.getElementById('video-2'), true, "<br><em>with 'src' attribute.</em>"); |
| - testMovieWithSource(document.getElementById('video-3'), true, "<br><em>with <source> element.</em>"); |
| - |
| - if (window.testRunner) |
| - testRunner.notifyDone(); |
| - } |
| - </script> |
| - </head> |
| - <body onload="loaded()"> |
| - <video id="video-1"></video> |
| - <video id="video-2"></video> |
| - <video id="video-3"><source id="source-1"></video> |
| - |
| - <p>Test the document's load event is delayed until a movie's meta data is available.</p> |
| - |
| - <script> |
| - consoleWrite("<br><b>inline script</b>"); |
| - |
| - testMovieWithNoSource(document.getElementById('video-1')); |
| - |
| - video = document.getElementById('video-2'); |
| - video.src = findMediaFile("video", "content/test"); |
| - testMovieWithSource(video, false, "<br><em>with 'src' attribute.</em>"); |
| - |
| - source = document.getElementById('source-1'); |
| - source.src = findMediaFile("video", "content/test"); |
| - testMovieWithSource(document.getElementById('video-3'), false, "<br><em>with <source> element.</em>"); |
| - document.getElementById('video-3').load(); |
| - </script> |
| - |
| - </body> |
| -</html> |
| +<!DOCTYPE html> |
| +<title>Test that the document's load event is delayed until a video's meta data is available.</title> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="media-file.js"></script> |
| +<body> |
|
fs
2016/06/27 18:46:38
Is this needed?
Srirama
2016/06/28 17:42:00
Done.
|
| +<video id="video1"></video> |
| +<video id="video2"></video> |
| +<video id="video3"><source></source></video> |
| +<script> |
| +async_test(function(t) { |
| + testVideoWithNoSource(document.getElementById("video1")); |
| + |
| + var video = document.getElementById("video2"); |
| + video.src = findMediaFile("video", "content/test"); |
| + testVideoWithSource(video, false); |
| + |
| + var source = document.querySelector("source"); |
| + source.src = findMediaFile("video", "content/test"); |
| + testVideoWithSource(document.getElementById("video3"), false); |
| + |
| + window.onload = t.step_func_done(function() { |
| + testVideoWithNoSource(document.getElementById("video1")); |
| + testVideoWithSource(document.getElementById("video2"), true); |
| + testVideoWithSource(document.getElementById("video3"), true); |
| + }); |
| + |
| + function testVideoWithNoSource(video) { |
| + assert_equals(video.networkState, HTMLMediaElement.NETWORK_EMPTY); |
| + assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING); |
| + } |
| + |
| + function testVideoWithSource(video, hasLoaded) { |
|
fs
2016/06/27 18:46:38
Since this only consists of two very distinct code
Srirama
2016/06/28 17:42:00
Done.
|
| + if (hasLoaded) { |
| + // The Video should have loaded at least to HAVE_CURRENT_DATA |
| + assert_not_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE); |
| + assert_greater_than_equal(video.networkState, HTMLMediaElement.NETWORK_IDLE); |
| + assert_greater_than_equal(video.readyState, HTMLMediaElement.HAVE_CURRENT_DATA); |
| + } else { |
| + assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE); |
| + assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING); |
| + } |
| + } |
| +}); |
| +</script> |
| +</body> |