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

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-capture-preview.html

Issue 2112003002: Convert video-canvas* and video-capture* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML"> 1 <!DOCTYPE html>
2 <html> 2 <title>Verify video play using media stream as video src.</title>
3 <head> 3 <script src="../resources/testharness.js"></script>
4 <script src=media-file.js></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 5 <video autoplay></video>
6 (Please avoid writing new tests using video-test.js) --> 6 <script>
7 <script src=video-test.js></script> 7 async_test(function(t) {
8 <script src=video-played.js></script> 8 var video = document.querySelector("video");
9 navigator.webkitGetUserMedia({video:true}, gotStream, getStreamFailed);
9 10
10 <script type="text/javascript"> 11 video.onerror = t.unreached_func();
12 video.onloadstart = t.step_func(function() {});
13 video.onloadeddata = t.step_func(function() {});
14 video.oncanplay = t.step_func(function() {});
15 video.onplay = t.step_func(function() {});
11 16
12 var previewURL = ""; 17 function gotStream(stream) {
fs 2016/06/30 18:43:42 Could be anonymous or step_func?
Srirama 2016/06/30 19:16:22 Done.
13 var localStream = null; 18 var previewURL = URL.createObjectURL(stream);
14 19
15 if (window.internals) 20 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
16 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); 21 video.oncanplaythrough = t.step_func_done();
22 // restart preview.
23 video.src = previewURL;
24 });
17 25
18 function startPreview() 26 //start preview.
19 { 27 video.src = previewURL;
20 video.src = previewURL;
21 }
22
23 function gotStream(stream)
24 {
25 consoleWrite("got a stream");
26 previewURL = URL.createObjectURL(stream);
27 startPreview();
28 consoleWrite("start preview");
29 localStream = stream;
30 var playTimeInMillisecond = 2500;
31 var replayIfTimeIsReached = function ()
32 {
33 startPreview();
34 consoleWrite("restart preview");
35 setTimeout(endTest, playTimeInMillisecond);
36 } 28 }
37 29
38 setTimeout(replayIfTimeIsReached, playTimeInMillisecond); 30 function getStreamFailed(error) {
fs 2016/06/30 18:43:42 Like in test above.
Srirama 2016/06/30 19:16:22 Done.
39 } 31 assert_unreached();
40
41 function gotStreamFailed(error)
42 {
43 consoleWrite("Failed to get access to local media. Error code was " + error. code);
44 }
45
46 function playPreview()
47 {
48 findMediaElement();
49 try {
50 consoleWrite("request access to local media");
51 navigator.webkitGetUserMedia({video:true}, gotStream, gotStreamFailed);
52 } catch (e) {
53 consoleWrite("getUserMedia error " + "(" + e.name + " / " + e.message + ")");
54 } 32 }
55 33 });
56 waitForEvent("error"); 34 </script>
57 waitForEvent("loadstart");
58 waitForEvent("loadeddata");
59 waitForEvent("canplay");
60 waitForEvent("play");
61 waitForEvent("canplaythrough");
62 }
63
64 </script>
65 </head>
66
67 <body onload="playPreview()">
68 <video width="320" height="240" autoplay="autoplay"></video>
69 </body>
70 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698