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

Side by Side Diff: content/test/data/media/canvas_capture.html

Issue 2746973005: Reenable WebRtcCaptureFromElementBrowserTest.VerifyCanvasCaptureOffscreenCanvasCommitFrames (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « content/browser/webrtc/webrtc_capture_from_element_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Media Capture from Canvas Browser Test</title> 4 <title>Media Capture from Canvas Browser Test</title>
5 </head> 5 </head>
6 <body> 6 <body>
7 <div> Capture and playback from canvas elements.</div> 7 <div> Capture and playback from canvas elements.</div>
8 </body> 8 </body>
9 <script type="text/javascript" src="webrtc_test_utilities.js"></script> 9 <script type="text/javascript" src="webrtc_test_utilities.js"></script>
10 <script> 10 <script>
(...skipping 25 matching lines...) Expand all
36 function drawOffscreenCanvasCommit(canvas, drawCounter) { 36 function drawOffscreenCanvasCommit(canvas, drawCounter) {
37 var ctx = canvas.getContext('2d'); 37 var ctx = canvas.getContext('2d');
38 ctx.fillStyle = 'green'; 38 ctx.fillStyle = 'green';
39 ctx.fillRect(0, 0, canvas.width, canvas.height); 39 ctx.fillRect(0, 0, canvas.width, canvas.height);
40 ctx.commit(); 40 ctx.commit();
41 checkForRedraw(canvas, drawCounter, drawOffscreenCanvasCommit); 41 checkForRedraw(canvas, drawCounter, drawOffscreenCanvasCommit);
42 }; 42 };
43 43
44 function drawBitmapRenderer(canvas, drawCounter) { 44 function drawBitmapRenderer(canvas, drawCounter) {
45 var gl = canvas.getContext('bitmaprenderer'); 45 var gl = canvas.getContext('bitmaprenderer');
46 var offscreen = new OffscreenCanvas(64, 48); 46 var offscreen = new OffscreenCanvas(canvas.width, canvas.height);
47 var ctx = offscreen.getContext('2d'); 47 var ctx = offscreen.getContext('2d');
48 ctx.fillStyle = 'green'; 48 ctx.fillStyle = 'green';
49 ctx.fillRect(0, 0, canvas.width, canvas.height); 49 ctx.fillRect(0, 0, canvas.width, canvas.height);
50 gl.transferFromImageBitmap(offscreen.transferToImageBitmap()); 50 gl.transferFromImageBitmap(offscreen.transferToImageBitmap());
51 checkForRedraw(canvas, drawCounter, drawBitmapRenderer); 51 checkForRedraw(canvas, drawCounter, drawBitmapRenderer);
52 }; 52 };
53 53
54 function testCanvasCapture(drawFunction) { 54 function testCanvasCapture(drawFunction) {
55 var canvas = document.createElement('canvas'); 55 var canvas = document.createElement('canvas');
56 canvas.width = canvas.height = 64; 56 canvas.width = canvas.height = 64;
57 document.body.appendChild(canvas);
58 57
59 var stream = canvas.captureStream(); 58 var stream = canvas.captureStream();
60 assertTrue(stream, 'Error creating MediaStream'); 59 assertTrue(stream, 'Error creating MediaStream');
61 assertEquals(1, stream.getVideoTracks().length); 60 assertEquals(1, stream.getVideoTracks().length);
62 assertEquals(0, stream.getAudioTracks().length); 61 assertEquals(0, stream.getAudioTracks().length);
63 62
64 var recorded_events = 0; 63 var recorded_events = 0;
65 const recorder = new MediaRecorder(stream); 64 const recorder = new MediaRecorder(stream);
66 assertTrue(recorder, 'Error creating recorder out of the MediaStream'); 65 assertTrue(recorder, 'Error creating recorder out of the MediaStream');
67 66
68 recorder.ondataavailable = function(event) { 67 recorder.ondataavailable = function(event) {
69 if (event.data.size > ON_DATA_AVAILABLE_THRESHOLD) { 68 if (event.data.size > ON_DATA_AVAILABLE_THRESHOLD) {
70 if (++recorded_events == NUMBER_OF_EVENTS_TO_RECORD) 69 if (++recorded_events == NUMBER_OF_EVENTS_TO_RECORD)
71 reportTestSuccess(); 70 reportTestSuccess();
72 } 71 }
73 }; 72 };
74 73
75 recorder.start(0); 74 recorder.start(0);
76 if (drawFunction.toString() == drawOffscreenCanvasCommit.toString()) { 75 if (drawFunction.toString() == drawOffscreenCanvasCommit.toString()) {
77 var offscreen = canvas.transferControlToOffscreen(); 76 var offscreen = canvas.transferControlToOffscreen();
78 drawFunction(offscreen, 0); 77 drawFunction(offscreen, 0);
79 } else { 78 } else {
80 drawFunction(canvas, 0); 79 drawFunction(canvas, 0);
81 } 80 }
82 } 81 }
83 82
84 </script> 83 </script>
85 </body> 84 </body>
86 </html> 85 </html>
OLDNEW
« no previous file with comments | « content/browser/webrtc/webrtc_capture_from_element_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698