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

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: nits and updated 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 var canvas = document.getElementById('canvas_source');
14 var stream;
15 var track;
16
17 function onVideoPlay() {
18 testPassed('Video play callback succeeded.');
19 drawToCanvas(canvas);
20 };
21
22 function onVideoCanPlayThrough() {
23 testPassed('Video canplaythrough callback succeeded.');
24 finishJSTest();
25 };
26
27 function drawToCanvas(canvas) {
28 testPassed('Drawing to canvas.');
29 var ctx = canvas.getContext("2d");
30 ctx.strokeStyle="#FF0204";
31 ctx.beginPath();
32 ctx.moveTo(0,0);
33 ctx.lineTo(100, 100);
34 ctx.stroke();
35 }
36
37 function gotStream() {
38 shouldBe('stream.getVideoTracks().length', '1');
39 track = stream.getVideoTracks()[0];
40 shouldBeEqualToString('track.readyState', 'live');
41
42 var video = document.createElement('video');
43 try {
44 video.src = window.URL.createObjectURL(stream);
45 testPassed('Plugged stream to video tag.');
46 } catch(e) {
47 testFailed('Exception plugging stream to <video>: ' + e);
48 finishJSTest();
49 }
50 video.addEventListener("play", onVideoPlay);
51 video.addEventListener("canplaythrough", onVideoCanPlayThrough);
52 video.play();
53 };
54
55 try {
56 stream = canvas.captureStream();
57 testPassed('Got a stream from canvas.');
58 } catch (e) {
59 testFailed('Exception calling captureStream(): ' + e);
60 finishJSTest();
61 }
62 gotStream();
63
64 window.jsTestIsAsync = true;
65 window.successfullyParsed = true;
66 </script>
67 </body>
68 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698