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

Unified Diff: third_party/WebKit/LayoutTests/media/video-load-networkState.html

Issue 2077413002: Convert video-duration*, video-error* and video-load* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/media/video-load-networkState.html
diff --git a/third_party/WebKit/LayoutTests/media/video-load-networkState.html b/third_party/WebKit/LayoutTests/media/video-load-networkState.html
index a607f3dedcd6b63c08be6bfa00ad839014b0c440..e4175edab3aa0e84c4e77ffbe2d6a59eb94b8b0b 100644
--- a/third_party/WebKit/LayoutTests/media/video-load-networkState.html
+++ b/third_party/WebKit/LayoutTests/media/video-load-networkState.html
@@ -1,57 +1,31 @@
-<html>
-<body>
-
- <video controls></video>
-
- <p>Test that setting src to an invalid url triggers load(), which sets networkState
- to NETWORK_NO_SOURCE. Setting src to a valid url should then trigger the loading
- events and end up with networkState >= NETWORK_LOADING.
- </p>
-
- <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>
- <script>
- function testNetworkState(expected, endit, op)
- {
- testExpected("video.networkState", expected, op);
- if (endit)
- endTest();
- }
-
- waitForEvent("loadstart");
- waitForEvent("loadedmetadata");
- waitForEvent("loadeddata");
- waitForEvent("canplay");
- waitForEventAndFail("play");
- waitForEventAndFail("playing");
- waitForEvent("canplaythrough", function () { testNetworkState(HTMLMediaElement.NETWORK_IDLE, true, '>=' ); } );
-
- function waitUntilNotLoading()
- {
- if (video.networkState == HTMLMediaElement.NETWORK_LOADING) {
- setTimeout(waitUntilNotLoading, 100);
- return;
- }
-
- testNetworkState(HTMLMediaElement.NETWORK_NO_SOURCE);
- consoleWrite("");
-
- // now set a valid url
- var mediaFile = findMediaFile("video", "content/test");
- disableFullTestDetailsPrinting();
- runSilently("video.src = '" + mediaFile + "'");
- enableFullTestDetailsPrinting();
- }
-
- // first set the src to a bogus url, it should attempt a load
- consoleWrite("");
- testNetworkState(HTMLMediaElement.NETWORK_EMPTY);
- run("video.src = 'bogus/movie.mpg'");
-
- setTimeout(waitUntilNotLoading, 100);
- </script>
-
-</body>
-</html>
+<!DOCTYPE html>
+<title>Test that setting src to an invalid url triggers load(), which sets networkState to NETWORK_NO_SOURCE. Setting src to a valid url should then trigger the loading events and end up with networkState >= NETWORK_LOADING.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="media-file.js"></script>
+<video></video>
+<script>
+async_test(function(t) {
+ var video = document.querySelector("video");
+ video.onloadstart = t.step_func(function() {});
+ video.onloadedmetadata = t.step_func(function() {});
+ video.onloadeddata = t.step_func(function() {});
+ video.oncanplay = t.step_func(function() {});
+ video.onplay = t.unreached_func();
+ video.onplaying = t.unreached_func();
+
+ video.onerror = t.step_func(function() {
+ assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE);
+ // now set a valid url
+ video.src = findMediaFile("video", "content/test");
+ });
+
+ video.oncanplaythrough = t.step_func_done(function () {
+ assert_greater_than_equal(video.networkState, HTMLMediaElement.NETWORK_IDLE);
+ });
+
+ // first set the src to a bogus url, it should attempt a load
+ assert_equals(video.networkState, HTMLMediaElement.NETWORK_EMPTY);
+ video.src = "bogus/movie.mpg";
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698