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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/media/video-error-abort.html

Issue 2179483002: Convert video-cookie* and video-error* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use EventWatcher to simplify the test Created 4 years, 5 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/http/tests/media/video-error-abort.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/media/video-error-abort.html b/third_party/WebKit/LayoutTests/http/tests/media/video-error-abort.html
index 687437ee9061740a86c481f784c6967a89f50f02..e128489871edd957828ea2602cefa411e5d06b81 100644
--- a/third_party/WebKit/LayoutTests/http/tests/media/video-error-abort.html
+++ b/third_party/WebKit/LayoutTests/http/tests/media/video-error-abort.html
@@ -1,67 +1,32 @@
-<!DOCTYPE HTML>
-<html>
- <head>
- <title>'abort' event test</title>
- <script src=../../media-resources/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=../../media-resources/video-test.js></script>
- <script>
- var didLoad = false;
-
- function loadstart()
- {
- consoleWrite("<br><b><em>'loadstart'</em> event</b>");
- testExpected("video.error", null);
-
- if (didLoad)
- return;
- didLoad = true;
-
- // Force the element to reload, while the current movie is still loading,
- // this should generate an 'abort' event
- run("video.load()");
- }
-
- function abort()
- {
- consoleWrite("<br><b><em>'abort'</em> event</b>");
- testExpected("video.error", null);
-
- // Progress events have a 'lengthComputable' field, check to make sure this event
- // doesn't have one.
- testExpected("event.lengthComputable", undefined);
- }
-
- function canplaythrough()
- {
- consoleWrite("<br><b><em>'canplaythrough'</em> event</b>");
- testExpected("video.error", null);
-
- consoleWrite("");
- endTest();
- }
-
- function start()
- {
- findMediaElement();
-
- waitForEvent("error");
-
- consoleWrite("<br><b>Test before movie is open</b>");
- testExpected("video.error", null);
-
- var movie = findMediaFile("video", "../resources/test");
- video.src = "http://127.0.0.1:8000/media/video-throttled-load.cgi?name=" + movie + "&throttle=256";
- }
- </script>
- </head>
-
- <body onload="start()">
- <video controls
- onloadstart="loadstart()"
- onabort="abort()"
- oncanplaythrough="canplaythrough()"
- ></video>
- </body>
-</html>
+<!DOCTYPE html>
+<title>Test "abort" event.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../../media-resources/media-file.js"></script>
+<video></video>
+<script>
+async_test(function(t) {
+ var video = document.querySelector("video");
+ // Test before movie is open.
+ assert_equals(video.error, null);
+ video.onerror = t.unreached_func();
+
+ var watcher = new EventWatcher(t, video, ["loadstart", "abort", "canplaythrough"]);
+ watcher.wait_for("loadstart").then(t.step_func(function() {
+ assert_equals(video.error, null);
+ video.load();
+ return watcher.wait_for("abort");
+ })).then(t.step_func(function() {
+ assert_equals(video.error, null);
+ return watcher.wait_for("loadstart");
+ })).then(t.step_func(function() {
+ assert_equals(video.error, null);
+ return watcher.wait_for("canplaythrough");
+ })).then(t.step_func_done(function() {
+ assert_equals(video.error, null);
+ }));
+
+ var movie = findMediaFile("video", "../resources/test");
+ video.src = "http://127.0.0.1:8000/media/video-throttled-load.cgi?name=" + movie + "&throttle=256";
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698