content/media/test/test_video_to_canvas.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=486646
michael@0 5 -->
michael@0 6
michael@0 7 <head>
michael@0 8 <title>Test for Bug 486646</title>
michael@0 9 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
michael@0 10 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 12 <script type="text/javascript" src="manifest.js"></script>
michael@0 13 </head>
michael@0 14 <body>
michael@0 15 <script class="testbody" type="text/javascript">
michael@0 16
michael@0 17 var manager = new MediaTestManager;
michael@0 18
michael@0 19 function loaded(e) {
michael@0 20 var v = e.target;
michael@0 21 ok(v.readyState >= v.HAVE_CURRENT_DATA,
michael@0 22 "readyState must be >= HAVE_CURRENT_DATA for " + v._name);
michael@0 23
michael@0 24 var canvas = document.createElement("canvas");
michael@0 25 canvas.width = v.videoWidth;
michael@0 26 canvas.height = v.videoHeight;
michael@0 27 document.body.appendChild(canvas);
michael@0 28 var ctx = canvas.getContext("2d");
michael@0 29 try {
michael@0 30 ctx.drawImage(v, 0, 0);
michael@0 31 ok(true, "Shouldn't throw exception while drawing to canvas from video for " + v._name);
michael@0 32 } catch (ex) {
michael@0 33 ok(false, "Shouldn't throw exception while drawing to canvas from video for " + v._name);
michael@0 34 }
michael@0 35
michael@0 36 v._finished = true;
michael@0 37 v.parentNode.removeChild(v);
michael@0 38 manager.finished(v.token);
michael@0 39 }
michael@0 40
michael@0 41 function startTest(test, token) {
michael@0 42 var type = getMajorMimeType(test.type);
michael@0 43 if (type != "video")
michael@0 44 return;
michael@0 45
michael@0 46 var v = document.createElement('video');
michael@0 47 v.token = token;
michael@0 48 manager.started(token);
michael@0 49 v.src = test.name;
michael@0 50 v._name = test.name;
michael@0 51 v._finished = false;
michael@0 52 v.autoplay = true;
michael@0 53 v.style.display = "none";
michael@0 54 v.addEventListener("ended", loaded, false);
michael@0 55 document.body.appendChild(v);
michael@0 56 }
michael@0 57
michael@0 58 SimpleTest.waitForExplicitFinish();
michael@0 59 SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
michael@0 60 function beginTest() {
michael@0 61 manager.runTests(gSmallTests, startTest);
michael@0 62 }
michael@0 63
michael@0 64 </script>
michael@0 65 </pre>
michael@0 66
michael@0 67 </body>
michael@0 68 </html>

mercurial