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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-request-frame-events.html

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

Powered by Google App Engine
This is Rietveld 408576698