Bug 1182426 - Test that we can record CanvasCaptureMediaStreams. r=roc

--HG--
extra : commitid : 9dFV0mv1iSr
extra : rebase_source : 111d3b636be9b72d97539d57f5e7dbea22c01d35
This commit is contained in:
Andreas Pehrson 2015-10-05 11:51:43 +08:00
Родитель 9d893f67a5
Коммит 7e6023b3b4
2 изменённых файлов: 76 добавлений и 0 удалений

Просмотреть файл

@ -680,6 +680,9 @@ tags=msg
tags=msg
[test_mediarecorder_record_audionode.html]
tags=msg
[test_mediarecorder_record_canvas_captureStream.html]
skip-if = (toolkit == 'android' || toolkit == 'gonk') # Bug 1210286 to fix canvas capturestream support in the OMX backend
tags=msg
[test_mediarecorder_record_changing_video_resolution.html]
skip-if = (toolkit == 'android' || toolkit == 'gonk') # Bug 1210286 to fix canvas capturestream support in the OMX backend
tags=msg

Просмотреть файл

@ -0,0 +1,73 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test MediaRecorder Recording canvas stream</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/dom/canvas/test/captureStream_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<div id="content">
</div>
<script class="testbody" type="text/javascript">
function startTest() {
var canvas = document.createElement("canvas");
canvas.width = canvas.height = 100;
document.getElementById("content").appendChild(canvas);
var helper = new CaptureStreamTestHelper2D(100, 100);
helper.drawColor(canvas, helper.red);
var stream = canvas.captureStream(0);
var blob;
mediaRecorder = new MediaRecorder(stream);
is(mediaRecorder.stream, stream,
"Media recorder stream = canvas stream at the start of recording");
mediaRecorder.onwarning = () => ok(false, "warning unexpectedly fired");
mediaRecorder.onerror = () => ok(false, "Recording failed");
mediaRecorder.ondataavailable = ev => {
is(blob, undefined, "Should only get one dataavailable event");
blob = ev.data;
};
mediaRecorder.onstart = () => {
info("Got 'start' event");
// We just want one frame encoded, to see that the recorder produces something readable.
mediaRecorder.stop();
};
mediaRecorder.onstop = () => {
info("Got 'stop' event");
ok(blob, "Should have gotten a data blob");
var video = document.createElement("video");
video.id = "recorded-video";
video.src = URL.createObjectURL(blob);
video.play();
video.onerror = err => {
ok(false, "Should be able to play the recording. Got error. code=" + video.error.code);
SimpleTest.finish();
};
document.getElementById("content").appendChild(video);
helper.waitForPixel(video, helper.red, 128, "Should become red")
.then(SimpleTest.finish);
};
mediaRecorder.start();
is(mediaRecorder.state, "recording", "Media recorder should be recording");
}
SimpleTest.waitForExplicitFinish();
startTest();
</script>
</pre>
</body>
</html>