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

Unified 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: Added new interface to 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-events-and-exceptions.html
diff --git a/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-events-and-exceptions.html b/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-events-and-exceptions.html
new file mode 100644
index 0000000000000000000000000000000000000000..8ed45f412bc7b2ccb56a5f8160e634332c503aa4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-events-and-exceptions.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<canvas id="canvas_source"></canvas>
+<script>
+description("Exercises the potential events on CanvasCaptureMediaStream.");
+
+window.jsTestIsAsync = true;
+
+var canvas = document.getElementById('canvas_source');
+var stream;
+var track;
+
+function onVideoPlay() {
+ testPassed('Video play callback succeeded.');
+ drawToCanvas(canvas);
+};
+
+function onVideoCanPlayThrough() {
+ testPassed('Video canplaythrough callback succeeded.');
+ finishJSTest();
+};
+
+function drawToCanvas(canvas) {
+ testPassed('Drawing to canvas.');
+ var ctx = canvas.getContext("2d");
+ ctx.strokeStyle="#FF0204";
+ ctx.beginPath();
+ ctx.moveTo(0,0);
+ ctx.lineTo(100, 100);
+ ctx.stroke();
+};
+
+function playMediaStream() {
+ shouldBe('stream.getVideoTracks().length', '1');
+ track = stream.getVideoTracks()[0];
+ shouldBeEqualToString('track.readyState', 'live');
+
+ var video = document.createElement('video');
+ try {
+ video.src = window.URL.createObjectURL(stream);
+ testPassed('Plugged stream to video tag.');
+ } catch(e) {
+ testFailed('Exception plugging stream to <video>: ' + e);
+ finishJSTest();
+ }
+ video.addEventListener("play", onVideoPlay);
+ video.addEventListener("canplaythrough", onVideoCanPlayThrough);
+ video.play();
+};
+
+try {
+ stream = canvas.captureStream();
+ testPassed('Got a stream from canvas.');
+} catch (e) {
+ testFailed('Exception calling captureStream(): ' + e);
+ finishJSTest();
+}
+if (stream) {
+ playMediaStream();
+}
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698