commit-queue@webkit.org | a02f39e | 2017-03-08 22:44:42 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <script src =../../resources/testharness.js></script> |
| 3 | <script src =../../resources/testharnessreport.js></script> |
| 4 | <script> |
| 5 | |
| 6 | async_test(t => { |
| 7 | var canvas = document.createElement('canvas'); |
| 8 | var ctx = canvas.getContext('2d'); |
| 9 | ctx.fillStyle = 'green'; |
| 10 | var recorder = new MediaRecorder(canvas.captureStream()); |
| 11 | var frameCount = 0; |
| 12 | |
| 13 | recorder.ondataavailable = function() { |
| 14 | t.step(function() { |
| 15 | assert_true(event.data.size > 0, 'Recorded data size should be > 0'); |
| 16 | }); |
| 17 | |
| 18 | frameCount = frameCount + 1; |
| 19 | if (frameCount > 3) { |
| 20 | recorder.stop(); |
| 21 | t.done(); |
| 22 | } else { |
| 23 | ctx.fillRect(0, 0, canvas.width, canvas.height); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | recorder.start(0); |
| 28 | ctx.fillRect(0, 0, canvas.width, canvas.height); |
| 29 | }, "Verify that drawing to a 2D canvas that is not attached to the DOM dispatches frames to an attached MediaRecorder." ); |
| 30 | |
| 31 | async_test(t => { |
| 32 | var canvas = document.createElement('canvas'); |
| 33 | var gl = canvas.getContext('webgl'); |
| 34 | gl.clearColor(0, 1, 0, 1); |
| 35 | var recorder = new MediaRecorder(canvas.captureStream()); |
| 36 | var frameCount = 0; |
| 37 | |
| 38 | recorder.ondataavailable = function() { |
| 39 | t.step(function() { |
| 40 | assert_true(event.data.size > 0, 'Recorded data size should be > 0'); |
| 41 | }); |
| 42 | |
| 43 | frameCount = frameCount + 1; |
| 44 | if (frameCount > 3) { |
| 45 | recorder.stop(); |
| 46 | t.done(); |
| 47 | } else { |
| 48 | gl.clear(gl.COLOR_BUFFER_BIT); |
| 49 | } |
| 50 | } |
| 51 | recorder.start(0); |
| 52 | |
| 53 | gl.clear(gl.COLOR_BUFFER_BIT); |
| 54 | }, "Verify that drawing to a webgl canvas that is not attached to the DOM dispatches frames to an attached MediaRecorder." ); |
| 55 | </script> |