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

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: use timeupdate event 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}, function(stream) {
10 var previewURL = URL.createObjectURL(stream);
9 11
10 <script type="text/javascript"> 12 video.ontimeupdate = t.step_func(function() {
13 // restart preview.
14 video.src = previewURL;
15 video.ontimeupdate = t.step_func_done();
16 });
11 17
12 var previewURL = ""; 18 //start preview.
13 var localStream = null; 19 video.src = previewURL;
20 }, getStreamFailed);
14 21
15 if (window.internals) 22 function getStreamFailed(error) {
16 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); 23 t.unreached_func();
17
18 function startPreview()
19 {
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 } 24 }
37 25
38 setTimeout(replayIfTimeIsReached, playTimeInMillisecond); 26 video.onerror = t.unreached_func();
39 } 27 video.onloadstart = t.step_func(function() {});
40 28 video.onloadeddata = t.step_func(function() {});
41 function gotStreamFailed(error) 29 video.oncanplay = t.step_func(function() {});
42 { 30 video.onplay = t.step_func(function() {});
43 consoleWrite("Failed to get access to local media. Error code was " + error. code); 31 video.oncanplaythrough = t.step_func(function() {});
44 } 32 });
45 33 </script>
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 }
55
56 waitForEvent("error");
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