Bug 879717: Part 4 - Add mochitest for
bug 879717 r=roc
--- a/content/media/test/mochitest.ini
+++ b/content/media/test/mochitest.ini
@@ -314,16 +314,17 @@ skip-if = buildapp == 'mulet' || os == '
[test_bug465498.html]
[test_bug493187.html]
[test_bug495145.html]
[test_bug495300.html]
[test_bug654550.html]
[test_bug686942.html]
[test_bug726904.html]
[test_bug874897.html]
+[test_bug879717.html]
[test_bug883173.html]
[test_bug895091.html]
[test_bug895305.html]
[test_bug919265.html]
[test_bug957847.html]
[test_bug1018933.html]
[test_can_play_type.html]
[test_can_play_type_mpeg.html]
new file mode 100644
--- /dev/null
+++ b/content/media/test/test_bug879717.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>