Bug 879717: Part 4 - Add mochitest for bug 879717 r=roc
☠☠ backed out by b2d92cb44873 ☠ ☠
authorAndreas Pehrson <pehrsons@gmail.com>
Mon, 06 Oct 2014 11:22:55 +0200
changeset 209019 353aee81348432381174cb0957fc8f84661dc8c1
parent 209018 cd7d8b93923f3fe80129955917d78e83ebce5da8
child 209020 88bb2a142e10a6ea86a04f04ddf381ae42bea905
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersroc
bugs879717
milestone35.0a1
Bug 879717: Part 4 - Add mochitest for bug 879717 r=roc
content/media/test/mochitest.ini
content/media/test/test_bug879717.html
--- 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>