Bug 1304910 - Adding a test about nsTemporaryFileInputStream and PSendStream, r=jdm

--HG--
rename : dom/media/test/test_mediarecorder_record_canvas_captureStream.html => dom/media/test/test_temporary_file_blob_video_plays.html
This commit is contained in:
Andrea Marchesini 2016-09-27 16:39:47 +02:00
Родитель bef76e271e
Коммит 7505d76cd1
2 изменённых файлов: 74 добавлений и 0 удалений

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

@ -930,3 +930,4 @@ tags = suspend
tags = suspend
[test_background_video_no_suspend_disabled.html]
tags = suspend
[test_temporary_file_blob_video_plays.html]

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

@ -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.waitForPixelColor(video, helper.red, 128, "Should become red")
.then(SimpleTest.finish);
};
mediaRecorder.start();
is(mediaRecorder.state, "recording", "Media recorder should be recording");
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({set:[["media.recorder.max_memory", 1]]}, startTest);
</script>
</pre>
</body>
</html>