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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-events-and-exceptions.html

Issue 1467103003: Basic use implementation for MediaStream from Canvas: captureStream() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added new interface to LayoutTests. Created 5 years 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
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <canvas id="canvas_source"></canvas>
10 <script>
11 description("Exercises the potential events on CanvasCaptureMediaStream.");
12
13 window.jsTestIsAsync = true;
14
15 var canvas = document.getElementById('canvas_source');
16 var stream;
17 var track;
18
19 function onVideoPlay() {
20 testPassed('Video play callback succeeded.');
21 drawToCanvas(canvas);
22 };
23
24 function onVideoCanPlayThrough() {
25 testPassed('Video canplaythrough callback succeeded.');
26 finishJSTest();
27 };
28
29 function drawToCanvas(canvas) {
30 testPassed('Drawing to canvas.');
31 var ctx = canvas.getContext("2d");
32 ctx.strokeStyle="#FF0204";
33 ctx.beginPath();
34 ctx.moveTo(0,0);
35 ctx.lineTo(100, 100);
36 ctx.stroke();
37 };
38
39 function playMediaStream() {
40 shouldBe('stream.getVideoTracks().length', '1');
41 track = stream.getVideoTracks()[0];
42 shouldBeEqualToString('track.readyState', 'live');
43
44 var video = document.createElement('video');
45 try {
46 video.src = window.URL.createObjectURL(stream);
47 testPassed('Plugged stream to video tag.');
48 } catch(e) {
49 testFailed('Exception plugging stream to <video>: ' + e);
50 finishJSTest();
51 }
52 video.addEventListener("play", onVideoPlay);
53 video.addEventListener("canplaythrough", onVideoCanPlayThrough);
54 video.play();
55 };
56
57 try {
58 stream = canvas.captureStream();
59 testPassed('Got a stream from canvas.');
60 } catch (e) {
61 testFailed('Exception calling captureStream(): ' + e);
62 finishJSTest();
63 }
64 if (stream) {
65 playMediaStream();
66 }
67
68 </script>
69 </body>
70 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698