Bug 879717: Part 4 - Add mochitest for bug 879717 r=roc

This commit is contained in:
Andreas Pehrson 2014-10-06 11:22:55 +02:00
Родитель d6867b7276
Коммит d5c30211e1
2 изменённых файлов: 66 добавлений и 0 удалений

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

@ -319,6 +319,7 @@ skip-if = buildapp == 'mulet' || os == 'win' # bug 894922
[test_bug686942.html]
[test_bug726904.html]
[test_bug874897.html]
[test_bug879717.html]
[test_bug883173.html]
[test_bug895091.html]
[test_bug895305.html]

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

@ -0,0 +1,65 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for bug 879717, check that a video element can be drawn into a canvas directly on 'play' event</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<video id="v1" autoplay />
<video id="v2" autoplay />
<canvas id="c1" />
<canvas id="c2" />
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
var media = getPlayableVideo(gSmallTests);
var checkDrawImage = function(video, canvas, name) {
var exception = null;
var exceptionName = "nothing";
try {
var ctx = canvas.getContext('2d');
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
} catch (e) {
exception = e;
exceptionName = e.name;
}
ok(exception === null || video.ended,
"drawImage shouldn't throw an exception on play of " + name + ", got " + exceptionName);
};
if (media == null) {
todo(false, "No media supported.");
SimpleTest.finish();
} else {
v1.src = media.name;
v2.mozSrcObject = v1.mozCaptureStream();
var v1Tested = false;
var v2Tested = false;
v1.addEventListener('play', function() {
checkDrawImage(v1, c1, media.name);
v1Tested = true;
if (v2Tested) {
SimpleTest.finish();
}
});
v2.addEventListener('play', function() {
checkDrawImage(v2, c2, "stream of " + media.name);
v2Tested = true;
if (v1Tested) {
SimpleTest.finish();
}
});
}
</script>
</pre>
</body>
</html>