Index: third_party/WebKit/LayoutTests/media/video-capture-preview.html |
diff --git a/third_party/WebKit/LayoutTests/media/video-capture-preview.html b/third_party/WebKit/LayoutTests/media/video-capture-preview.html |
index c1ce6ff92b64fe65d47b6a3f575189337c248bae..100950c48f238ca427913adf16bdd1c98d06f9e9 100644 |
--- a/third_party/WebKit/LayoutTests/media/video-capture-preview.html |
+++ b/third_party/WebKit/LayoutTests/media/video-capture-preview.html |
@@ -1,70 +1,34 @@ |
-<!DOCTYPE HTML"> |
-<html> |
-<head> |
-<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 src=video-played.js></script> |
- |
-<script type="text/javascript"> |
- |
-var previewURL = ""; |
-var localStream = null; |
- |
-if (window.internals) |
- window.internals.settings.setMediaPlaybackRequiresUserGesture(true); |
- |
-function startPreview() |
-{ |
- video.src = previewURL; |
-} |
- |
-function gotStream(stream) |
-{ |
- consoleWrite("got a stream"); |
- previewURL = URL.createObjectURL(stream); |
- startPreview(); |
- consoleWrite("start preview"); |
- localStream = stream; |
- var playTimeInMillisecond = 2500; |
- var replayIfTimeIsReached = function () |
- { |
- startPreview(); |
- consoleWrite("restart preview"); |
- setTimeout(endTest, playTimeInMillisecond); |
+<!DOCTYPE html> |
+<title>Verify video play using media stream as video src.</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<video autoplay></video> |
+<script> |
+async_test(function(t) { |
+ var video = document.querySelector("video"); |
+ navigator.webkitGetUserMedia({video:true}, gotStream, getStreamFailed); |
+ |
+ video.onerror = t.unreached_func(); |
+ video.onloadstart = t.step_func(function() {}); |
+ video.onloadeddata = t.step_func(function() {}); |
+ video.oncanplay = t.step_func(function() {}); |
+ video.onplay = t.step_func(function() {}); |
+ |
+ function gotStream(stream) { |
fs
2016/06/30 18:43:42
Could be anonymous or step_func?
Srirama
2016/06/30 19:16:22
Done.
|
+ var previewURL = URL.createObjectURL(stream); |
+ |
+ video.oncanplaythrough = t.step_func(function() { |
fs
2016/06/30 18:43:42
Not quite sure above what the old strategy had goi
Srirama
2016/06/30 19:16:22
It would have buffered most of the video by this t
fs
2016/06/30 19:21:12
We should probably play it safe, so go with timeup
|
+ video.oncanplaythrough = t.step_func_done(); |
+ // restart preview. |
+ video.src = previewURL; |
+ }); |
+ |
+ //start preview. |
+ video.src = previewURL; |
} |
- setTimeout(replayIfTimeIsReached, playTimeInMillisecond); |
-} |
- |
-function gotStreamFailed(error) |
-{ |
- consoleWrite("Failed to get access to local media. Error code was " + error.code); |
-} |
- |
-function playPreview() |
-{ |
- findMediaElement(); |
- try { |
- consoleWrite("request access to local media"); |
- navigator.webkitGetUserMedia({video:true}, gotStream, gotStreamFailed); |
- } catch (e) { |
- consoleWrite("getUserMedia error " + "(" + e.name + " / " + e.message + ")"); |
+ function getStreamFailed(error) { |
fs
2016/06/30 18:43:42
Like in test above.
Srirama
2016/06/30 19:16:22
Done.
|
+ assert_unreached(); |
} |
- |
- waitForEvent("error"); |
- waitForEvent("loadstart"); |
- waitForEvent("loadeddata"); |
- waitForEvent("canplay"); |
- waitForEvent("play"); |
- waitForEvent("canplaythrough"); |
-} |
- |
-</script> |
-</head> |
- |
-<body onload="playPreview()"> |
-<video width="320" height="240" autoplay="autoplay"></video> |
-</body> |
-</html> |
+}); |
+</script> |