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

Unified Diff: third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-offscreencanvas.html

Issue 2632593003: Notify listeners on OffScreenCanvas changes (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLCanvasElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-offscreencanvas.html
diff --git a/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-offscreencanvas.html b/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-offscreencanvas.html
new file mode 100644
index 0000000000000000000000000000000000000000..b3104841ce18ec5e4a532fcdaae65b6146ee308f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-offscreencanvas.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<script src=../../resources/testharness.js></script>
+<script src=../../resources/testharnessreport.js></script>
+<script src="resources/webgl-test.js"></script>
+<script>
+
+function drawOn2DContext(canvas) {
+ var ctx = canvas.getContext('2d');
+ ctx.strokeStyle="#FF0204";
+ ctx.beginPath();
+ ctx.moveTo(0,0);
+ ctx.lineTo(100, 100);
+ ctx.stroke();
+ return ctx;
+};
+
+function drawOnWebGLContext(canvas) {
+ var ctx = create3DContext(canvas);
+ ctx.drawArrays(ctx.TRIANGLES, 0, 3);
+ return ctx;
+};
+
+// Run captureStream() after transferControlToOffscreen().
+var testOffScreenCanvasCommits = function(drawFunction, message) {
+ async_test(function(test) {
+ var canvas = document.createElement('canvas');
+ var offscreen = canvas.transferControlToOffscreen();
+
+ var recorder = new MediaRecorder(canvas.captureStream());
+ recorder.ondataavailable = test.step_func_done(function(event) {
+ assert_true(event.data.size > 0, 'Recorded data size should be > 0');
+ });
+ recorder.start(0);
+
+ var ctx = drawFunction(offscreen);
+ ctx.commit();
+ }), message;
+};
+
+generate_tests(testOffScreenCanvasCommits, [
Justin Novosad 2017/01/19 19:06:31 The testharness documentation says you can't use g
emircan 2017/01/19 20:50:52 Sorry for missing that. I just removed generate_te
+ [ "2d", drawOn2DContext, 'capture of an OffscreenCanvas with 2D context' ],
+ [ "webgl", drawOnWebGLContext, 'capture of an OffscreenCanvas with WebGL context' ]
+]);
+
+// Run captureStream() on OffscreenCanvas that uses transferFromImageBitmap().
+var testOffScreenCanvasTransferBitmaps = function(drawFunction, message) {
+ async_test(function(test) {
+ var canvas = document.createElement('canvas');
+ var ctx = canvas.getContext('bitmaprenderer');
+ var offscreen = new OffscreenCanvas(400,200);
+
+ var recorder = new MediaRecorder(canvas.captureStream());
+ recorder.ondataavailable = test.step_func_done(function(event) {
+ assert_true(event.data.size > 0, 'Recorded data size should be > 0');
+ });
+ recorder.start(0);
+
+ drawFunction(offscreen);
+ var image = offscreen.transferToImageBitmap();
+ assert_equals(image.width, 400);
+ assert_equals(image.height, 200);
+ ctx.transferFromImageBitmap(offscreen.transferToImageBitmap());
+ }), message;
+};
+
+generate_tests(testOffScreenCanvasTransferBitmaps, [
+ [ "2d", drawOn2DContext, 'capture of an OffscreenCanvas with 2D context' ],
+ [ "webgl", drawOnWebGLContext, 'capture of an OffscreenCanvas with WebGL context' ]
+]);
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLCanvasElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698