Chromium Code Reviews| 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..78a219b074fcdbece0c8c1cfd852192461ad2039 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-events-and-exceptions.html |
| @@ -0,0 +1,68 @@ |
| +<!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."); |
|
Justin Novosad
2015/12/04 14:45:29
Thanks for cleaning up this test. It is much easie
|
| + |
| +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 gotStream() { |
| + 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(); |
|
Justin Novosad
2015/12/04 14:45:29
Here you are potentially calling finishJSTest befo
Justin Novosad
2015/12/04 14:49:24
FWIW, this ordering does not actually matter other
emircan
2015/12/04 18:49:37
Moving it to the beginning of the file.
|
| +} |
| +gotStream(); |
|
Justin Novosad
2015/12/04 14:45:29
Should not call this if there was an exception. Al
emircan
2015/12/04 18:49:37
Renaming it to playMediaStream() and moving inside
|
| + |
| +window.jsTestIsAsync = true; |
| +window.successfullyParsed = true; |
|
Justin Novosad
2015/12/04 14:45:29
This is not necessary.
emircan
2015/12/04 18:49:37
Done.
|
| +</script> |
| +</body> |
| +</html> |