summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_bug879717.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/test/test_bug879717.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/test/test_bug879717.html')
-rw-r--r--dom/media/test/test_bug879717.html134
1 files changed, 134 insertions, 0 deletions
diff --git a/dom/media/test/test_bug879717.html b/dom/media/test/test_bug879717.html
new file mode 100644
index 000000000..37c9a402a
--- /dev/null
+++ b/dom/media/test/test_bug879717.html
@@ -0,0 +1,134 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for bug 879717, check that a video element can be drawn into a canvas at various states of playback</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>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+//longer timeout for slow platforms
+if (isSlowPlatform()) {
+ SimpleTest.requestLongerTimeout(1.5);
+}
+
+var manager = new MediaTestManager;
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+
+var checkDrawImage = function(eventName, videoElement) {
+ var exception = null;
+ var exceptionName = "nothing";
+ try {
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(videoElement, 0, 0, canvas.width, canvas.height);
+ } catch (e) {
+ exception = e;
+ exceptionName = e.name;
+ }
+ ok(exception === null,
+ "drawImage shouldn't throw an exception on " + eventName +
+ " of " + videoElement.testName + ", got " + exceptionName);
+};
+
+var checkDrawImageEventHandler = function(ev) {
+ checkDrawImage(ev.type, ev.target);
+};
+var startTest = function(media, token) {
+ manager.started(token);
+
+ // File playback
+ var v1 = document.createElement("video");
+ v1.autoplay = true;
+
+ // Captured file playback
+ var v2 = document.createElement("video");
+
+ // Stream playback
+ var v3 = document.createElement("video");
+ v3.autoplay = true;
+
+ v1.gotLoadeddata = false;
+ v2.gotLoadeddata = false;
+ v3.gotLoadeddata = false;
+
+ v1.testName = "v1 (" + media.name + ")";
+ v2.testName = "v2 (Captured " + media.name + ")";
+ v3.testName = "v3 (Stream of " + media.name + ")";
+
+ checkDrawImage("beforeplay", v1);
+ checkDrawImage("beforeplay", v2);
+ checkDrawImage("beforeplay", v3);
+
+ v1.onloadedmetadata = checkDrawImageEventHandler;
+ v2.onloadedmetadata = checkDrawImageEventHandler;
+ v3.onloadedmetadata = checkDrawImageEventHandler;
+
+ v1.onplay = checkDrawImageEventHandler;
+ v2.onplay = checkDrawImageEventHandler;
+ v3.onplay = checkDrawImageEventHandler;
+
+ function onplaying(ev) {
+ if (!ev.target.gotPlaying) {
+ ev.target.gotPlaying = true;
+ checkDrawImageEventHandler(ev);
+ }
+ }
+ v1.onplaying = onplaying;
+ v2.onplaying = onplaying;
+ v3.onplaying = onplaying;
+
+ var onloadeddata = function(ev) {
+ ev.target.gotLoadeddata = true;
+ checkDrawImageEventHandler(ev);
+ };
+
+ v1.onloadeddata = onloadeddata;
+ v2.onloadeddata = onloadeddata;
+ v3.onloadeddata = onloadeddata;
+
+ var checkFinished = function() {
+ if (!v1.testFinished || !v2.testFinished || !v3.testFinished) {
+ return;
+ }
+
+ ok(v1.gotLoadeddata, v1.testName + " should have gotten the 'loadeddata' event callback");
+ ok(v2.gotLoadeddata, v2.testName + " should have gotten the 'loadeddata' event callback");
+ ok(v3.gotLoadeddata, v3.testName + " should have gotten the 'loadeddata' event callback");
+
+ manager.finished(token);
+ };
+
+ var onended = function(ev) {
+ checkDrawImageEventHandler(ev);
+ removeNodeAndSource(ev.target);
+ ev.target.testFinished = true;
+ checkFinished();
+ };
+
+ v1.onended = onended;
+ v2.onended = onended;
+ v3.onended = onended;
+
+ document.body.appendChild(v1);
+ document.body.appendChild(v2);
+ document.body.appendChild(v3);
+
+ v1.src = media.name;
+ v2.src = media.name;
+ v2.preload = 'metadata';
+
+ v2.addEventListener('loadedmetadata', function () {
+ v3.srcObject = v2.mozCaptureStreamUntilEnded();
+ v2.play();
+ });
+}
+
+manager.runTests(getPlayableVideos(gSmallTests), startTest);
+</script>
+</pre>
+</body>
+</html>